当前位置: 代码迷 >> 综合 >> SAP-ABAP-普通OOALV,OOALV分屏展示,发送邮件excel附件合并单元格,附件带框线,附件居中。
  详细解决方案

SAP-ABAP-普通OOALV,OOALV分屏展示,发送邮件excel附件合并单元格,附件带框线,附件居中。

热度:4   发布时间:2023-12-13 04:18:46.0

功能展示

1.三个可拖动变换大小的屏幕

2.普通OOALV

 3.带格式的邮件附件,三个表格,合并居中,单元格带框线,指定列宽。

代码如下,复制可直接激活,没有include,创建程序后还有一些其他步骤,详情见后文

*&---------------------------------------------------------------------*
*& Report ZLQT_OOALV_SPLIT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZLQT_OOALV_SPLIT.
TABLES : t001,BKPF,SSCRFIELDS." ---TODO
TYPE-POOLS:icon.DATA: ok_code LIKE sy-ucomm.CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: event_receiver TYPE REF TO lcl_event_receiver.DATA: gt_fieldcat          TYPE lvc_t_fcat,gt_fieldcat1         TYPE lvc_t_fcat,gt_fieldcat2         TYPE lvc_t_fcat,gt_fieldcat3         TYPE lvc_t_fcat,gs_layout            TYPE lvc_s_layo,gs_variant           TYPE disvariant,gt_t_f4              TYPE lvc_t_f4,GT_SELCELL           TYPE LVC_T_CELL,it_toolbar_excluding TYPE ui_functions.DATA: stbl TYPE lvc_s_stbl. "鼠标游标位置
DATA: et_filtered TYPE lvc_t_fidx.
DATA: gv_code TYPE sy-tcode .DATA alv_grid TYPE REF TO cl_gui_alv_grid. "后面要用到CL_GUI_ALV_GRID类中的方法
"SET_TABLE_FIRST_DISPLAY,这个方法基于实例存在,必须
"为这个类创建一个对象。在此处声明。
DATA gs_parent TYPE REF TO cl_gui_custom_container . "定义容器
DATA gt_select TYPE lvc_t_cell . "定義選中單元格方法參數
DATA gt_selrow TYPE lvc_t_row  . "定義選中行方法參數*DATA: gr_table TYPE REF TO cl_salv_table.
*DATA: lr_functions TYPE REF TO cl_salv_functions."$. Region 此处定义改为需要用到的定义-TODO
TYPES : BEGIN OF ty_item ,XH       TYPE C LENGTH 3,SUM      TYPE C LENGTH 3,YUE01    TYPE C LENGTH 3,YUE02    TYPE C LENGTH 3,YUE03    TYPE C LENGTH 3,YUE04    TYPE C LENGTH 3,YUE05    TYPE C LENGTH 3,YUE06    TYPE C LENGTH 3,YUE07    TYPE C LENGTH 3,YUE08    TYPE C LENGTH 3,YUE09    TYPE C LENGTH 3,YUE10    TYPE C LENGTH 3,YUE11    TYPE C LENGTH 3,YUE12    TYPE C LENGTH 3,END OF ty_item .
DATA gt_item TYPE TABLE OF ty_item .TYPES : BEGIN OF TY_HB1 ,XH       TYPE C LENGTH 3,SUM      TYPE C LENGTH 3,YUE01    TYPE C LENGTH 3,YUE02    TYPE C LENGTH 3,YUE03    TYPE C LENGTH 3,YUE04    TYPE C LENGTH 3,YUE05    TYPE C LENGTH 3,YUE06    TYPE C LENGTH 3,YUE07    TYPE C LENGTH 3,YUE08    TYPE C LENGTH 3,YUE09    TYPE C LENGTH 3,YUE10    TYPE C LENGTH 3,YUE11    TYPE C LENGTH 3,YUE12    TYPE C LENGTH 3,
END OF TY_HB1 .
DATA gt_HB1 TYPE TABLE OF TY_HB1 .
DATA gS_HB1 TYPE  TY_HB1 .
DATA gt_HB1S TYPE TABLE OF TY_HB1 .
DATA gS_HB1S TYPE  TY_HB1 .TYPES : BEGIN OF TY_HB2 ,XH       TYPE C LENGTH 3,SUM      TYPE C LENGTH 3,YC01     TYPE C LENGTH 3,YC02     TYPE C LENGTH 3,YC03     TYPE C LENGTH 3,YC04     TYPE C LENGTH 3,
END OF TY_HB2 .
DATA gt_HB2 TYPE TABLE OF TY_HB2 .
DATA gS_HB2 TYPE  TY_HB2 .
DATA gS_HB2S TYPE  TY_HB2 .TYPES : BEGIN OF TY_HB3 ,XH       TYPE C LENGTH 3,SUM      TYPE C LENGTH 3,YUE01    TYPE C LENGTH 3,YUE02    TYPE C LENGTH 3,YUE03    TYPE C LENGTH 3,YUE04    TYPE C LENGTH 3,YUE05    TYPE C LENGTH 3,YUE06    TYPE C LENGTH 3,YUE07    TYPE C LENGTH 3,YUE08    TYPE C LENGTH 3,YUE09    TYPE C LENGTH 3,YUE10    TYPE C LENGTH 3,YUE11    TYPE C LENGTH 3,YUE12    TYPE C LENGTH 3,
END OF TY_HB3 .
DATA gt_HB3 TYPE TABLE OF TY_HB3 .
DATA gS_HB3 TYPE  TY_HB3 .
DATA gS_HB3S TYPE  TY_HB3 .DATA: gt_xml_table_forecast   TYPE TABLE OF x255.
"拆分屏幕定义
DATA: g_doc_cont   TYPE REF TO cl_gui_docking_container.
DATA: g_grid_left   TYPE REF TO cl_gui_alv_grid.
DATA: g_grid_right  TYPE REF TO cl_gui_alv_grid.
DATA: g_grid2       TYPE REF TO cl_gui_alv_grid.
"$. Endregion 此处定义改为需要用到的定义-TODO*&---------------------------------------------------------------------*
*&       Class LCL_EVENT_RECEIVER
*&---------------------------------------------------------------------*
*        Text
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.PUBLIC SECTION.METHODS handle_double_click FOR EVENT double_click OF cl_gui_alv_grid    "定义类中的方法---双击IMPORTING e_row e_column es_row_no.                                    ""                                                 "METHODS handle_onf4 FOR EVENT onf4 OF cl_gui_alv_grid                    "定义类中的方法---F4帮助IMPORTING e_fieldname es_row_no er_event_data .                        ""METHODS handle_toolbar      FOR EVENT toolbar OF cl_gui_alv_grid         "定义类中的方法---ALV状态栏按钮IMPORTING e_object e_interactive .                                     ""METHODS handle_user_command FOR EVENT user_command OF cl_gui_alv_grid    "定义类中的方法---按钮触发方法IMPORTING e_ucomm .                                                    ""METHODS handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid    "定义类中的方法---数据修改时的方法IMPORTING er_data_changed e_onf4 e_onf4_before e_onf4_after e_ucomm.   "METHODS  handle_data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_gridIMPORTING e_modified et_good_cells.
ENDCLASS. "LCL_EVENT_RECEIVER
"$. Endregion 定义"$. Region 选择屏幕-TODOSELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.PARAMETERS : P_ZYEAR TYPE BKPF-GJAHR DEFAULT SY-DATUM(4) .SELECTION-SCREEN SKIP 1 .PARAMETERS : P_MX RADIOBUTTON GROUP G1 DEFAULT 'X'.  "明细数据PARAMETERS : P_HZ1 RADIOBUTTON GROUP G1 .            "责任部门与异常零件点数统计"
"  PARAMETERS : P_HZ2 RADIOBUTTON GROUP G1.            "责任部门与延迟天数统计汇总
"  PARAMETERS : P_HZ3 RADIOBUTTON GROUP G1.            "责任部门与责任人异常零件点数统计TOP10SELECTION-SCREEN END OF BLOCK b1 .SELECTION-SCREEN FUNCTION KEY 1. "
"$. Endregion 选择屏幕-TODO
INITIALIZATION.stbl-row = 'X'.stbl-col = 'X'.SSCRFIELDS-FUNCTXT_01 = '维护邮箱'.AT SELECTION-SCREEN."$. Region 权限-TODO* SELECT T001~BUKRS FROM T001 WHERE T001~BUKRS IN @S_BUKRS INTO TABLE @DATA(GT_BUKRS) .
*
* LOOP AT GT_BUKRS INTO DATA(GS_BUKRS).
*  AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
*              ID 'BUKRS' FIELD GS_BUKRS-BUKRS
*               ID 'ACTVT' FIELD '03'.
*  IF SY-SUBRC <> 0.
*      MESSAGE '您没有公司代码' && GS_BUKRS-BUKRS  && '的操作权限!'   TYPE 'E' .
*
*  ENDIF.
*
* ENDLOOP."$. Endregion 权限-TODOCASE SSCRFIELDS-UCOMM.          "处理按钮命令WHEN'FC01'.CALL FUNCTION 'VIEW_MAINTENANCE_CALL'EXPORTINGACTION    = 'U'VIEW_NAME = 'ZTMM200_MAIL'.  "改成自己维护邮箱的表或者删掉在后面写死WHEN OTHERS.ENDCASE.START-OF-SELECTION.PERFORM frm_get_data.IF P_MX = 'X'.CALL SCREEN 9000.ELSEIF P_HZ1 = 'X' .CALL SCREEN 8000.ENDIF."$. Region FORM
MODULE status_9000 OUTPUT.SET PF-STATUS '9000'.SET TITLEBAR '9000'.DATA(gv_frist) = 'X' . "判断是不是第一次运行,自添加按钮需要刷新才能显示PERFORM prepare_field_catalog USING 0 CHANGING gt_fieldcat.PERFORM prepare_field_catalog USING 1 CHANGING gt_fieldcat1.PERFORM prepare_field_catalog USING 2 CHANGING gt_fieldcat2.PERFORM prepare_field_catalog USING 3 CHANGING gt_fieldcat3.PERFORM prepare_layout        CHANGING gs_layout.IF P_MX = 'X'.PERFORM frm_display_alv .ELSEIF P_HZ1 = 'X' .PERFORM frm_display_alv_SPLIT .ENDIF.IF gv_frist = 'X' AND alv_grid IS NOT INITIAL.CALL METHOD alv_grid->refresh_table_display  "增加按钮需要刷新才会显示出来,否则无法显示。EXPORTINGis_stable = stbl.gv_frist = '0' ."判断是否为第一次,为第一次则刷新ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.gv_code = ok_code .CASE ok_code.WHEN 'BACK'.CLEAR: gt_item.LEAVE TO SCREEN 0.WHEN 'EXIT'.LEAVE PROGRAM.WHEN 'CANCEL'.CLEAR: gt_item.LEAVE TO SCREEN 0.WHEN 'MAIL'.PERFORM frm_process_xml_data.PERFORM frm_send_email .ENDCASE.
ENDMODULE.*----------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.METHOD handle_double_click.MESSAGE  '双击' TYPE 'S'. "  e_row  e_column  es_row_noCALL METHOD alv_grid->get_selected_cellsIMPORTINGet_cell = GT_SELCELL.ENDMETHOD.                    "HANDLE_DOUBLE_CLICK双击后触发该段代码,可接T-CODE跳转等功能METHOD handle_onf4.DATA: ls_modi    TYPE lvc_s_modi,lt_ret_tab TYPE TABLE OF ddshretval.IF e_fieldname = 'REPTEXT'.READ TABLE gt_item INDEX es_row_no-row_id ASSIGNING FIELD-SYMBOL(<fs_item>).
*      CHECK sy-subrc = 0.IF sy-subrc = 0..CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTINGretfield   = 'DDTEXT'value_org  = 'S'TABLESvalue_tab  = gt_itemreturn_tab = lt_ret_tab.IF sy-subrc = 0.READ TABLE lt_ret_tab INDEX 1 ASSIGNING FIELD-SYMBOL(<fs_ret>).IF sy-subrc = 0.ENDIF.ENDIF.er_event_data->m_event_handled = 'X'.CALL METHOD alv_grid->refresh_table_displayEXPORTINGis_stable = stbl.ENDIF .ENDIF .ENDMETHOD.                    "需在ALV中调用触发一般与filedcat中的 f4availabl 参数同用METHOD handle_toolbar.    "在ALV状态栏增加按钮,一般是汇总按钮,新增后的按钮可触发HANDLE_USER_COMMAND方法DATA: ls_toolbar        TYPE stb_button.CLEAR ls_toolbar.MOVE 3                  TO ls_toolbar-butn_type.      "分隔符APPEND ls_toolbar       TO e_object->mt_toolbar."    CLEAR ls_toolbar.
"    MOVE 'MAIL'            TO ls_toolbar-function.        "功能码
"    MOVE '发送邮件'         TO ls_toolbar-quickinfo.
"    MOVE '发送邮件'         TO ls_toolbar-text.            "显示名称
"    MOVE ' '                TO ls_toolbar-disabled.
"    APPEND ls_toolbar       TO e_object->mt_toolbar.ENDMETHOD.                    "在ALV状态栏增加按钮,一般是汇总按钮METHOD handle_user_command.CASE e_ucomm.WHEN 'MAIL'.WHEN OTHERS.ENDCASE.CALL METHOD alv_grid->set_frontend_layoutEXPORTINGis_layout = gs_layout.CALL METHOD alv_grid->refresh_table_displayEXPORTINGis_stable = stbl.ENDMETHOD.                    "一般与HANDLE_TOOLBAR同用METHOD handle_data_changed.   "er_data_changed e_onf4 e_onf4_before e_onf4_after e_ucomm.
"用途在于检查这行是否能修改,数据是否合法LOOP AT er_data_changed->mt_good_cells  ASSIGNING FIELD-SYMBOL(<ls_good>).ENDLOOP .ENDMETHOD.                    "数据修改后触发,一般用在数据联动修改如数量字段修改,同时联动修改金额字段METHOD handle_data_changed_finished."用途在于修改后的数据联动,DATA: ls_et_good_cell  TYPE lvc_s_modi.LOOP AT et_good_cells INTO ls_et_good_cell.READ TABLE gt_item ASSIGNING FIELD-SYMBOL(<fs_item>) INDEX ls_et_good_cell-row_id.IF sy-subrc = '0'.IF ls_et_good_cell-fieldname = 'SCRTEXT_L'.ENDIF.ENDIF.ENDLOOP.CALL METHOD alv_grid->refresh_table_displayEXPORTINGis_stable = stbl.ENDMETHOD.ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_display_alv  ." CLEAR: gt_fieldcat,gt_fieldcat1,gt_fieldcat2,gt_fieldcat3,gs_layout,it_toolbar_excluding.gs_variant-report = sy-repid.gs_variant-handle = '0001'.
******实例化 容器CREATE OBJECT gs_parentEXPORTINGcontainer_name = 'ALV'. " 界面中的一个CUNSTOMER CONTROL控件 用于存放类对象。"使用这个控件把名称赋值给CONTAINER_NAME******将alv植入到容器中CREATE OBJECT alv_gridEXPORTINGi_parent = gs_parent.PERFORM toolbar_excluding_item     CHANGING it_toolbar_excluding.  "ALV按钮排除CALL METHOD alv_grid->set_table_for_first_displayEXPORTINGis_layout            = gs_layouti_save               = 'A'i_default            = 'X'is_variant           = gs_variantit_toolbar_excluding = it_toolbar_excludingCHANGINGit_outtab            = gt_itemit_fieldcatalog      = gt_fieldcat.CREATE OBJECT event_receiver. "创建事件SET HANDLER event_receiver->handle_double_click          FOR alv_grid. "双击事件
*    SET HANDLER event_receiver->handle_onf4                  FOR alv_grid. "F4帮助事件SET HANDLER event_receiver->handle_toolbar               FOR alv_grid. "ALV状态栏SET HANDLER event_receiver->handle_user_command          FOR alv_grid. "按钮事件SET HANDLER event_receiver->handle_data_changed          FOR alv_grid. "修改事件SET HANDLER event_receiver->handle_data_changed_finished FOR alv_grid. "数据修改后触发事件"    gt_t_f4 = VALUE #( BASE gt_t_f4 ( fieldname = 'REPTEXT'  register = 'X' getbefore = 'X' chngeafter = 'X' ) ) .
"    CALL METHOD alv_grid->register_f4_for_fields "注册F4帮助事件
"      EXPORTING
"        it_f4 = gt_t_f4.CALL METHOD alv_grid->register_edit_event "注册编辑事件,否则不会触发更新事件EXPORTINGi_event_id = cl_gui_alv_grid=>mc_evt_modified.CALL METHOD alv_grid->set_frontend_layoutEXPORTINGis_layout = gs_layout.CALL METHOD alv_grid->SET_FRONTEND_FIELDCATALOGEXPORTINGIT_FIELDCATALOG = gt_fieldcat.CALL METHOD cl_gui_control=>set_focusEXPORTINGcontrol = alv_grid.CALL METHOD cl_gui_cfw=>flush.
"  IF  alv_grid IS INITIAL .
"  ELSE.
"    CALL METHOD alv_grid->set_frontend_layout
"      EXPORTING
"        is_layout = gs_layout.
"    CALL METHOD alv_grid->refresh_table_display
"      EXPORTING
"        is_stable = stbl.
"  ENDIF.
ENDFORM.*&---------------------------------------------------------------------*
*&      Form  PREPARE_FIELD_CATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM prepare_field_catalog USING I CHANGING p_gt_fieldcat TYPE lvc_t_fcat.DATA ls_fcat TYPE lvc_s_fcat.DEFINE set_fcat.CLEAR ls_fcat.ls_fcat-fieldname = &1.   "字段ls_fcat-outputlen = &2.   "列的字符宽度ls_fcat-key       = &3.   "主键ls_fcat-edit      = &4.   "可编辑ls_fcat-ref_table = &5.   "参考表ls_fcat-ref_field = &6.   "参考字段ls_fcat-icon      = &7.   "以圖標輸出
*    ls_fcat-NO_ZERO   = &8.   "前导0ls_fcat-coltext   = &9.   "描述ls_fcat-f4availabl = &8.APPEND ls_fcat TO p_gt_fieldcat.END-OF-DEFINITION.CLEAR :p_gt_fieldcat[],ls_fcat .CASE I.WHEN 0.set_fcat 'ZSYSTEM'   ''   ''   ''    'ZTMM200_LOG'    'ZSYSTEM'       ''       ''      '订单发送外围系统'.set_fcat 'EKGRP'     ''   ''   ''    'ZTMM200_LOG'    'EKGRP'         ''       ''      '采购组'.set_fcat 'VERKF'     ''   ''   ''    'ZTMM200_LOG'    'VERKF'         ''       ''      '卖方业务伙伴订单'.set_fcat 'TELF1'     ''   ''   ''    'ZTMM200_LOG'    'TELF1'         ''       ''      '订购用途'.set_fcat 'LIFNR'     ''   ''   ''    'ZTMM200_LOG'    'LIFNR'         ''       ''      '供应商或债权人的帐号'.set_fcat 'UNSEZ'     ''   ''   ''    'ZTMM200_LOG'    'UNSEZ'         ''       ''      '出货地'.set_fcat 'MATNR'     ''   ''   ''    'ZTMM200_LOG'    'MATNR'         ''       ''      '物料编号'.set_fcat 'MENGE'     ''   ''   ''    'ZTMM200_LOG'    'MENGE'         ''       ''      '采购订单数量'.set_fcat 'ZSTATUS'   ''   ''   ''    'ZTMM200_LOG'    'ZSTATUS'       ''       ''      '采购状态'.set_fcat 'WERKS'     ''   ''   ''    'ZTMM200_LOG'    'WERKS'         ''       ''      '工厂'.set_fcat 'LGORT'     ''   ''   ''    'ZTMM200_LOG'    'LGORT'         ''       ''      '库存地点'.set_fcat 'EEIND'     ''   ''   ''    'ZTMM200_LOG'    'EEIND'         ''       ''      '交货日期'.set_fcat 'ZDATE'     ''   ''   ''    'ZTMM200_LOG'    'ZDATE'         ''       ''      '接口传输日期'.set_fcat 'ZTIME'     ''   ''   ''    'ZTMM200_LOG'    'ZTIME'         ''       ''      '接口传输时间'.set_fcat 'UNAME'     ''   ''   ''    'ZTMM200_LOG'    'UNAME'         ''       ''      '用户名'.set_fcat 'EBELN'     ''   ''   ''    'ZTMM200_LOG'    'EBELN'         ''       ''      '采购凭证编号'.set_fcat 'EBELP'     ''   ''   ''    'ZTMM200_LOG'    'EBELP'         ''       ''      '采购凭证的项目编号'.set_fcat 'TEXT2'     ''   ''   ''    'ZTMM200_LOG'    'TEXT2'         ''       ''      '参考字段'.set_fcat 'NAME1'     ''   ''   ''    'ZTMM200_LOG'    'NAME1'         ''       ''      '名称'.set_fcat 'MAKTX'     ''   ''   ''    'ZTMM200_LOG'    'MAKTX'         ''       ''      '物料描述'.set_fcat 'ZDATE1'    ''   ''   ''    'ZTMM200_LOG'    'ZDATE1'        ''       ''      '重处理日期'.set_fcat 'ZTIME1'    ''   ''   ''    'ZTMM200_LOG'    'ZTIME1'        ''       ''      '重处理时间'.WHEN 1.set_fcat ' XH   '   ''   ''   ''    ''    ''       ''       ''      '序号'.set_fcat ' ZRESD'   ''   ''   ''    ''    ''       ''       ''      '责任部门'.set_fcat ' SUM  '   ''   ''   ''    ''    ''       ''       ''      '年度累计'.set_fcat ' YUE01'   ''   ''   ''    ''    ''       ''       ''      '1月'.set_fcat ' YUE02'   ''   ''   ''    ''    ''       ''       ''      '2月'.set_fcat ' YUE03'   ''   ''   ''    ''    ''       ''       ''      '3月'.set_fcat ' YUE04'   ''   ''   ''    ''    ''       ''       ''      '4月'.set_fcat ' YUE05'   ''   ''   ''    ''    ''       ''       ''      '5月'.set_fcat ' YUE06'   ''   ''   ''    ''    ''       ''       ''      '6月'.set_fcat ' YUE07'   ''   ''   ''    ''    ''       ''       ''      '7月'.set_fcat ' YUE08'   ''   ''   ''    ''    ''       ''       ''      '8月'.set_fcat ' YUE09'   ''   ''   ''    ''    ''       ''       ''      '9月'.set_fcat ' YUE10'   ''   ''   ''    ''    ''       ''       ''      '10月'.set_fcat ' YUE11'   ''   ''   ''    ''    ''       ''       ''      '11月'.set_fcat ' YUE12'   ''   ''   ''    ''    ''       ''       ''      '12月'.WHEN 2.set_fcat 'XH   '   ''   ''   ''    ''    ''       ''       ''      '序号'.set_fcat 'ZRESD'   ''   ''   ''    ''    ''       ''       ''      '责任部门'.set_fcat 'SUM  '   ''   ''   ''    ''    ''       ''       ''      '年度累计'.set_fcat 'YC01 '   ''   ''   ''    ''    ''       ''       ''      '1-3天'.set_fcat 'YC02 '   ''   ''   ''    ''    ''       ''       ''      '4-7天'.set_fcat 'YC03 '   ''   ''   ''    ''    ''       ''       ''      '8-14天'.set_fcat 'YC04 '   ''   ''   ''    ''    ''       ''       ''      '15天以上'.WHEN 3.set_fcat ' XH   '   ''   ''   ''    ''    ''       ''       ''      '序号'.set_fcat ' ZRESD'   ''   ''   ''    ''    ''       ''       ''      '责任部门'.set_fcat ' ZRESP'   ''   ''   ''    ''    ''       ''       ''      '责任人'.set_fcat ' SUM  '   ''   ''   ''    ''    ''       ''       ''      '年度累计'.set_fcat ' YUE01'   ''   ''   ''    ''    ''       ''       ''      '1月'.set_fcat ' YUE02'   ''   ''   ''    ''    ''       ''       ''      '2月'.set_fcat ' YUE03'   ''   ''   ''    ''    ''       ''       ''      '3月'.set_fcat ' YUE04'   ''   ''   ''    ''    ''       ''       ''      '4月'.set_fcat ' YUE05'   ''   ''   ''    ''    ''       ''       ''      '5月'.set_fcat ' YUE06'   ''   ''   ''    ''    ''       ''       ''      '6月'.set_fcat ' YUE07'   ''   ''   ''    ''    ''       ''       ''      '7月'.set_fcat ' YUE08'   ''   ''   ''    ''    ''       ''       ''      '8月'.set_fcat ' YUE09'   ''   ''   ''    ''    ''       ''       ''      '9月'.set_fcat ' YUE10'   ''   ''   ''    ''    ''       ''       ''      '10月'.set_fcat ' YUE11'   ''   ''   ''    ''    ''       ''       ''      '11月'.set_fcat ' YUE12'   ''   ''   ''    ''    ''       ''       ''      '12月'.WHEN OTHERS.ENDCASE.ENDFORM.*&---------------------------------------------------------------------*
*&      Form  PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM prepare_layout CHANGING p_gs_layout TYPE lvc_s_layo.p_gs_layout-zebra      = 'X'.      "斑馬紋顯示p_gs_layout-sel_mode   = 'A'.      "選擇模式p_gs_layout-cwidth_opt = 'X'.      "最佳列寬
ENDFORM.FORM toolbar_excluding_item CHANGING pt_exclude TYPE ui_functions.DATA ls_exclude TYPE ui_func.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.APPEND ls_exclude TO pt_exclude.ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.APPEND ls_exclude TO pt_exclude.
ENDFORM.*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_get_data .
ENDFORM.FORM frm_display_alv_SPLIT .IF g_doc_cont IS INITIAL.CREATE OBJECT g_doc_contEXPORTINGratio = '95'side  = cl_gui_docking_container=>dock_at_left.  " 1PERFORM frm_alv_global_splitter_objectUSING g_doc_contCHANGING g_grid_left g_grid_right g_grid2.ENDIF.
ENDFORM .*&---------------------------------------------------------------------*
*&      Form  ALV_GLOBAL_SPLITTER_OBJECT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PA_DCON    text
*      -->PA_TOP     text
*      -->PA_BOTTOM  text
*      -->PV_HEIGHT  text
*----------------------------------------------------------------------*
FORM frm_alv_global_splitter_object USINGpv_dcont  TYPE REF TO cl_gui_docking_containerCHANGINGcv_grid1   TYPE REF TO cl_gui_alv_gridcv_grid2   TYPE REF TO cl_gui_alv_gridcv_grid3   TYPE REF TO cl_gui_alv_grid.DATA: lv_split  TYPE REF TO cl_gui_splitter_container.DATA: lv_split2 TYPE REF TO cl_gui_splitter_container.*-- 分开DATA: lv_t1 TYPE i VALUE 1.DATA: lv_t2 TYPE i VALUE 2.PERFORM frm_split_cont  USING pv_dcont 2 1     CHANGING lv_split.PERFORM frm_split_cont2 USING lv_split 1 1 1 2 CHANGING lv_split2.PERFORM frm_split_set_grid USING lv_split2 1 1 1 CHANGING cv_grid1.PERFORM frm_split_set_grid USING lv_split2 1 2 2 CHANGING cv_grid2.PERFORM frm_split_set_grid USING lv_split  2 1 3 CHANGING cv_grid3.lv_split->set_row_height( id = 1 height = 50 ).lv_split2->set_column_width( id = 1 width = 50 ).ENDFORM. "alv_splitter_object*&---------------------------------------------------------------------*
*&      Form  FRM_SPLIT_CONT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_G_SPLITTER1PA_DCON  text
*      -->P_1      text
*      -->P_2      text
*----------------------------------------------------------------------*
FORM frm_split_contUSING    pv_dco_cont TYPE REF TO cl_gui_docking_containerpv_c1 pv_c2CHANGING pv_splitter TYPE REF TO cl_gui_splitter_container.IF pv_dco_cont IS NOT INITIAL.CREATE OBJECT pv_splitterEXPORTINGparent  = pv_dco_controws    = pv_c1columns = pv_c2.ENDIF.ENDFORM.                    " FRM_SPLIT_CONT
*&---------------------------------------------------------------------*
*&      Form  frm_split_cont2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PV_SPLIT     text
*      -->PV_P1        text
*      -->PV_P2        text
*      -->PV_C1        text
*      -->PV_C2        text
*      <--PV_SPLITTER  text
*----------------------------------------------------------------------*
FORM frm_split_cont2USING   pv_split    TYPE REF TO cl_gui_splitter_containerpv_p1 pv_p2 pv_c1 pv_c2CHANGING pv_splitter TYPE REF TO cl_gui_splitter_container.IF pv_split IS NOT INITIAL.CREATE OBJECT pv_splitterEXPORTINGparent  = pv_split->get_container( row = pv_p1 column = pv_p2 )rows    = pv_c1columns = pv_c2.ENDIF.ENDFORM.                    " FRM_SPLIT_CONT
*&---------------------------------------------------------------------*
*&      Form  FRM_SPLIT_CONT_SET
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_G_SPLITTER1  text
*      -->P_1      text
*      -->P_1      text
*      <--P_PA_TOP1  text
*----------------------------------------------------------------------*
FORM frm_split_set_gridUSING pv_split TYPE REF TO cl_gui_splitter_containerp_v1p_v2ICHANGING cv_grid TYPE REF TO cl_gui_alv_grid.DATA: pv_cont TYPE REF TO cl_gui_container.CALL METHOD pv_split->get_containerEXPORTINGrow       = p_v1column    = p_v2RECEIVINGcontainer = pv_cont.IF sy-subrc = 0.CREATE OBJECT cv_grid  "创建第一个ALV,并放在容器中EXPORTINGi_parent = pv_cont.CASE I.WHEN 1.gs_layout-GRID_TITLE = '责任部门与异常零件点数统计' .CALL METHOD cv_grid->set_frontend_layoutEXPORTINGis_layout = gs_layout.CALL METHOD cv_grid->set_table_for_first_displayEXPORTINGis_layout       = gs_layoutCHANGINGit_outtab       = gt_HB1[]it_fieldcatalog = gt_fieldcat1[].WHEN 2.gs_layout-GRID_TITLE = '责任部门与延迟天数统计' .CALL METHOD cv_grid->set_frontend_layoutEXPORTINGis_layout = gs_layout.CALL METHOD cv_grid->set_table_for_first_displayEXPORTINGis_layout       = gs_layoutCHANGINGit_outtab       = gt_HB2[]it_fieldcatalog = gt_fieldcat2[].WHEN 3.gs_layout-GRID_TITLE = '责任部门与责任人异常零件点数统计TOP10' .CALL METHOD cv_grid->set_frontend_layoutEXPORTINGis_layout = gs_layout.CALL METHOD cv_grid->set_table_for_first_displayEXPORTINGis_layout       = gs_layoutCHANGINGit_outtab       = gt_HB3[]it_fieldcatalog = gt_fieldcat3[].WHEN OTHERS.ENDCASE.ENDIF.
ENDFORM.                    " FRM_SPLIT_CONT_SET" FRM_FORECAST_COLUMN_FORMAT
*&---------------------------------------------------------------------*
*&      Form  FRM_SEND_EMAIL
*&---------------------------------------------------------------------*
*       发邮件
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_send_email .DATA:ls_solix          TYPE solix,lc_xls_type       TYPE so_obj_tp VALUE 'XLS', "文件格式lr_sender         TYPE REF TO if_sender_bcs, "发送者对象lt_binary_content TYPE solix_tab,lv_mailto         TYPE ad_smtpadr,lt_binary         TYPE solix_tab,lv_sent_to_all    TYPE os_boolean,lt_main_text      TYPE bcsy_text,lr_send_req       TYPE REF TO cl_bcs,lr_document       TYPE REF TO cl_document_bcs,lr_recipient      TYPE REF TO if_recipient_bcs,lr_bcs_exception  TYPE REF TO cx_bcs.* - 获取发送的邮箱"二进制文件LOOP AT gt_xml_table_forecast INTO ls_solix-line.APPEND ls_solix TO lt_binary.CLEAR ls_solix.ENDLOOP.TRY ."创建发送请求lr_send_req = cl_bcs=>create_persistent( )."创建和设置带有附件的文档"从带有文本的内部表创建文档对象APPEND '邮件正文!' TO lt_main_text.lr_document = cl_document_bcs=>create_document(i_type = 'HTM'i_text = lt_main_texti_subject = '邮件标题' )."将电子表格作为附件添加到文档对象lr_document->add_attachment(i_attachment_type = lc_xls_typei_attachment_subject = '邮件附件名称'i_att_content_hex = lt_binary )."添加文档对象以发送请求lr_send_req->set_document( lr_document )."取得发送者lr_sender = cl_sapuser_bcs=>create( 'BASIS').lr_send_req->set_sender( lr_sender )."添加收件人(电子邮件地址)lv_mailto = '979621537@qq.com'. ""测试邮箱,需要修改为自己的邮箱,不要给博客作者发邮件"创建接收对象lr_recipient = cl_cam_address_bcs=>create_internet_address( lv_mailto )."添加接收对象以发送请求lr_send_req->add_recipient( lr_recipient )."立即发送CALL METHOD lr_send_req->set_send_immediately( 'X' ).lr_send_req->set_status_attributes( i_requested_status = 'E' i_status_mail = 'R' ).lv_sent_to_all = lr_send_req->send( i_with_error_screen = 'X' ).COMMIT WORK.IF lv_sent_to_all IS INITIAL.MESSAGE i500(sbcoms) WITH lv_mailto.ELSE.MESSAGE s022(so).ENDIF."异常处理CATCH cx_bcs INTO lr_bcs_exception.MESSAGE i865(so) WITH lr_bcs_exception->error_type.ENDTRY.
ENDFORM.                    " FRM_SEND_EMAIL*&---------------------------------------------------------------------*
*&      Form  FRM_PROCESS_XML_DATA
*&---------------------------------------------------------------------*
*       附件xml
*----------------------------------------------------------------------*
*      -->P_1      text
*----------------------------------------------------------------------*
FORM frm_process_xml_data.DATA: l_ixml          TYPE REF TO if_ixml,l_streamfactory TYPE REF TO if_ixml_stream_factory,l_ostream       TYPE REF TO if_ixml_ostream,l_renderer      TYPE REF TO if_ixml_renderer,l_document      TYPE REF TO if_ixml_document.DATA: l_element_root TYPE REF TO if_ixml_element,r_element      TYPE REF TO if_ixml_element,r_worksheet    TYPE REF TO if_ixml_element,r_table        TYPE REF TO if_ixml_element,r_column       TYPE REF TO if_ixml_element,r_row          TYPE REF TO if_ixml_element,r_cell         TYPE REF TO if_ixml_element,r_data         TYPE REF TO if_ixml_element,l_xml_size     TYPE i,lv_rc          TYPE i,l_value        TYPE string.*  create a ixml factoryl_ixml = cl_ixml=>create( ).*  create the DOM object modell_document = l_ixml->create_document( ).*  create workbookPERFORM create_workbook USING l_document r_worksheet r_table.*  column formattingPERFORM frm_forecast_column_format USING l_document r_table.* XML作为二进制数据流保存到内表
*   creating a stream factoryl_streamfactory = l_ixml->create_stream_factory( ).*   connect internal xml table to stream factoryl_ostream = l_streamfactory->create_ostream_itable( table = gt_xml_table_forecast ).*   rendering the documentl_renderer = l_ixml->create_renderer( ostream = l_ostream document = l_document ).lv_rc = l_renderer->render( ).* saving the xml documentl_xml_size = l_ostream->get_num_written_raw( ).
ENDFORM.             " FRM_PROCESS_XML_DATA" FRM_PROCESS_XML_DATA
*&---------------------------------------------------------------------*
*&      Form  CREATE_WORKBOOK
*&---------------------------------------------------------------------*
*       新建工作区
*----------------------------------------------------------------------*
*      -->P_L_DOCUMENT  text
*      -->P_R_WORKSHEET  text
*      -->P_R_TABLE  text
*----------------------------------------------------------------------*
FORM create_workbook USING l_document  TYPE REF TO if_ixml_documentr_worksheet TYPE REF TO if_ixml_elementr_table     TYPE REF TO if_ixml_element.DATA: l_element_root       TYPE REF TO if_ixml_element,lr_ns_attribute         TYPE REF TO if_ixml_attribute,lr_element_properties TYPE REF TO if_ixml_element,lr_styles             TYPE REF TO if_ixml_element,lr_style              TYPE REF TO if_ixml_element,lr_border             TYPE REF TO if_ixml_element,lr_format             TYPE REF TO if_ixml_element,l_value              TYPE string.*  create root node 'workbook'l_element_root = l_document->create_simple_element( name = 'Workbook' parent = l_document ).l_element_root->set_attribute( name = 'xmlns' value = 'urn:schemas-microsoft-com:office:spreadsheet' ).lr_ns_attribute = l_document->create_namespace_decl( name = 'ss' prefix = 'xmlns'  uri = 'urn:schemas-microsoft-com:office:spreadsheet' ).l_element_root->set_attribute_node( lr_ns_attribute ).lr_ns_attribute = l_document->create_namespace_decl( name = 'x'  prefix = 'xmlns'  uri = 'urn:schemas-microsoft-com:office:excel' ).l_element_root->set_attribute_node( lr_ns_attribute ).*  create node for document propertieslr_element_properties = l_document->create_simple_element( name = 'TEST_REPORT' parent = l_element_root ).l_value = sy-uname.l_document->create_simple_element( name = 'Author' value = l_value parent = lr_element_properties ).* Styles(类似css,可以被cell使用)lr_styles = l_document->create_simple_element( name = 'Styles' parent = l_element_root ).
* 预定义明细格式格式:Detaillr_style = l_document->create_simple_element( name = 'Style' parent = lr_styles ).lr_style->set_attribute_ns( name = 'ID'  prefix = 'ss' value = 'Detail' ).
"格式居中Lr_format = l_document->create_simple_element( name = 'Alignment' parent = lr_style ).Lr_format->set_attribute_ns( name = 'Horizontal' prefix = 'ss' value = 'Center' ).Lr_format->set_attribute_ns( name = 'Vertical' prefix = 'ss' value = 'Center' ).Lr_format->set_attribute_ns( name = 'WrapText'  prefix = 'ss'  value = '1' )."边框lr_border = l_document->create_simple_element( name = 'Borders' parent = lr_style ).lr_format = l_document->create_simple_element( name = 'Border' parent = lr_border ).lr_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Bottom' ).lr_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).lr_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '2' ).lr_format = l_document->create_simple_element( name = 'Border' parent = lr_border ).lr_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Left' ).lr_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).lr_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '2' ).lr_format = l_document->create_simple_element( name = 'Border' parent = lr_border ).lr_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Top' ).lr_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).lr_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '2' ).lr_format = l_document->create_simple_element( name = 'Border' parent = lr_border ).lr_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Right' ).lr_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).lr_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '2' ).
*  worksheetr_worksheet = l_document->create_simple_element( name = 'Worksheet' parent = l_element_root ).r_worksheet->set_attribute_ns( name = 'Name' prefix = 'ss' value = 'Sheet1' ).*  tabler_table = l_document->create_simple_element( name = 'Table' parent = r_worksheet ).r_table->set_attribute_ns( name = 'FullColumns' prefix = 'x' value = '1' ).r_table->set_attribute_ns( name = 'FullRows'    prefix = 'x' value = '1' ).
ENDFORM.                    " CREATE_WORKBOOK*&---------------------------------------------------------------------*
*&      Form  FRM_FORECAST_COLUMN_FORMAT
*&---------------------------------------------------------------------*
*       表头与格式设置
*----------------------------------------------------------------------*
*      -->P_L_DOCUMENT  text
*      -->P_R_TABLE  text
*----------------------------------------------------------------------*
FORM frm_forecast_column_format  USING    l_document TYPE REF TO if_ixml_documentr_table TYPE REF TO if_ixml_element.DATA: l_element_root TYPE REF TO if_ixml_element,lr_column       TYPE REF TO if_ixml_element,lr_row          TYPE REF TO if_ixml_element,lr_cell         TYPE REF TO if_ixml_element,r_format        TYPE REF TO if_ixml_element,lr_data         TYPE REF TO if_ixml_element,l_value        TYPE string.
*  设定列宽lr_column = l_document->create_simple_element( name = 'Column' parent = r_table ).lr_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '30' ).DO 15 TIMES.lr_column = l_document->create_simple_element( name = 'Column' parent = r_table ).lr_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '66' ).ENDDO.*  设定列名lr_row = l_document->create_simple_element( name = 'Row' parent = r_table  ).lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lr_cell->set_attribute_ns(  name = 'MergeAcross' prefix = 'ss' value = '14').lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = '责任部门与异常零件点数统计'  parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row->set_attribute_ns( name = 'AutoFitHeight' prefix = 'ss' value = '1' ).DATA lv_value TYPE string.
*  data table1LOOP AT gt_fieldcat1 INTO DATA(ls_fieldcat).lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lv_value =  ls_fieldcat-coltext.lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = lv_value  parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).ENDLOOP.LOOP AT gt_HB1 ASSIGNING FIELD-SYMBOL(<lfs_alv>).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).LOOP AT gt_fieldcat1 INTO ls_fieldcat.ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <lfs_alv> TO FIELD-SYMBOL(<lfs_value>).lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lv_value = <lfs_value>.lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = lv_value parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).ENDLOOP.ENDLOOP.lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row->set_attribute_ns( name = 'AutoFitHeight' prefix = 'ss' value = '1' ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table  ).lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lr_cell->set_attribute_ns(  name = 'MergeAcross' prefix = 'ss' value = '6').lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = '责任部门与延迟天数统计'  parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row->set_attribute_ns( name = 'AutoFitHeight' prefix = 'ss' value = '1' ).
*  data table1LOOP AT gt_fieldcat2 INTO ls_fieldcat.lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lv_value =  ls_fieldcat-coltext.lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = lv_value  parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).ENDLOOP.LOOP AT gt_HB2 ASSIGNING FIELD-SYMBOL(<lfs_alv2>) .lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).LOOP AT gt_fieldcat2 INTO ls_fieldcat.ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <lfs_alv2> TO <lfs_value>.lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lv_value = <lfs_value>.lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = lv_value parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).ENDLOOP.ENDLOOP.lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row->set_attribute_ns( name = 'AutoFitHeight' prefix = 'ss' value = '1' ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table  ).lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lr_cell->set_attribute_ns(  name = 'MergeAcross' prefix = 'ss' value = '15').lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = '责任部门与责任人异常零件点数统计TOP10'  parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).lr_row->set_attribute_ns( name = 'AutoFitHeight' prefix = 'ss' value = '1' ).
*  data table1LOOP AT gt_fieldcat3 INTO ls_fieldcat.lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lv_value =  ls_fieldcat-coltext.lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = lv_value  parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).ENDLOOP.LOOP AT gt_HB3 ASSIGNING FIELD-SYMBOL(<lfs_alv3>) .lr_row = l_document->create_simple_element( name = 'Row' parent = r_table ).LOOP AT gt_fieldcat3 INTO ls_fieldcat.ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <lfs_alv3> TO <lfs_value>.lr_cell = l_document->create_simple_element( name = 'Cell' parent = lr_row ).lv_value = <lfs_value>.lr_cell->set_attribute_ns(  name = 'StyleID' prefix = 'ss' value = 'Detail').lr_data = l_document->create_simple_element( name = 'Data' value = lv_value parent = lr_cell ).lr_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).ENDLOOP.ENDLOOP.ENDFORM.                    " FRM_FORECAST_COLUMN_FORMAT

分别双击红框中的代码创建屏幕,按钮,标题

双击 CALL SCREEN 9000.中的9000创建9000屏幕,

 屏幕画出表控件,命名为ALV,勾选垂直和水平,然后激活

 元素清单给OK_CODE

双击 CALL SCREEN 8000.中的8000创建8000屏幕,分屏展示的alv不用画屏幕

 双击 SET PF-STATUS '9000'.中的9000 创建按钮

 双击SET TITLEBAR '9000'.中的9000创建标题

 常驻CSDN有什么问题欢迎留言

  相关解决方案