ABAP—技术验证平台(屏幕类01)
前言:
该程序代码较为健硕,功能区域划分清晰,可根据需要添加自己需要的事件用于技术验证(取数逻辑请忽略)。
涵盖功能:
1、Docking
2、ALV_GRID
3、ALV_TREE
4、Drag and Drop
5、图片显示
6、程序中包含一个以纵深结构作为静态属性的类
代码:
*&---------------------------------------------------------------------*
*& Report ZFIR090T
*&---------------------------------------------------------------------*
*& Author : NathanSun
*& Create Date : 2018-08-31
*& Program Type : Report
*& Description : ***********
*&---------------------------------------------------------------------*
REPORT YN_FIR090T.
*&---------------------------------------------------------------------*
*& 包含 ZFIR090_TOP
*&---------------------------------------------------------------------*
TABLES:VBAK,VBAP,ACDOCA.
TYPE-POOLS:SLIS ,ICON .
"OOALV-DEFINITION
DATA GO_ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA GO_ALV_GRID_SUB TYPE REF TO CL_GUI_ALV_GRID.
DATA LO_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA OK_CODE TYPE SY-UCOMM.
DATA OK_SAVE TYPE SY-UCOMM.
* global fields
DATA: DRAGDROP_TREE TYPE REF TO CL_DRAGDROP,
DRAGDROP_ALV TYPE REF TO CL_DRAGDROP,
FLG_NEW,
GRID TYPE REF TO CL_GUI_ALV_GRID,
GS_LAYOUT_ALV TYPE LVC_S_LAYO,
GS_TOOLBAR TYPE STB_BUTTON,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_CONTAINER_OBJECT TYPE REF TO CL_GUI_DOCKING_CONTAINER,
G_DROPEFFECT TYPE I,
G_HANDLE_TREE TYPE I,
G_HANDLE_ALV TYPE I,
G_HIERARCHY_HEADER TYPE TREEV_HHDR,
G_REPID LIKE SY-REPID,
CONTROLS_CREATED1,
TREE1 TYPE REF TO CL_GUI_ALV_TREE,
IT_NODE_KEY TYPE LVC_T_NKEY .
TYPES pic_line(1022) TYPE x.
DATA pic_tab TYPE TABLE OF pic_line.
DATA l_alignment TYPE i.
FIELD-SYMBOLS:
"""" 如下参数定义为操作EXCEL所用
INCLUDE: OLE2INCL,
ZFIR090_EXCEL.
DATA: I_EXCEL_CONTROL TYPE REF TO EXCEL_CONTROL,
I_EXCEL_DESTINATION TYPE REF TO EXCEL_DESTINATION.
DATA: I_ROWS_TABLE TYPE ROWS_TAB.
DATA: BEGIN OF EXCEL_COLUMN OCCURS 0,
S_INDEX LIKE SY-TABIX,
S_ID TYPE C,
END OF EXCEL_COLUMN.
TYPES: BEGIN OF GTS_DATA,
KUNNR TYPE VBAK-KUNNR, "客户;
NAME1 TYPE KNA1-NAME1, "客户名称
MATNR TYPE ACDOCA-MATNR, "物料编码
ZUONR TYPE ACDOCA-ZUONR, "DN编号
ZUONR_F TYPE CHAR10, "DN编号前十位
ZUONR_B TYPE CHAR6, "DN编号后六位
WADAT_IST TYPE LIKP-WADAT_IST, "DN时间
MSL TYPE ACDOCA-MSL, "销售数量
WERKS TYPE ACDOCA-WERKS, "工厂
RUNIT TYPE ACDOCA-RUNIT, "单位
HSL TYPE ACDOCA-HSL, "发出商品金额
KDAUF TYPE ZDN_CREATE_HIS-KDAUF, "销售订单
KDPOS TYPE ZDN_CREATE_HIS-KDPOS, "销售订单项目
NETPR TYPE VBAP-NETPR, "净价
KPEIN TYPE VBAP-KPEIN, "定价单位
UMZIN TYPE VBAP-UMZIN, "转换因子
UMZIZ TYPE VBAP-UMZIZ, "转换因子
NETSR TYPE VBAP-NETPR, "销售收入
WAERK TYPE VBAP-WAERK, "凭证货币
KNUMV TYPE EKKO-KNUMV, "凭证条件号
EBELN TYPE EKPO-EBELN, "采购凭证
EBELP TYPE EKPO-EBELP, "行项目
UMREN TYPE EKPO-UMREN, "分母
UMREZ TYPE EKPO-UMREZ, "分子
S_NETPR TYPE VBAP-NETPR, "订单本币净价
EXCH_RATE TYPE BAPI1093_0, "汇率
RETURN TYPE BAPIRET1, "报错
VKORG TYPE TVKO-VKORG, "销售组织
VTWEG TYPE MVKE-VTWEG, "分销渠道
PRODH TYPE MVKE-PRODH, "产品层次
VTEXT1 TYPE T179T-VTEXT, "大类
VTEXT2 TYPE T179T-VTEXT, "中类
VTEXT3 TYPE T179T-VTEXT, "小类
ZXSML TYPE VBAP-NETPR, "毛利
ZHSLPS TYPE ACDOCA-HSL, "毛利率
ZXSMPS TYPE CHAR20, "毛利率
P_NODE TYPE LVC_NKEY , "层级
END OF GTS_DATA.
DATA: GT_DATA TYPE TABLE OF GTS_DATA WITH HEADER LINE.
DATA: GT_DATA_C TYPE TABLE OF GTS_DATA WITH HEADER LINE.
DATA: GT_DATA_D TYPE TABLE OF GTS_DATA WITH HEADER LINE.
DATA: GT_DATA_E TYPE TABLE OF GTS_DATA WITH HEADER LINE.
DATA: GT_DATA_F TYPE TABLE OF GTS_DATA WITH HEADER LINE.
CONSTANTS:P_RLDNR TYPE ACDOCA-RLDNR VALUE '0L'.
CONSTANTS:P_RRCTY TYPE ACDOCA-RRCTY VALUE 0 .
CONSTANTS:P_RACCT TYPE ACDOCA-RACCT VALUE '1406010100'.
CONSTANTS:P_AWTYP TYPE ACDOCA-AWTYP VALUE 'BKPFF'.
CONSTANTS:SELECTED VALUE 'X'.
DATA: CONTROLS_CREATED.
DATA: LV_WAERS TYPE T001-WAERS .
DATA OUT_01 TYPE CHAR30. "法人公司
DATA OUT_02 TYPE CHAR30. "截止至日期
DATA OUT_03 TYPE CHAR30. "编制人
DATA OUT_04 TYPE CHAR30. "币别
DATA OUT_05 TYPE CHAR16 VALUE '0'. "销售收入-期末金额
DATA OUT_06 TYPE CHAR16 VALUE '0'. "销售收入-1月内
DATA OUT_07 TYPE CHAR16 VALUE '0'. "销售收入-1~2月
DATA OUT_08 TYPE CHAR16 VALUE '0'. "销售收入-2~3月
DATA OUT_09 TYPE CHAR16 VALUE '0'. "销售收入-3~6月
DATA OUT_10 TYPE CHAR16 VALUE '0'. "销售收入-超过6个月
DATA OUT_11 TYPE CHAR16 VALUE '0'. "发出商品金额-期末金额
DATA OUT_12 TYPE CHAR16 VALUE '0'. "发出商品金额-1月内
DATA OUT_13 TYPE CHAR16 VALUE '0'. "发出商品金额-1~2月
DATA OUT_14 TYPE CHAR16 VALUE '0'. "发出商品金额-2~3月
DATA OUT_15 TYPE CHAR16 VALUE '0'. "发出商品金额-3~6月
DATA OUT_16 TYPE CHAR16 VALUE '0'. "发出商品金额-超过6个月
DATA OUT_17 TYPE CHAR16 VALUE '0'. "销售数量-合计
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: P_RBUKRS LIKE ACDOCA-RBUKRS MODIF ID M1 OBLIGATORY . "公司代码
PARAMETERS: P_GJAHR LIKE ACDOCA-GJAHR MODIF ID M1 OBLIGATORY . "年度
PARAMETERS: P_BUDAT LIKE ACDOCA-BUDAT MODIF ID M1 OBLIGATORY . "截止日期
SELECTION-SCREEN END OF BLOCK B1.
*
*SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE TEXT-003.
*PARAMETERS: p_chong AS CHECKBOX USER-COMMAND mx MODIF ID mb.
*SELECTION-SCREEN END OF BLOCK b3.
*&---------------------------------------------------------------------*
*& 包含 ZFIR090_CLASS
*&---------------------------------------------------------------------*
CLASS DEMO DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
MAIN,
CLASS_CONSTRUCTOR.
PRIVATE SECTION.
CLASS-DATA:
BEGIN OF STRUCT1,
A1 TYPE STRING VALUE `a1_XX`,
A2 TYPE STRING VALUE `a2_XX`,
BEGIN OF ISTRUCT,
A1 TYPE STRING VALUE `a1_YY`,
A2 TYPE STRING VALUE `a2_YY`,
END OF ISTRUCT,
ITAB LIKE STANDARD TABLE OF STRUCT1-ISTRUCT WITH EMPTY KEY,
END OF STRUCT1.
ENDCLASS.
CLASS DEMO IMPLEMENTATION.
METHOD MAIN.
DATA(OUT) = CL_DEMO_OUTPUT=>NEW( ).
OUT->BEGIN_SECTION( `纵深结构的内表展示`
)->WRITE( STRUCT1-ISTRUCT
)->WRITE( STRUCT1-ITAB ).
OUT->DISPLAY( ).
ENDMETHOD.
METHOD CLASS_CONSTRUCTOR.
STRUCT1-ITAB = VALUE #(
( A1 = `a1_xx` A2 = `a2_xx` )
( A1 = `a1_yy` A2 = `a2_yy` ) ).
ENDMETHOD.
ENDCLASS.
*----------------------------------------------------------------------*
* CLASS cl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS CL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
" 声明单击事件的方法
METHODS HANDLE_HOTSPOT_CLICK
FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID.
" 声明双击事件方法
METHODS HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
" 声明TOOLBAR事件方法
METHODS HANDLE_TOOLBAR
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE.
" 声明USER-COMMAND 事件方法
METHODS HANDLE_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.
"Drag
METHODS HANDLE_ONDRAG
FOR EVENT ONDRAG OF CL_GUI_ALV_GRID
IMPORTING E_ROW
E_COLUMN
ES_ROW_NO
E_DRAGDROPOBJ.
"Drop
METHODS HANDLE_ONDROP
FOR EVENT ONDROP OF CL_GUI_ALV_GRID
IMPORTING E_ROW
E_COLUMN
E_DRAGDROPOBJ.
PRIVATE SECTION.
ENDCLASS. "CL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS CL_EVENT_RECEIVER IMPLEMENTATION.
" 单击事件方法的实现
METHOD HANDLE_HOTSPOT_CLICK.
ENDMETHOD. "HANDLE_HOTSPOT_CLICK
" 双击事件方法的实现
METHOD HANDLE_DOUBLE_CLICK.
CLEAR GT_DATA_C .
READ TABLE GT_DATA_C[] INDEX E_ROW-INDEX INTO GT_DATA_C .
CLEAR GT_DATA_D[] .
LOOP AT GT_DATA INTO GT_DATA WHERE PRODH = GT_DATA_C-PRODH.
APPEND GT_DATA TO GT_DATA_D[] .
CLEAR GT_DATA .
ENDLOOP.
GO_ALV_GRID_SUB->REFRESH_TABLE_DISPLAY( ).
ENDMETHOD. "HANDLE_DOUBLE_CLICK
" 实现TOOLBAR事件方法
METHOD HANDLE_TOOLBAR.
DATA: LS_TOOLBAR TYPE STB_BUTTON.
DELETE E_OBJECT->MT_TOOLBAR WHERE FUNCTION = '&PRINT_BACK'.
CLEAR: LS_TOOLBAR.
LS_TOOLBAR-BUTN_TYPE = 3. " 分隔符
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR: LS_TOOLBAR.
LS_TOOLBAR-FUNCTION = 'BT_8'. "功能码
LS_TOOLBAR-ICON = ICON_INFORMATION. " 图标名称
LS_TOOLBAR-TEXT = '显示信息'. " 按钮上显示的文本
LS_TOOLBAR-QUICKINFO = '显示信息'. " 图标的提示信息
LS_TOOLBAR-BUTN_TYPE = 0. " 0表示正常按钮
LS_TOOLBAR-DISABLED = ''. " X表示灰色,不可用
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "HANDLE_TOOLBAR
" 实现USER-COMMAND 事件方法
METHOD HANDLE_COMMAND.
* DATA: REF TYPE REF TO CL_GUI_ALV_GRID.
* DATA : LV_STABLE TYPE LVC_S_STBL. "刷新稳定性
** RANGES: L_WERKS FOR T001W-WERKS.
** RANGES: L_MATNR FOR MARA-MATNR.
* DATA:L_BUKRS TYPE T001K-BUKRS.
*
* LV_STABLE-ROW = '1'.
* LV_STABLE-COL = '1'.
*
* CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* IMPORTING
* E_GRID = REF.
* CALL METHOD REF->CHECK_CHANGED_DATA.
CASE E_UCOMM.
WHEN 'BT_8'.
DEMO=>MAIN( ).
* SORT gt_data[] BY bedat.
* CALL METHOD go_alv_grid->refresh_table_display "内表改变时刷新ALV
* EXPORTING
* is_stable = lv_stable.
WHEN OTHERS.
ENDCASE.
* CALL METHOD REF->REFRESH_TABLE_DISPLAY
* EXPORTING
* IS_STABLE = LV_STABLE.
ENDMETHOD. "HANDLE_COMMAND
" 实现DATA_CHANGED 事件方法
METHOD HANDLE_DATA_CHANGED.
ENDMETHOD. "handle_data_changed
* Drag & Drop
METHOD HANDLE_ONDRAG.
CHECK NOT E_ROW IS INITIAL.
* PERFORM DISPLAY_FLIGHTS USING NODE_KEY.
* CALL METHOD CL_GUI_CFW=>SET_NEW_OK_CODE EXPORTING NEW_CODE =
* FCODE_ENTR.
ENDMETHOD.
* Drag & Drop
METHOD HANDLE_ONDROP.
CHECK NOT E_ROW IS INITIAL.
*
ENDMETHOD.
ENDCLASS. "cl_event_receiver IMPLEMENTATION
***INCLUDE BCALV_EVENT_REC_DRAGDROP.
CLASS CL_TREE_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
DATA: UCOMM TYPE SY-UCOMM.
DATA: SELFIELD TYPE SLIS_SELFIELD.
* toolbar
METHODS HANDLE_TOOLBAR_SET
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE.
* user command
METHODS HANDLE_USER_COMMAND
FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM.
* double click
METHODS HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
* context menue
METHODS HANDLE_CONTEXT_MENU
FOR EVENT CONTEXT_MENU_REQUEST OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT.
METHODS HANDLE_ONDROP
FOR EVENT ONDROP OF CL_GUI_ALV_GRID
IMPORTING E_ROW
E_COLUMN
E_DRAGDROPOBJ.
PRIVATE SECTION.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS CL_EVENT_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS CL_TREE_EVENT_RECEIVER IMPLEMENTATION.
* handle user_command
METHOD HANDLE_USER_COMMAND.
* CASE E_UCOMM.
* WHEN FCODE_DISP.
* PERFORM DISPLAY_DETAIL.
* WHEN FCODE_PLANE.
* PERFORM DISPLAY_SAPLANE.
* WHEN OTHERS.
* ENDCASE.
ENDMETHOD.
* handle double_click
METHOD HANDLE_DOUBLE_CLICK.
* PERFORM DISPLAY_SAPLANE.
ENDMETHOD.
* handle toolbar
METHOD HANDLE_TOOLBAR_SET.
** create own Menubuttons and ToolbarButtons
** append a separator to normal toolbar
* CLEAR GS_TOOLBAR.
* MOVE 3 TO GS_TOOLBAR-BUTN_TYPE.
* APPEND GS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
** append detail button
* CLEAR GS_TOOLBAR.
* MOVE FCODE_DISP TO GS_TOOLBAR-FUNCTION.
* MOVE ICON_DETAIL TO GS_TOOLBAR-ICON.
* MOVE TEXT-005 TO GS_TOOLBAR-QUICKINFO.
* MOVE ' ' TO GS_TOOLBAR-DISABLED.
* APPEND GS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
** append a separator to normal toolbar
* CLEAR GS_TOOLBAR.
* MOVE 3 TO GS_TOOLBAR-BUTN_TYPE.
* APPEND GS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
** append new button
* CLEAR GS_TOOLBAR.
* MOVE FCODE_PLANE TO GS_TOOLBAR-FUNCTION.
* MOVE ICON_WS_PLANE TO GS_TOOLBAR-ICON.
* MOVE TEXT-002 TO GS_TOOLBAR-QUICKINFO.
* MOVE ' ' TO GS_TOOLBAR-DISABLED.
* APPEND GS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD.
* context menue
METHOD HANDLE_CONTEXT_MENU.
* CALL METHOD E_OBJECT->ADD_FUNCTION
* EXPORTING
* FCODE = FCODE_DISP
* TEXT = TEXT-005.
* CALL METHOD E_OBJECT->ADD_FUNCTION
* EXPORTING
* FCODE = FCODE_PLANE
* TEXT = TEXT-002.
ENDMETHOD.
* Drag & Drop
METHOD HANDLE_ONDROP.
*
ENDMETHOD.
ENDCLASS.
*
DATA: EVENT_RECEIVER TYPE REF TO CL_TREE_EVENT_RECEIVER.
*----------------------------------------------------------------------*
* CLASS CL_TREE_EVENT_RECEIVER IMPLEMENTATION *
*----------------------------------------------------------------------*
CLASS CL_TREE_EVENT_RECEIVER_DRAG DEFINITION.
PUBLIC SECTION.
* double click item
METHODS HANDLE_DOUBLE_CLICK
FOR EVENT NODE_DOUBLE_CLICK OF CL_GUI_ALV_TREE
IMPORTING NODE_KEY.
* Drag
METHODS HANDLE_ON_DRAG
FOR EVENT ON_DRAG OF CL_GUI_ALV_TREE
IMPORTING DRAG_DROP_OBJECT
FIELDNAME
NODE_KEY.
PRIVATE SECTION.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS CL_TREE_EVENT_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS CL_TREE_EVENT_RECEIVER_DRAG IMPLEMENTATION.
* handle double_click
METHOD HANDLE_DOUBLE_CLICK.
CHECK NOT NODE_KEY IS INITIAL.
PERFORM DISPLAY_FLIGHTS USING NODE_KEY.
ENDMETHOD.
* Drag & Drop
METHOD HANDLE_ON_DRAG.
CHECK NOT NODE_KEY IS INITIAL.
PERFORM DISPLAY_FLIGHTS USING NODE_KEY.
* CALL METHOD CL_GUI_CFW=>SET_NEW_OK_CODE EXPORTING NEW_CODE =
* FCODE_ENTR.
ENDMETHOD.
ENDCLASS.
*
DATA: TREE_EVENT_RECEIVER TYPE REF TO CL_TREE_EVENT_RECEIVER_DRAG.
*&---------------------------------------------------------------------*
*& Form DISPLAY_FLIGHTS
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_NODE_KEY text
*&---------------------------------------------------------------------*
FORM DISPLAY_FLIGHTS USING P_NODE_KEY TYPE LVC_NKEY.
DATA: GRID_TITLE TYPE LVC_TITLE.
DATA: LS_DATA TYPE GTS_DATA,
E_PARENT_NODE_KEY TYPE LVC_NKEY,
LT_CHILDREN TYPE LVC_T_NKEY WITH HEADER LINE,
LT_CHILDREN1 TYPE LVC_T_NKEY WITH HEADER LINE.
REFRESH GT_DATA_D .
CALL METHOD TREE1->GET_OUTTAB_LINE
EXPORTING I_NODE_KEY = P_NODE_KEY
IMPORTING E_OUTTAB_LINE = LS_DATA.
CLEAR GT_DATA_F[] .
CASE LS_DATA-P_NODE.
WHEN 'L'.
GRID_TITLE = '大类:'&& LS_DATA-VTEXT1 && ' 明细数据'.
CLEAR LT_CHILDREN[].
CALL METHOD TREE1->GET_CHILDREN
EXPORTING I_NODE_KEY = P_NODE_KEY
IMPORTING ET_CHILDREN = LT_CHILDREN[].
CHECK NOT LT_CHILDREN[] IS INITIAL.
LOOP AT LT_CHILDREN.
CLEAR LT_CHILDREN1[].
CALL METHOD TREE1->GET_CHILDREN
EXPORTING I_NODE_KEY = LT_CHILDREN
IMPORTING ET_CHILDREN = LT_CHILDREN1[].
LOOP AT LT_CHILDREN1.
CALL METHOD TREE1->GET_OUTTAB_LINE
EXPORTING I_NODE_KEY = LT_CHILDREN1
IMPORTING E_OUTTAB_LINE = GT_DATA_F.
APPEND GT_DATA_F .
CLEAR GT_DATA_F .
ENDLOOP.
ENDLOOP.
WHEN 'M'.
GRID_TITLE = '中类:'&& LS_DATA-VTEXT2 && ' 明细数据'.
CLEAR LT_CHILDREN1[].
CALL METHOD TREE1->GET_CHILDREN
EXPORTING I_NODE_KEY = P_NODE_KEY
IMPORTING ET_CHILDREN = LT_CHILDREN1[].
LOOP AT LT_CHILDREN1.
CALL METHOD TREE1->GET_OUTTAB_LINE
EXPORTING I_NODE_KEY = LT_CHILDREN1
IMPORTING E_OUTTAB_LINE = GT_DATA_F.
APPEND GT_DATA_F .
CLEAR GT_DATA_F .
ENDLOOP.
WHEN 'S'.
GRID_TITLE = '小类:'&& LS_DATA-VTEXT3 && ' 明细数据'.
CALL METHOD TREE1->GET_OUTTAB_LINE
EXPORTING I_NODE_KEY = P_NODE_KEY
IMPORTING E_OUTTAB_LINE = GT_DATA_F.
APPEND GT_DATA_F .
WHEN OTHERS.
ENDCASE.
IF GT_DATA_F[] IS INITIAL. "AND NOT GRID IS INITIAL.
MESSAGE I000(0K) WITH TEXT-115 SPACE SPACE SPACE.
ELSE.
CLEAR GT_DATA_D[] .
LOOP AT GT_DATA_F.
LOOP AT GT_DATA INTO GT_DATA WHERE PRODH = GT_DATA_F-PRODH.
APPEND GT_DATA TO GT_DATA_D[] .
CLEAR GT_DATA .
ENDLOOP.
CLEAR GT_DATA_F .
ENDLOOP.
* GO_ALV_GRID_SUB->REFRESH_TABLE_DISPLAY( ).
DATA : LV_STABLE TYPE LVC_S_STBL. "刷新稳定性
LV_STABLE-ROW = '1'.
LV_STABLE-COL = '1'.
GS_LAYOUT_ALV-GRID_TITLE = GRID_TITLE."标题栏文本
GS_LAYOUT_ALV-SEL_MODE = 'D'. "选择方式
GS_LAYOUT_ALV-CWIDTH_OPT = 'X'. "优化列宽
* handle for D'n'D
GS_LAYOUT_ALV-S_DRAGDROP-ROW_DDID = G_HANDLE_ALV.
CALL METHOD GO_ALV_GRID_SUB->SET_FRONTEND_LAYOUT
EXPORTING
IS_LAYOUT = GS_LAYOUT_ALV.
CALL METHOD GO_ALV_GRID_SUB->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LV_STABLE.
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = GO_ALV_GRID_SUB.
CALL METHOD CL_GUI_CFW=>FLUSH.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* CLASS c_service DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS C_SERVICE DEFINITION.
PUBLIC SECTION.
CLASS-METHODS GET_PIC_TAB IMPORTING MIME_URL TYPE CSEQUENCE
EXPORTING PIC_TAB TYPE STANDARD TABLE.
ENDCLASS. "c_service DEFINITION
CLASS C_SERVICE IMPLEMENTATION.
METHOD GET_PIC_TAB.
DATA PIC_WA TYPE XSTRING.
DATA LENGTH TYPE I.
DATA MIME_API TYPE REF TO IF_MR_API.
MIME_API = CL_MIME_REPOSITORY_API=>GET_API( ).
MIME_API->GET( EXPORTING I_URL = MIME_URL
IMPORTING E_CONTENT = PIC_WA
EXCEPTIONS OTHERS = 4 ).
IF SY-SUBRC = 4.
RETURN.
ENDIF.
CLEAR PIC_TAB.
LENGTH = XSTRLEN( PIC_WA ).
WHILE LENGTH >= 1022.
APPEND PIC_WA(1022) TO PIC_TAB.
SHIFT PIC_WA BY 1022 PLACES LEFT IN BYTE MODE.
LENGTH = XSTRLEN( PIC_WA ).
ENDWHILE.
IF LENGTH > 0.
APPEND PIC_WA TO PIC_TAB.
ENDIF.
ENDMETHOD. "get_pic_tab
ENDCLASS. "c_service IMPLEMENTATION
* PICTURE_CONTROL
DATA: CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
CONTAINER2 LIKE CONTAINER1,
PICT1 TYPE REF TO CL_GUI_PICTURE,
PICT2 LIKE PICT1,
EVT_TAB TYPE CNTL_SIMPLE_EVENTS,
EVT_TAB_LINE LIKE LINE OF EVT_TAB,
URL(256) TYPE C.
*&---------------------------------------------------------------------*
*& 包含 ZFIR090_FOM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_MONTH_LASTDAY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM GET_MONTH_LASTDAY .
*取上个月最后一天
P_BUDAT = SY-DATUM(6) && '01'.
P_BUDAT = P_BUDAT - 1 .
*取本月最后一天
* CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
* EXPORTING
* i_date = sy-datum
* IMPORTING
* e_date = p_budat
* .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SCREEN_SETTING
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM SCREEN_SETTING .
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD P_RBUKRS .
IF SY-SUBRC <> 0.
MESSAGE '您没有公司:'&& P_RBUKRS && ' 的权限!' TYPE 'E' .
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FOM_GETDATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FOM_GETDATA .
SELECT SINGLE WAERS INTO LV_WAERS FROM T001
WHERE BUKRS = P_RBUKRS .
DATA GV_ZDN_CREATE_HIS TYPE ZDN_CREATE_HIS .
DATA GV_ZUONR TYPE ACDOCA-ZUONR .
CLEAR GT_DATA[] .
IF P_RBUKRS = '1010' OR P_RBUKRS = '2010' OR P_RBUKRS = '4010'.
SELECT
ACDOCA~HSL
ACDOCA~MATNR
ACDOCA~WERKS
ACDOCA~ZUONR
ACDOCA~MSL
ACDOCA~RUNIT
ACDOCA~ZUONR
INTO CORRESPONDING FIELDS OF TABLE GT_DATA[]
FROM ACDOCA
WHERE ACDOCA~RBUKRS = P_RBUKRS
AND ACDOCA~GJAHR = P_GJAHR
AND ACDOCA~BUDAT = P_BUDAT
AND ACDOCA~RLDNR = P_RLDNR
AND ACDOCA~RRCTY = P_RRCTY
AND ACDOCA~RACCT = P_RACCT
AND ACDOCA~AWTYP = P_AWTYP
.
LOOP AT GT_DATA.
*分配(ACDOCA-ZUONR)的前十位为DN编号,第十一位开始取6为DN项目;
GT_DATA-ZUONR_F = GT_DATA-ZUONR(10) .
GT_DATA-ZUONR_B = GT_DATA-ZUONR+11(6) .
*DN编号是85开头的则对销售数量(ACDOCA-MSL)取负数
* IF GT_DATA-ZUONR_F(2) = 85 .
* GT_DATA-MSL = GT_DATA-MSL * -1 .
* ENDIF.
SELECT SINGLE WADAT_IST INTO GT_DATA-WADAT_IST FROM LIKP
WHERE VBELN = GT_DATA-ZUONR_F .
*如果DN时间(LIKP-WADAT_IST)取不到值,根据MSEG-VBELN_IM = DN编号、MSEG-VBELP_IM、MSEG-SMBLN = 空,取过账日期(MSEG-BUDAT_MKPF),如果有多条取过账日期较大的作为DN时间(LIKP-WADAT_IST)。
IF GT_DATA-WADAT_IST IS INITIAL.
SELECT SINGLE MAX( BUDAT_MKPF ) INTO GT_DATA-WADAT_IST FROM MSEG
WHERE VBELN_IM = GT_DATA-ZUONR_F
AND VBELP_IM = GT_DATA-ZUONR_B
AND SMBLN = ''
.
ENDIF.
*根据ZDN_CREATE_HIS-VBELN = DN编号、ZDN_CREATE_HIS-POSNR = DN项目、ZDN_CREATE_HIS-WERKS =工厂; 取销售订单(ZDN_CREATE_HIS-KDAUF)、项目(ZDN_CREATE_HIS-KDPOS),
SELECT SINGLE KDAUF KDPOS INTO ( GT_DATA-KDAUF ,GT_DATA-KDPOS ) FROM ZDN_CREATE_HIS
WHERE VBELN = GT_DATA-ZUONR_F
AND POSNR = GT_DATA-ZUONR_B
AND WERKS = GT_DATA-WERKS
.
*如果不能取到值(指在表中不存在条目或在表中有条目但销售订单为空)则再根据 LIPS-VBELN = DN编号、LIPS-POSNR = DN项目,取销售订单(LIPS-VGBEL)及项目(LIPS-VGPOS);
IF GT_DATA-KDAUF IS INITIAL OR GT_DATA-KDPOS IS INITIAL.
SELECT SINGLE VGBEL VGPOS INTO ( GT_DATA-KDAUF ,GT_DATA-KDPOS ) FROM LIPS
WHERE VBELN = GT_DATA-ZUONR_F
AND POSNR = GT_DATA-ZUONR_B
.
ENDIF.
SELECT SINGLE
VBAK~KUNNR
VBAP~NETPR
VBAP~KPEIN
VBAP~UMZIN
VBAP~UMZIZ
VBAP~WAERK
INTO CORRESPONDING FIELDS OF GT_DATA
FROM VBAP
INNER JOIN VBAK ON VBAP~VBELN = VBAK~VBELN
WHERE VBAP~VBELN = GT_DATA-KDAUF
AND VBAP~POSNR = GT_DATA-KDPOS
.
IF GT_DATA-KUNNR IS INITIAL.
SELECT SINGLE KUNNR INTO GT_DATA-KUNNR FROM EKPV
WHERE EBELN = GT_DATA-KDAUF
AND EBELP = GT_DATA-KDPOS
.
ENDIF.
*如果未取到vbap的货币数据则根据结合表EKKO、EKPO,EKPO-EBELN =销售订单、EKPO-EBELP = 项目,取凭证货币(EKKO-WAERS)、凭证条件号(EKPO-KNUMV)、
*采购凭证(EKPO-EBELN)、行项目(EKPO-EBELP)、净价(EKPO-NETPR)、定价单位(EKPO-PEINH)、分母(EKPO-UMREN)、分子(EKPO-UMREZ);
IF GT_DATA-WAERK IS INITIAL.
SELECT SINGLE
EKKO~WAERS AS WAERK "货币
EKKO~KNUMV "凭证条件号
EKPO~EBELN "采购凭证
EKPO~EBELP "行项目
EKPO~NETPR "净价
EKPO~PEINH AS KPEIN "定价单位
EKPO~UMREN AS UMZIN "分母
EKPO~UMREZ AS UMZIZ "分子
INTO CORRESPONDING FIELDS OF GT_DATA
FROM EKKO
INNER JOIN EKPO ON EKKO~EBELN = EKPO~EBELN
WHERE EKPO~EBELN = GT_DATA-KDAUF
AND EKPO~EBELP = GT_DATA-KDPOS
.
ENDIF.
*取汇率
IF GT_DATA-WAERK = LV_WAERS.
GT_DATA-S_NETPR = GT_DATA-NETPR .
ELSE.
CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
EXPORTING
RATE_TYPE = 'M'
FROM_CURR = GT_DATA-WAERK
TO_CURRNCY = LV_WAERS
DATE = P_BUDAT
IMPORTING
EXCH_RATE = GT_DATA-EXCH_RATE "exch_rate 为纵深结构
RETURN = GT_DATA-RETURN
.
GT_DATA-S_NETPR = GT_DATA-NETPR * GT_DATA-EXCH_RATE-EXCH_RATE .
ENDIF.
*销售收入 = 订单本币净价(VBAP-NETPR) 除以 定价单位(VBAP-KPEIN) 乘以 转换因子(VBAP-UMZIN) 除以 转换因子(VBAP-UMZIZ) 乘以 销售数量(ACDOCA-MSL)
IF GT_DATA-KPEIN <> 0 AND GT_DATA-UMZIZ <> 0.
GT_DATA-NETSR = GT_DATA-S_NETPR / GT_DATA-KPEIN * GT_DATA-UMZIN / GT_DATA-UMZIZ * GT_DATA-MSL .
ENDIF.
SELECT SINGLE NAME1 INTO GT_DATA-NAME1 FROM KNA1
WHERE KUNNR = GT_DATA-KUNNR
* AND spras = 1
.
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
ELSEIF P_RBUKRS = '1000'.
SELECT
ACDOCA~HSL
ACDOCA~MATNR
ACDOCA~WERKS
ACDOCA~ZUONR
ACDOCA~MSL
ACDOCA~RUNIT
ACDOCA~ZUONR
INTO CORRESPONDING FIELDS OF TABLE GT_DATA[]
FROM ACDOCA
WHERE ACDOCA~RBUKRS = P_RBUKRS
AND ACDOCA~GJAHR = P_GJAHR
AND ACDOCA~BUDAT = P_BUDAT
AND ACDOCA~RLDNR = P_RLDNR
AND ACDOCA~RRCTY = P_RRCTY
AND ACDOCA~RACCT = P_RACCT
AND ACDOCA~AWTYP = P_AWTYP
.
LOOP AT GT_DATA.
GT_DATA-ZUONR_F = GT_DATA-ZUONR(10) .
GT_DATA-ZUONR_B = GT_DATA-ZUONR+11(6) .
*DN编号是85开头的则对销售数量(ACDOCA-MSL)取负数
* IF GT_DATA-ZUONR_F(2) = 85.
* GT_DATA-MSL = GT_DATA-MSL * -1 .
* ENDIF.
SELECT SINGLE WADAT_IST INTO GT_DATA-WADAT_IST FROM LIKP
WHERE VBELN = GT_DATA-ZUONR_F .
*如果DN时间(LIKP-WADAT_IST)取不到值,根据MSEG-VBELN_IM = DN编号、MSEG-VBELP_IM、MSEG-SMBLN = 空,取过账日期(MSEG-BUDAT_MKPF),如果有多条取过账日期较大的作为DN时间(LIKP-WADAT_IST)。
IF GT_DATA-WADAT_IST IS INITIAL.
SELECT SINGLE MAX( BUDAT_MKPF ) INTO GT_DATA-WADAT_IST FROM MSEG
WHERE VBELN_IM = GT_DATA-ZUONR_F
AND VBELP_IM = GT_DATA-ZUONR_B
AND SMBLN = ''
.
ENDIF.
*取销售订单、行项目:LIPS-VBELN = DN编号、LIPS-POSNR = DN项目,取销售订单(LIPS-VGBEL)及项目(LIPS-VGPOS);
SELECT SINGLE VGBEL VGPOS INTO ( GT_DATA-KDAUF ,GT_DATA-KDPOS ) FROM LIPS
WHERE VBELN = GT_DATA-ZUONR_F
AND POSNR = GT_DATA-ZUONR_B
.
SELECT SINGLE
VBAK~KUNNR
VBAP~NETPR
VBAP~KPEIN
VBAP~UMZIN
VBAP~UMZIZ
VBAP~WAERK
INTO CORRESPONDING FIELDS OF GT_DATA
FROM VBAP
INNER JOIN VBAK ON VBAP~VBELN = VBAK~VBELN
WHERE VBAP~VBELN = GT_DATA-KDAUF
AND VBAP~POSNR = GT_DATA-KDPOS
.
IF GT_DATA-KUNNR IS INITIAL.
SELECT SINGLE KUNNR INTO GT_DATA-KUNNR FROM EKPV
WHERE EBELN = GT_DATA-KDAUF
AND EBELP = GT_DATA-KDPOS
.
ENDIF.
*如果未取到vbap的货币数据则根据结合表EKKO、EKPO,EKPO-EBELN =销售订单、EKPO-EBELP = 项目,取凭证货币(EKKO-WAERS)、凭证条件号(EKPO-KNUMV)、
*采购凭证(EKPO-EBELN)、行项目(EKPO-EBELP)、净价(EKPO-NETPR)、定价单位(EKPO-PEINH)、分母(EKPO-UMREN)、分子(EKPO-UMREZ);
IF GT_DATA-WAERK IS INITIAL.
SELECT SINGLE
EKKO~WAERS "货币
EKKO~KNUMV "凭证条件号
EKPO~EBELN "采购凭证
EKPO~EBELP "行项目
EKPO~NETPR "净价
EKPO~PEINH "定价单位
EKPO~UMREN "分母
EKPO~UMREZ "分子
INTO CORRESPONDING FIELDS OF GT_DATA
FROM EKKO
INNER JOIN EKPO ON EKKO~EBELN = EKPO~EBELN
WHERE EKPO~EBELN = GT_DATA-KDAUF
AND EKPO~EBELP = GT_DATA-KDPOS
.
ENDIF.
*取汇率
IF GT_DATA-WAERK = LV_WAERS.
GT_DATA-S_NETPR = GT_DATA-NETPR .
ELSE.
CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
EXPORTING
RATE_TYPE = 'M'
FROM_CURR = GT_DATA-WAERK
TO_CURRNCY = LV_WAERS
DATE = P_BUDAT
IMPORTING
EXCH_RATE = GT_DATA-EXCH_RATE "exch_rate 为纵深结构
RETURN = GT_DATA-RETURN
.
GT_DATA-S_NETPR = GT_DATA-NETPR * GT_DATA-EXCH_RATE-EXCH_RATE .
ENDIF.
*销售收入 等于 订单本币净价(VBAP-NETPR) 除以 定价单位(VBAP-KPEIN) 乘以 转换因子(VBAP-UMZIN) 除以 转换因子(VBAP-UMZIZ) 乘以 销售数量(ACDOCA-MSL)
IF GT_DATA-KPEIN <> 0 AND GT_DATA-UMZIZ <> 0.
GT_DATA-NETSR = GT_DATA-S_NETPR / GT_DATA-KPEIN * GT_DATA-UMZIN / GT_DATA-UMZIZ * GT_DATA-MSL .
ENDIF.
SELECT SINGLE NAME1 INTO GT_DATA-NAME1 FROM KNA1
WHERE KUNNR = GT_DATA-KUNNR
* AND spras = 1
.
*取交货工厂的发出商品金额、DN时间:根据ZDN_CREATE_HIS-KDAUF =销售订单(LIPS-VGBEL)、ZDN_CREATE_HIS-KDPOS = 项目(LIPS-VGPOS);取公司代码(ZDN_CREATE_HIS-BUKRS)、交货(ZDN_CREATE_HIS-VBELN)、项 目(ZDN_CREATE_HIS-POSNR),
CLEAR GV_ZDN_CREATE_HIS .
SELECT SINGLE BUKRS VBELN POSNR INTO CORRESPONDING FIELDS OF GV_ZDN_CREATE_HIS FROM ZDN_CREATE_HIS
WHERE KDAUF = GT_DATA-KDAUF
AND KDPOS = GT_DATA-KDPOS
.
*如果取不到交货、项目的值,则发出商品金额用原来的ACDOCA-HSL、DN时间用原来的LIKP-WADAT_IST
IF GV_ZDN_CREATE_HIS-VBELN IS NOT INITIAL AND GV_ZDN_CREATE_HIS-POSNR IS NOT INITIAL.
CLEAR GV_ZUONR .
GV_ZUONR = GV_ZDN_CREATE_HIS-VBELN && GV_ZDN_CREATE_HIS-POSNR .
SELECT SINGLE
ACDOCA~HSL
INTO GT_DATA-HSL
FROM ACDOCA
WHERE ACDOCA~RBUKRS = P_RBUKRS
AND ACDOCA~GJAHR = P_GJAHR
AND ACDOCA~BUDAT = P_BUDAT
AND ACDOCA~RLDNR = P_RLDNR
AND ACDOCA~RRCTY = P_RRCTY
AND ACDOCA~RACCT = P_RACCT
AND ACDOCA~AWTYP = P_AWTYP
AND ACDOCA~ZUONR = GV_ZUONR
.
*根据交货(ZDN_CREATE_HIS-VBELN)取表LIKP的DN时间(LIKP-WADAT_IST)。
SELECT SINGLE WADAT_IST INTO GT_DATA-WADAT_IST FROM LIKP
WHERE VBELN = GV_ZDN_CREATE_HIS-VBELN .
*如果DN时间(LIKP-WADAT_IST)取不到值,根据MSEG-VBELN_IM = DN编号、MSEG-VBELP_IM、MSEG-SMBLN = 空,取过账日期(MSEG-BUDAT_MKPF),如果有多条取过账日期较大的作为DN时间(LIKP-WADAT_IST)。
IF GT_DATA-WADAT_IST IS INITIAL.
SELECT SINGLE MAX( BUDAT_MKPF ) INTO GT_DATA-WADAT_IST FROM MSEG
WHERE VBELN_IM = GV_ZDN_CREATE_HIS-VBELN
AND VBELP_IM = GV_ZDN_CREATE_HIS-POSNR
AND SMBLN = ''
.
ENDIF.
ENDIF.
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
ELSE."???
ENDIF.
SELECT SINGLE BUTXT WAERS INTO (OUT_01 ,OUT_04) FROM T001 WHERE BUKRS = P_RBUKRS ." AND spras = 1 .
OUT_02 = P_BUDAT+(4) && '年' && P_BUDAT+4(2) && '月' && P_BUDAT+6(2) && '日'.
*账龄数据:屏幕截止日期 减去 DN时间,将0-30天内的各DN编号汇总销售收入、发出商品金额赋值给对应的1月内;31-60天赋值给1~2月、61-90天赋值给2~3月、91-180天赋值给3~6月、大于等于181天赋值给超过6个月。
LOOP AT GT_DATA .
IF P_BUDAT - GT_DATA-WADAT_IST <= 30.
OUT_06 = OUT_06 + GT_DATA-NETSR .
OUT_12 = OUT_12 + GT_DATA-HSL .
ELSEIF P_BUDAT - GT_DATA-WADAT_IST <= 60.
OUT_07 = OUT_07 + GT_DATA-NETSR .
OUT_13 = OUT_13 + GT_DATA-HSL .
ELSEIF P_BUDAT - GT_DATA-WADAT_IST <= 90.
OUT_08 = OUT_08 + GT_DATA-NETSR .
OUT_14 = OUT_14 + GT_DATA-HSL .
ELSEIF P_BUDAT - GT_DATA-WADAT_IST <= 180.
OUT_09 = OUT_09 + GT_DATA-NETSR .
OUT_15 = OUT_15 + GT_DATA-HSL .
ELSE.
OUT_10 = OUT_10 + GT_DATA-NETSR .
OUT_16 = OUT_16 + GT_DATA-HSL .
ENDIF.
OUT_05 = OUT_05 + GT_DATA-NETSR .
OUT_11 = OUT_11 + GT_DATA-HSL .
OUT_17 = OUT_17 + GT_DATA-MSL .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = GT_DATA-ZUONR_B
IMPORTING
OUTPUT = GT_DATA-ZUONR_B.
MODIFY GT_DATA TRANSPORTING ZUONR_B.
CLEAR GT_DATA .
ENDLOOP.
IF GT_DATA[] IS NOT INITIAL.
CLEAR GT_DATA_C[] .
SELECT
MVKE~PRODH
MVKE~VKORG
MVKE~VTWEG
MVKE~MATNR
INTO CORRESPONDING FIELDS OF TABLE GT_DATA_C[]
FROM MVKE
FOR ALL ENTRIES IN GT_DATA[]
WHERE MVKE~MATNR = GT_DATA-MATNR
.
SORT GT_DATA_C[] BY VKORG VTWEG MATNR.
DELETE ADJACENT DUPLICATES FROM GT_DATA_C[] COMPARING MATNR.
LOOP AT GT_DATA .
READ TABLE GT_DATA_C WITH KEY MATNR = GT_DATA-MATNR .
IF SY-SUBRC = 0.
GT_DATA-PRODH = GT_DATA_C-PRODH .
ENDIF.
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
GT_DATA_C[] = GT_DATA[] .
SORT GT_DATA_C[] BY PRODH.
DELETE ADJACENT DUPLICATES FROM GT_DATA_C[] COMPARING PRODH.
LOOP AT GT_DATA_C .
CLEAR GT_DATA_C-MSL . "销售数量
CLEAR GT_DATA_C-NETSR ."销售收入
CLEAR GT_DATA_C-HSL . "销售成本
LOOP AT GT_DATA WHERE PRODH = GT_DATA_C-PRODH.
GT_DATA_C-MSL = GT_DATA_C-MSL + GT_DATA-MSL .
GT_DATA_C-NETSR = GT_DATA_C-NETSR + GT_DATA-NETSR .
GT_DATA_C-HSL = GT_DATA_C-HSL + GT_DATA-HSL .
CLEAR GT_DATA .
ENDLOOP.
*毛利:销售收入 减去 销售成本
GT_DATA_C-ZXSML = GT_DATA_C-NETSR - GT_DATA_C-HSL .
*毛利率: 毛利 除以 销售收入,按百分比显示。
IF GT_DATA_C-NETSR <> 0.
GT_DATA_C-ZHSLPS = GT_DATA_C-ZXSML / GT_DATA_C-NETSR * 100 .
GT_DATA_C-ZXSMPS = GT_DATA_C-ZHSLPS && '%' .
ENDIF.
SELECT SINGLE VTEXT INTO GT_DATA_C-VTEXT1 FROM T179T
WHERE PRODH = GT_DATA_C-PRODH(5)
.
SELECT SINGLE VTEXT INTO GT_DATA_C-VTEXT2 FROM T179T
WHERE PRODH = GT_DATA_C-PRODH(10)
.
SELECT SINGLE VTEXT INTO GT_DATA_C-VTEXT3 FROM T179T
WHERE PRODH = GT_DATA_C-PRODH
.
MODIFY GT_DATA_C .
CLEAR GT_DATA_C .
ENDLOOP.
ENDIF.
LOOP AT GT_DATA .
SELECT SINGLE VTEXT INTO GT_DATA-VTEXT1 FROM T179T
WHERE PRODH = GT_DATA-PRODH(5)
.
SELECT SINGLE VTEXT INTO GT_DATA-VTEXT2 FROM T179T
WHERE PRODH = GT_DATA-PRODH(10)
.
SELECT SINGLE VTEXT INTO GT_DATA-VTEXT3 FROM T179T
WHERE PRODH = GT_DATA-PRODH
.
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
CLEAR GT_DATA_D .
APPEND GT_DATA_D .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form INIT_DRAGDROP
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM INIT_DRAGDROP .
* set allowed drop effect
G_DROPEFFECT = CL_DRAGDROP=>MOVE.
* Initialize drag & drop descriptions
* -> tree
CREATE OBJECT DRAGDROP_TREE.
CALL METHOD DRAGDROP_TREE->ADD EXPORTING
FLAVOR = 'LINE'
DRAGSRC = SELECTED
DROPTARGET = ''
EFFECT = G_DROPEFFECT.
CALL METHOD DRAGDROP_TREE->GET_HANDLE IMPORTING
HANDLE = G_HANDLE_TREE.
* -> ALV grid
CREATE OBJECT DRAGDROP_ALV.
CALL METHOD DRAGDROP_ALV->ADD EXPORTING
FLAVOR = 'LINE'
DRAGSRC = ''
DROPTARGET = SELECTED
EFFECT = G_DROPEFFECT.
CALL METHOD DRAGDROP_ALV->GET_HANDLE IMPORTING
HANDLE = G_HANDLE_ALV.
ENDFORM. " init_dragdrop
*&---------------------------------------------------------------------*
*& Form CREATEDOCKINGCONTROL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CREATEDOCKINGCONTROL .
* create container for alv-tree
CREATE OBJECT G_CONTAINER_OBJECT
EXPORTING SIDE = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_RIGHT
EXTENSION = 950
REPID = G_REPID
DYNNR = '0100'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATETREECONTROL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CREATETREECONTROL .
DATA L_FCAT_CACHE TYPE LVC_T_FCAT.
DATA WA_LAYOUT_CACHE TYPE LVC_S_LAYO.
DATA WA_FIELD TYPE LVC_S_FCAT.
DATA LO_EVENT TYPE REF TO CL_EVENT_RECEIVER.
CREATE OBJECT GO_ALV_GRID_SUB
EXPORTING
I_PARENT = G_CONTAINER_OBJECT.
DEFINE FILL_FIELD.
wa_field-fieldname = &1.
wa_field-coltext = &2.
IF wa_field-fieldname = 'MSL'
OR wa_field-fieldname = 'NETSR'
OR wa_field-fieldname = 'HSL'.
wa_field-do_sum = 'X'.
ENDIF.
IF wa_field-fieldname = 'MATNR' .
wa_field-ref_table = 'MARA'.
wa_field-REF_FIELD = 'MATNR'.
ENDIF.
IF wa_field-fieldname = 'VTEXT1'
OR wa_field-fieldname = 'VTEXT2'
OR wa_field-fieldname = 'VTEXT3'.
wa_field-KEY = 'X'.
ENDIF.
APPEND wa_field TO l_fcat_cache .
CLEAR wa_field.
END-OF-DEFINITION.
FILL_FIELD :
'VTEXT1' '大类',
'VTEXT2' '中类',
'VTEXT3' '小类',
'KUNNR' '客户',
'NAME1' '客户名称',
'MATNR' '物料编码',
'ZUONR_F' 'DN编号',
'ZUONR_B' 'DN项目',
'WADAT_IST' 'DN时间',
'MSL' '销售数量',
'RUNIT' '销售单位',
'NETSR' '销售收入',
'HSL' '发出商品金额',
'KDAUF' '销售订单',
'KDPOS' '销售订单项目',
'NETPR' '净价',
'S_NETPR' '订单本币净价',
'KPEIN' '定价单位',
'UMZIN' '转换因子',
'UMZIZ' '转换因子',
'WAERK' '凭证货币'.
CREATE OBJECT LO_EVENT.
SET HANDLER LO_EVENT->HANDLE_TOOLBAR FOR GO_ALV_GRID_SUB.
SET HANDLER LO_EVENT->HANDLE_COMMAND FOR GO_ALV_GRID_SUB.
SET HANDLER LO_EVENT->HANDLE_ONDROP FOR GO_ALV_GRID_SUB.
WA_LAYOUT_CACHE-GRID_TITLE = '发出商品明细表(双击/拖拽汇总树查看)'."标题栏文本
WA_LAYOUT_CACHE-SEL_MODE = 'D'. "选择方式
WA_LAYOUT_CACHE-CWIDTH_OPT = 'X'. "优化列宽
* handle for D'n'D
WA_LAYOUT_CACHE-S_DRAGDROP-ROW_DDID = G_HANDLE_ALV.
CALL METHOD GO_ALV_GRID_SUB->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WA_LAYOUT_CACHE
CHANGING
IT_FIELDCATALOG = L_FCAT_CACHE
IT_OUTTAB = GT_DATA_D[].
* CLEAR GT_DATA_D[].
GO_ALV_GRID_SUB->REFRESH_TABLE_DISPLAY( ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FORM_INIT_0101
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FORM_INIT_0101 .
DATA L_FCAT_CACHE TYPE LVC_T_FCAT.
DATA WA_LAYOUT_CACHE TYPE LVC_S_LAYO.
DATA WA_FIELD TYPE LVC_S_FCAT.
DATA LO_EVENT TYPE REF TO CL_EVENT_RECEIVER.
CREATE OBJECT LO_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONT01'.
* create Event Receiver
CREATE OBJECT TREE_EVENT_RECEIVER.
* create tree control
CREATE OBJECT TREE1
EXPORTING
PARENT = LO_CONTAINER
NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
ITEM_SELECTION = ''
NO_HTML_HEADER = ''
NO_TOOLBAR = ''
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
ILLEGAL_NODE_SELECTION_MODE = 5
FAILED = 6
ILLEGAL_COLUMN_NAME = 7.
* fields for tree
DEFINE FILL_FIELD.
wa_field-fieldname = &1.
wa_field-coltext = &2.
IF wa_field-fieldname = 'MSL'
OR wa_field-fieldname = 'NETSR'
OR wa_field-fieldname = 'HSL'.
wa_field-do_sum = 'X'.
ENDIF.
IF wa_field-fieldname = 'MATNR' .
wa_field-ref_table = 'MARA'.
wa_field-REF_FIELD = 'MATNR'.
ENDIF.
IF wa_field-fieldname = 'RUNIT'
.
wa_field-outputlen = 8 .
ENDIF.
IF wa_field-fieldname = 'ZXSMPS'
.
wa_field-outputlen = 12 .
ENDIF.
IF wa_field-fieldname = 'MSL'
OR wa_field-fieldname = 'NETSR'
OR wa_field-fieldname = 'HSL'
OR wa_field-fieldname = 'ZXSML'
.
wa_field-outputlen = 20 .
ENDIF.
APPEND wa_field TO l_fcat_cache .
CLEAR wa_field.
END-OF-DEFINITION.
FILL_FIELD :
* 'VTEXT1' '大类',
* 'VTEXT2' '中类',
* 'VTEXT3' '小类',
'RUNIT' '单位',
'MSL' '销售数量',
'NETSR' '销售收入',
'HSL' '销售成本',
'ZXSML' '毛利',
'ZXSMPS' '毛利率'.
* header for hierarchy
PERFORM BUILD_HIERARCHY_HEADER.
* create empty tree-control
CALL METHOD TREE1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_HIERARCHY_HEADER = G_HIERARCHY_HEADER
CHANGING
IT_OUTTAB = GT_DATA_E[] "empty table
IT_FIELDCATALOG = L_FCAT_CACHE[].
* create hierarchy
CLEAR IT_NODE_KEY[] .
PERFORM CREATE_HIERARCHY.
IF IT_NODE_KEY[] IS NOT INITIAL.
CALL METHOD TREE1->EXPAND_NODES"展开节点
EXPORTING
IT_NODE_KEY = IT_NODE_KEY[] ."次末节点的NODE_KEY
ENDIF.
* register events
PERFORM REGISTER_EVENTS.
* set handler for tree1
SET HANDLER TREE_EVENT_RECEIVER->HANDLE_DOUBLE_CLICK FOR TREE1.
SET HANDLER TREE_EVENT_RECEIVER->HANDLE_ON_DRAG FOR TREE1.
* this method must be called to send the data to the frontend
CALL METHOD TREE1->FRONTEND_UPDATE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUILD_HIERARCHY_HEADER
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM BUILD_HIERARCHY_HEADER .
CLEAR G_HIERARCHY_HEADER.
G_HIERARCHY_HEADER-HEADING = TEXT-010.
G_HIERARCHY_HEADER-TOOLTIP = TEXT-010.
G_HIERARCHY_HEADER-WIDTH = 65.
G_HIERARCHY_HEADER-WIDTH_PIX = ''.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_HIERARCHY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CREATE_HIERARCHY .
DATA: L_CARRID_KEY TYPE LVC_NKEY,
L_LAST_KEY TYPE LVC_NKEY,
L_LAST_KEY_I TYPE LVC_NKEY.
* add data to tree
SORT GT_DATA_C[] BY VTEXT1 VTEXT2 VTEXT3 .
LOOP AT GT_DATA_C.
ON CHANGE OF GT_DATA_C-VTEXT1.
PERFORM ADD_CARRID_LINE1 USING GT_DATA_C
''
CHANGING L_CARRID_KEY.
ENDON.
ON CHANGE OF GT_DATA_C-VTEXT2.
PERFORM ADD_CARRID_LINE2 USING GT_DATA_C
L_CARRID_KEY
CHANGING L_LAST_KEY.
ENDON.
PERFORM ADD_CARRID_LINE3 USING GT_DATA_C
L_LAST_KEY
CHANGING L_LAST_KEY_I.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_CARRID_LINE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_GT_DATA_C text
* -->P_ text
* <--P_L_CARRID_KEY text
*&---------------------------------------------------------------------*
FORM ADD_CARRID_LINE1 USING PS_GT_DATA_C TYPE GTS_DATA
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE.
DATA: GS_DATA_C TYPE GTS_DATA.
DATA: LT_ITEM_LAYOUT TYPE LVC_T_LAYI,
LS_ITEM_LAYOUT TYPE LVC_S_LAYI,
LS_NODE_LAYOUT TYPE LVC_S_LAYN.
* set item-layout
* LS_ITEM_LAYOUT-T_IMAGE = '@FN@'.
LS_ITEM_LAYOUT-FIELDNAME = TREE1->C_HIERARCHY_COLUMN_NAME.
APPEND LS_ITEM_LAYOUT TO LT_ITEM_LAYOUT.
* longtext for CARRID
L_NODE_TEXT = '大类:'&& PS_GT_DATA_C-VTEXT1.
CLEAR GS_DATA_C .
GS_DATA_C-VTEXT1 = PS_GT_DATA_C-VTEXT1 .
GS_DATA_C-P_NODE = 'L' .
* add node for CARRID
LS_NODE_LAYOUT-DRAGDROPID = G_HANDLE_TREE.
CALL METHOD TREE1->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_NODE_LAYOUT = LS_NODE_LAYOUT
IS_OUTTAB_LINE = GS_DATA_C
IT_ITEM_LAYOUT = LT_ITEM_LAYOUT
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_CARRID_LINE2
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_GT_DATA_C text
* -->P_ text
* <--P_L_CARRID_KEY text
*&---------------------------------------------------------------------*
FORM ADD_CARRID_LINE2 USING PS_GT_DATA_C TYPE GTS_DATA
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE.
DATA: GS_DATA_C TYPE GTS_DATA.
DATA: LT_ITEM_LAYOUT TYPE LVC_T_LAYI,
LS_ITEM_LAYOUT TYPE LVC_S_LAYI,
LS_NODE_LAYOUT TYPE LVC_S_LAYN.
* set item-layout
* LS_ITEM_LAYOUT-T_IMAGE = '@FN@'.
LS_ITEM_LAYOUT-FIELDNAME = TREE1->C_HIERARCHY_COLUMN_NAME.
APPEND LS_ITEM_LAYOUT TO LT_ITEM_LAYOUT.
* longtext for CARRID
L_NODE_TEXT = '中类:'&& PS_GT_DATA_C-VTEXT2.
CLEAR GS_DATA_C .
GS_DATA_C-VTEXT2 = PS_GT_DATA_C-VTEXT2 .
GS_DATA_C-P_NODE = 'M' .
* add node for CARRID
LS_NODE_LAYOUT-DRAGDROPID = G_HANDLE_TREE.
CALL METHOD TREE1->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_NODE_LAYOUT = LS_NODE_LAYOUT
IS_OUTTAB_LINE = GS_DATA_C
IT_ITEM_LAYOUT = LT_ITEM_LAYOUT
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
APPEND P_NODE_KEY TO IT_NODE_KEY[] .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_CARRID_LINE3
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_GT_DATA_C text
* -->P_L_LAST_KEY text
* <--P_L_LAST_KEY_I text
*&---------------------------------------------------------------------*
FORM ADD_CARRID_LINE3 USING PS_GT_DATA_C TYPE GTS_DATA
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE.
DATA: LT_ITEM_LAYOUT TYPE LVC_T_LAYI,
LS_ITEM_LAYOUT TYPE LVC_S_LAYI,
LS_NODE_LAYOUT TYPE LVC_S_LAYN.
* set item-layout
* LS_ITEM_LAYOUT-T_IMAGE = '@FN@'.
LS_ITEM_LAYOUT-FIELDNAME = TREE1->C_HIERARCHY_COLUMN_NAME.
APPEND LS_ITEM_LAYOUT TO LT_ITEM_LAYOUT.
* longtext for CARRID
L_NODE_TEXT = '小类:'&& PS_GT_DATA_C-VTEXT3.
PS_GT_DATA_C-P_NODE = 'S' .
* add node for CARRID
LS_NODE_LAYOUT-DRAGDROPID = G_HANDLE_TREE.
CALL METHOD TREE1->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = PS_GT_DATA_C
IS_NODE_LAYOUT = LS_NODE_LAYOUT
IT_ITEM_LAYOUT = LT_ITEM_LAYOUT
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form REGISTER_EVENTS
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM REGISTER_EVENTS .
DATA: LT_EVENTS TYPE CNTL_SIMPLE_EVENTS,
L_EVENT TYPE CNTL_SIMPLE_EVENT.
* define the events which will be passed to the backend
CLEAR L_EVENT.
L_EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_NODE_DOUBLE_CLICK.
L_EVENT-APPL_EVENT = SELECTED.
APPEND L_EVENT TO LT_EVENTS.
CLEAR L_EVENT.
L_EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_EXPAND_NO_CHILDREN.
APPEND L_EVENT TO LT_EVENTS.
CLEAR L_EVENT.
L_EVENT-EVENTID = CL_GUI_COLUMN_TREE=>EVENTID_HEADER_CLICK.
APPEND L_EVENT TO LT_EVENTS.
CLEAR L_EVENT.
* register events
CALL METHOD TREE1->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = LT_EVENTS
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
ILLEGAL_EVENT_COMBINATION = 3.
IF SY-SUBRC <> 0.
MESSAGE X534(0K).
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form INIT_REPORTING
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM INIT_REPORTING .
C_SERVICE=>GET_PIC_TAB(
EXPORTING MIME_URL = '/SAP/BC/fp/graphics/FPsamples/Tatze.bmp'
IMPORTING PIC_TAB = PIC_TAB ).
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
TYPE = 'IMAGE'
SUBTYPE = 'GIF'
TABLES
DATA = PIC_TAB
CHANGING
URL = URL.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_PICTURE_CONTROL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CREATE_PICTURE_CONTROL .
CREATE OBJECT: container1 EXPORTING container_name = 'CONT02',
container2 EXPORTING container_name = 'PICTURE2',
pict1 EXPORTING parent = container1,
pict2 EXPORTING parent = container2.
l_alignment = cl_gui_control=>align_at_left +
cl_gui_control=>align_at_right +
cl_gui_control=>align_at_top +
cl_gui_control=>align_at_bottom.
CALL METHOD pict1->set_alignment
EXPORTING
alignment = l_alignment.
CALL METHOD pict1->set_3d_border
EXPORTING
border = 1.
evt_tab_line-eventid = cl_gui_picture=>eventid_picture_click.
evt_tab_line-appl_event = ' '. " System Event!
APPEND evt_tab_line TO evt_tab.
CALL METHOD pict1->set_registered_events
EXPORTING
events = evt_tab.
CALL METHOD pict1->load_picture_from_url
EXPORTING
url = url
EXCEPTIONS
OTHERS = 4.
ENDFORM.
*&---------------------------------------------------------------------*
*& 包含 ZFIR090_PBO
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'PF_0100'.
SET TITLEBAR 'TITLE_0100'.
CHECK CONTROLS_CREATED IS INITIAL.
CALL METHOD CL_GUI_CFW=>FLUSH."触发SAP GUI更新界面
PERFORM FORM_INIT_0101. "实例化ALV_GRID
CONTROLS_CREATED = SELECTED.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module SCREEN_SETTING_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE SCREEN_SETTING_0100 OUTPUT.
LOOP AT SCREEN.
CASE SCREEN-GROUP1 .
WHEN 'G1'.
SCREEN-ACTIVE = '0'.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module TREE_AND_DOCKING OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE TREE_AND_DOCKING OUTPUT.
CHECK CONTROLS_CREATED1 IS INITIAL.
* Dialog Modules Output
PERFORM CREATE_PICTURE_CONTROL.
* docking control
PERFORM CREATEDOCKINGCONTROL.
* tree control
PERFORM CREATETREECONTROL.
CONTROLS_CREATED1 = SELECTED.
ENDMODULE.
*&---------------------------------------------------------------------*
*& 包含 ZFIR090_PAI
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module CANCEL INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE cancel INPUT.
LEAVE PROGRAM .
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
ok_save = sy-ucomm .
CLEAR sy-ucomm .
CLEAR ok_code .
CASE ok_save.
WHEN 'BACK' .
LEAVE TO SCREEN 0 .
* WHEN 'BT_8' .
* demo=>main( ).
WHEN OTHERS .
ENDCASE .
ENDMODULE.
INITIALIZATION .
PERFORM GET_MONTH_LASTDAY.
AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN.
PERFORM SCREEN_SETTING.
START-OF-SELECTION.
* Initialization Drag and Drop
PERFORM INIT_DRAGDROP.
* Reporting events
PERFORM INIT_REPORTING.
PERFORM FOM_GETDATA .
CALL SCREEN 100.
附件:
由于程序的屏幕不好以下载的方式分享,所以这里只提供了截图,需要的话照着画就可以了。
逻辑流:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE TREE_AND_DOCKING.
MODULE SCREEN_SETTING_0100.
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
MODULE USER_COMMAND_0100.
属性:
格式: