FI-發出商品分類彙總毛利分析表(開發筆記)
*&---------------------------------------------------------------------**& Report YN_FIR090A*&---------------------------------------------------------------------**& Author : NathanSun*& Create Date : 2018-08-31*& Program Type : Report*& Description :
*&---------------------------------------------------------------------**& 包含 ZFIR090_TOP*&---------------------------------------------------------------------*TABLES:VBAK
*&---------------------------------------------------------------------**& 包含 ZFIR090_CLASS*&---------------------------------------------------------------------**----------------------------------------------------------------------** 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_incomplete. " 圖示名稱* ls_toolbar-text = '功能按鈕1'. " 按鈕上顯示的文字* 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'.* 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.