SAP动态树程序DialogALV报表(下).docx
SAP动态树程序Dialog ALV报表(下)-Author:SUNZK QQ:1131341075 WEIXIN:DreamSunlight88REPORT ZFIR_1026.INCLUDE ZFIR_1026_TOP.INCLUDE ZFIR_1026_CLS.INCLUDE ZFIR_1026_SEL.INCLUDE ZFIR_1026_O01.INCLUDE ZFIR_1026_I01.INCLUDE ZFIR_1026_F01.*&-*& 包含 ZFIR_1026_TOP*&-*TYPE-POOLS:KKBLO .TABLES:T001,T012K,TCJ_POSITIONS ,ZFIT1011 , SSCRFIELDS,BKPF,ISELLIST,TCJ_DOCUMENTS.TYPES: BEGIN OF TY_TAB . INCLUDE TYPE ZFIT1011 .TYPES: BANKA TYPE BNKA-BANKA , HBKID TYPE T012K-HBKID , KDYKHB_01 TYPE FDBL_DE_S , "可动用可划拨-可动用可划拨 KDYKHB_02 TYPE FDBL_DE_S ,"可动用可划拨-现金 KDYKHB_XJ TYPE FDBL_DE_S ,"可动用可划拨-小计 KDYBKHB_10 TYPE FDBL_DE_S , "可动用不可划拨-外汇资本金户 KDYBKHB_11 TYPE FDBL_DE_S ,"可动用不可划拨-外债户 KDYBKHB_12 TYPE FDBL_DE_S ,"可动用不可划拨-销售监管户 KDYBKHB_13 TYPE FDBL_DE_S ,"可动用不可划拨-贷款监管户 KDYBKHB_XJ TYPE FDBL_DE_S ,"可动用不可划拨-小计 BKDY_20 TYPE FDBL_DE_S ,"不可动用-还本付息户 BKDY_21 TYPE FDBL_DE_S ,"不可动用-保证金户按揭保证金 BKDY_22 TYPE FDBL_DE_S ,"不可动用-保证金户还贷保证金 BKDY_23 TYPE FDBL_DE_S ,"不可动用-保证金户解押保证金 BKDY_24 TYPE FDBL_DE_S ,"不可动用-保证金户保函保证金 BKDY_25 TYPE FDBL_DE_S ,"不可动用-保证金户政府保证金 BKDY_26 TYPE FDBL_DE_S ,"不可动用-保证金户银行承兑汇票 BKDY_27 TYPE FDBL_DE_S ,"不可动用-临时验资户 BKDY_28 TYPE FDBL_DE_S ,"不可动用-纳税专户 BKDY_29 TYPE FDBL_DE_S ,"不可动用-其它户 BKDY_XJ TYPE FDBL_DE_S ,"不可动用-小计 ZHJ TYPE FDBL_DE_S ."合计TYPES: END OF TY_TAB .DATA:BEGIN OF GT_TCJ_POSITIONS OCCURS 0 . INCLUDE TYPE TCJ_POSITIONS .DATA: TRANSACT_NAME TYPE TCJ_TRANS_NAMES-TRANSACT_NAME ,* NUM TYPE CHAR4 ,* ORT01 TYPE T001-ORT01 , HBKID TYPE T012K-HBKID , "帐号* FUNAC TYPE T012K-FUNAC , "资金性质* FUNACT TYPE ZFIE1002-FUNACT , "资金性质描述 ACATR TYPE T012K-ACATR , "资金类别明细 ACATRT TYPE ZFIE1002-ACATRT , "账户性质描述* TEXT1 TYPE T012T-TEXT1 , "银行账户描述 BANKA TYPE BNKA-BANKA , "银行账户描述 CLASS TYPE CHAR20 ,* CSHYE TYPE FAGL_BALANCE_LINE-DEBIT,* QCYE TYPE FAGL_BALANCE_LINE-DEBIT,* CSHRQ TYPE BKPF-BUDAT CAJO_NUMBERT TYPE CHAR20 .DATA:END OF GT_TCJ_POSITIONS ."-SC100-* ALV实列DATA: GC_ALVGRID100 TYPE REF TO CL_GUI_ALV_GRID.* 客户容器DATA: GC_CCONTAINER100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER, GO_TREE100 TYPE REF TO CL_GUI_COLUMN_TREE, GV_CONT_100 TYPE SCRFNAME VALUE 'ALV100',* ALV字段设置 GT_FIELDCAT100 TYPE LVC_T_FCAT, GS_FIELDCAT100 TYPE LVC_S_FCAT,* ALV布局 GS_LAYOUT100 TYPE LVC_S_LAYO, GT_SORT100 TYPE LVC_T_SORT, GS_SORT100 TYPE LVC_S_SORT, GT_UIFUNCTION100 TYPE UI_FUNCTIONS.*-* DOI varibles*-*DATA: INITIALIZED(1), SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER, CONTAINER TYPE REF TO CL_GUI_CONTAINER, CONTROL TYPE REF TO I_OI_CONTAINER_CONTROL, DOCUMENT TYPE REF TO I_OI_DOCUMENT_PROXY, FILENAME LIKE RLGRAP-FILENAME , RETCODE TYPE SOI_RET_STRING, SPREADSHEET TYPE REF TO I_OI_SPREADSHEET, ERROR TYPE REF TO I_OI_ERROR, ERRORS TYPE REF TO I_OI_ERROR OCCURS 0 WITH HEADER LINE, APP TYPE VRM_ID, BDS_INSTANCE TYPE REF TO CL_BDS_DOCUMENT_SET, DOC_SIGNATURE TYPE SBDST_SIGNATURE, WA_DOC_SIGNATURE LIKE LINE OF DOC_SIGNATURE, DOC_COMPONENTS TYPE SBDST_COMPONENTS, DOC_URIS TYPE SBDST_URI, WA_DOC_URIS LIKE LINE OF DOC_URIS, EXCEL(80) VALUE 'Excel.Sheet', RANGES TYPE SOI_RANGE_LIST, RANGEITEM TYPE SOI_RANGE_ITEM, EXCEL_INPUT TYPE SOI_GENERIC_TABLE, EXCEL_INPUT_WA TYPE SOI_GENERIC_ITEM, TABLENAME(10), OKCODE(15), ROW(4), COLUMN(4), DATA(39), DOCUMENT_TYPE(80), ITEM_URL(256).DATA:BEGIN OF GT_CULUMN OCCURS 0 ,NAME TYPE TV_ITMNAME,TEXT TYPE TV_HEADING ,END OF GT_CULUMN .DATA:BEGIN OF GT_T012 OCCURS 0 . INCLUDE TYPE T012 .DATA: BANKA TYPE BNKA-BANKA .DATA:END OF GT_T012 .DATA:BEGIN OF GT_SUB_ALV OCCURS 0 . INCLUDE TYPE TCJ_POSITIONS .DATA: END OF GT_SUB_ALV .DATA: BEGIN OF IT_TAB OCCURS 0, FLAG(1), AREANO(5) TYPE N , TABCONTENT TYPE ZTAB_EXCEL , END OF IT_TAB.DATA: BEGIN OF ITAB OCCURS 0. INCLUDE STRUCTURE ALSMEX_TABLINE.DATA: END OF ITAB.RANGES:R_BUKRS FOR T001-BUKRS .DATA:GV_FLAG TYPE C , EV_REGCT TYPE ZFINODID, GV_NUM TYPE CHAR3 , G_VALUE TYPE STRING .DATA:GT_HIERARCHY TYPE SOI_HIERARCHY_TABLE.DATA:GT_T001 TYPE T001 OCCURS 0 WITH HEADER LINE , GT_T012K TYPE TABLE OF T012K WITH HEADER LINE , GT_ZFIE1002 TYPE TABLE OF ZFIE1002 WITH HEADER LINE .TYPES:TT_DEMO_ITEM TYPE STANDARD TABLE OF DEMO_ITEM, TT_ZFIT1011 TYPE STANDARD TABLE OF ZFIT1011, TT_TAB TYPE STANDARD TABLE OF TY_TAB , TY_DEMO_ITEM TYPE DEMO_ITEM, TY_ZFIT1011 TYPE ZFIT1011.DATA:GT_NODE_TAB TYPE TREEV_NTAB, GT_ITEM_TAB TYPE STANDARD TABLE OF DEMO_ITEM, GT_ZFIT1011 TYPE TABLE OF ZFIT1011, GS_ZFIT1011 TYPE ZFIT1011, GT_TAB TYPE TT_TAB , WT_TAB TYPE TT_TAB , GS_TAB TYPE TY_TAB, WS_TAB TYPE TY_TAB .FIELD-SYMBOLS:<ZFIT1011> TYPE ZFIT1011.DATA:GT_TCJ_DOCUMENTS TYPE TCJ_DOCUMENTS OCCURS 0 WITH HEADER LINE, GT_TCJ_TRANSACTIONS TYPE TCJ_TRANSACTIONS OCCURS 0 WITH HEADER LINE , GT_TCJ_TRANS_NAMES TYPE TCJ_TRANS_NAMES OCCURS 0 WITH HEADER LINE , GT_BNKA TYPE BNKA OCCURS 0 WITH HEADER LINE .*-* ALV related*-*DATA: GT_SUB_FIELDCAT TYPE LVC_T_FCAT.DATA: GT_FIELDCAT TYPE LVC_T_FCAT, IT_FIELDCAT TYPE LVC_T_FCAT, IS_FIELDCAT TYPE LVC_S_FCAT, IT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE, IT_SUB_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE, GS_LAYOUT TYPE LVC_S_LAYO, IT_SORT TYPE SLIS_T_SORTINFO_ALV, IT_PRINT TYPE SLIS_PRINT_ALV, G_GRID TYPE REF TO CL_GUI_ALV_GRID.DATA GS_SUB_ALV LIKE LINE OF GT_SUB_ALV.DATA: G_REPID LIKE SY-REPID, GT_LAYOUT_ALV TYPE LVC_S_LAYO.DATA: WA_SORT TYPE SLIS_SORTINFO_ALV, GT_SORT TYPE LVC_T_SORT.DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID.DATA: G_LAYOUT TYPE SLIS_LAYOUT_ALV, TITLE TYPE LVC_TITLE, IVARIANT LIKE DISVARIANT.DATA FNAME(20).*-* FIELD symbols*-*FIELD-SYMBOLS: <FIELD> TYPE ANY, <FIELD1> TYPE ANY .FIELD-SYMBOLS: <FS> LIKE GT_TCJ_POSITIONS.FIELD-SYMBOLS:<FS_TAB> TYPE TY_TAB .*&-*& 包含 ZFIR_1026_CLS*&-*-* INCLUDE BCALV_TOOLBAR_EVENT_RECEIVER *-*CLASS LCL_EVENT_RECEIVER DEFINITION. PUBLIC SECTION. METHODS: CONSTRUCTOR IMPORTING HANDLE TYPE REF TO CL_GUI_COLUMN_TREE CB_NODE_DOUBLE_CLICK TYPE RS38L_FNAM, HANDLE_ITEM_DOUBLE_CLICK FOR EVENT ITEM_DOUBLE_CLICK OF CL_GUI_COLUMN_TREE IMPORTING NODE_KEY ITEM_NAME. PRIVATE SECTION. DATA: TREE_HANDLE TYPE REF TO CL_GUI_COLUMN_TREE. DATA: TREE_CB_NODE_DOUBLE_CLICK TYPE RS38L_FNAM.ENDCLASS. "lcl_toolbar_event_receiver DEFINITION*-* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION*-*-*CLASS LCL_EVENT_RECEIVER IMPLEMENTATION . METHOD CONSTRUCTOR. TREE_HANDLE = HANDLE. TREE_CB_NODE_DOUBLE_CLICK = CB_NODE_DOUBLE_CLICK. ENDMETHOD. "constructor METHOD HANDLE_ITEM_DOUBLE_CLICK. DATA:LV_NODID TYPE ZFINODID . DATA:LV_ITEM_NAME TYPE NAME1 . DATA:LS_TCJ_POSITIONS LIKE LINE OF GT_TCJ_POSITIONS . DATA:LS_SUB_ALV LIKE LINE OF GT_SUB_ALV . DATA:LV_1 TYPE STRING , LV_2 TYPE STRING , LV_3 TYPE STRING , LV_4 TYPE STRING . CLEAR :LV_NODID,LV_ITEM_NAME. LV_NODID = NODE_KEY . LV_ITEM_NAME = ITEM_NAME . READ TABLE GT_TAB WITH KEY NODID = LV_NODID TRANSPORTING NO FIELDS. IF SY-SUBRC = 0. CLEAR: GT_SUB_ALV ,GS_TAB. REFRESH:WT_TAB ,GT_SUB_ALV. PERFORM FRM_GET_CLICK_DATA USING LV_NODID . " 使用递归找寻下级数据 LOOP AT WT_TAB INTO GS_TAB . LOOP AT GT_TCJ_POSITIONS INTO LS_TCJ_POSITIONS WHERE COMP_CODE = GS_TAB-BUKRS "公司代码 AND HBKID = GS_TAB-HBKID . "银行CODE* AND BANKA = GS_TAB-BANKA . "银行描述 IF GS_TAB-RCFLG = 'X'. CHECK LS_TCJ_POSITIONS-NODID IS NOT INITIAL . ELSE. CHECK LS_TCJ_POSITIONS-NODID IS INITIAL . ENDIF. IF LV_ITEM_NAME = 'ZHJ' OR LV_ITEM_NAME = 'NODID'. "合计项不做限制 ELSE. SPLIT LV_ITEM_NAME AT '_' INTO LV_1 LV_2 . "分割出资金类别,资金类别明细 SPLIT LS_TCJ_POSITIONS-CLASS AT '_' INTO LV_3 LV_4 . "分割出资金类别,资金类别明细 CONDENSE:LV_1,LV_2,LV_3,LV_4 NO-GAPS . CHECK LV_1 = LV_3 . "检查出资金类别 IF LV_2 = 'XJ' . ELSE. CHECK LV_2 = LV_4 . ENDIF. ENDIF. GS_TAB-NODID = LS_TCJ_POSITIONS-NODID . "区域中心标识. MOVE-CORRESPONDING LS_TCJ_POSITIONS TO LS_SUB_ALV . APPEND LS_SUB_ALV TO GT_SUB_ALV .CLEAR LS_SUB_ALV. ENDLOOP. ENDLOOP. IF GT_SUB_ALV IS NOT INITIAL. PERFORM FRM_SUB_FIELDCAT . PERFORM FRM_SUB_EVENTS . PERFORM FRM_SUB_ALV . ENDIF. ENDIF. ENDMETHOD. "handle_item_double_clickENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATIONDATA:GO_APPLICATION TYPE REF TO LCL_EVENT_RECEIVER.*-* -> p1 参数:1 列 2 行 3 值* <- p2 作用:填充excel*-*DEFINE HFILL-CELL. ITAB-COL = &1. ITAB-ROW = &2. IF &4 = 'X'. IF &3 < 0 . CLEAR G_VALUE. G_VALUE = ABS( &3 ). CONCATENATE '-' G_VALUE INTO G_VALUE . CONDENSE G_VALUE NO-GAPS . MOVE G_VALUE TO ITAB-VALUE. ELSE. MOVE &3 TO ITAB-VALUE. ENDIF. ELSE. MOVE &3 TO ITAB-VALUE. ENDIF. APPEND ITAB. CLEAR ITAB.END-OF-DEFINITION.*&-*& 包含 ZFIR_1026_SEL*&-*SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE K1.SELECT-OPTIONS: S_BUKRS FOR BKPF-BUKRS OBLIGATORY.SELECT-OPTIONS: S_BUDAT FOR ISELLIST-BDATE DEFAULT SY-DATUM OBLIGATORY NO INTERVALS NO-EXTENSION, S_HBKID FOR T012K-HBKID.SELECTION-SCREEN END OF BLOCK BLK1.*AT SELECTION-SCREEN ON VALUE-REQUEST FOR iv_nodid .* PERFORM frm_f4_help .START-OF-SELECTION. EV_REGCT = 'GI' . SELECT * INTO TABLE GT_ZFIT1011 FROM ZFIT1011 WHERE BUKRS IN S_BUKRS OR NODID = 'GI'. IF S_BUKRS IS NOT INITIAL. LOOP AT GT_ZFIT1011 ASSIGNING <ZFIT1011> WHERE BUKRS IS INITIAL. <ZFIT1011>-DWNOD = S_BUKRS-LOW. ENDLOOP. ENDIF. IF GT_ZFIT1011 IS INITIAL . MESSAGE '请先维护资金层次维护表ZFIT1011' TYPE 'S' DISPLAY LIKE 'E' . LEAVE LIST-PROCESSING . ENDIF.*->权限检查 AUTHORITY-CHECK OBJECT 'F_BKPF_BUK' ID 'BUKRS' FIELD S_BUKRS-LOW. IF SY-SUBRC <> 0. MESSAGE S055(ZFI) DISPLAY LIKE 'E'. EXIT. ENDIF. CALL SCREEN 100.*&-*& 包含 ZFIR_1026_O01*&-*&-*& Module STATUS_0100 OUTPUT*&-* text*-*MODULE STATUS_0100 OUTPUT.* SET PF-STATUS '0100'.* SET TITLEBAR '0100'. PERFORM FRM_BUILT_ALV_100.ENDMODULE. " STATUS_0100 OUTPUT*&-*& Module STATUS_0200 OUTPUT*&-* text*-*MODULE STATUS_0200 OUTPUT.* SET PF-STATUS 'xxxxxxxx'.* SET TITLEBAR 'xxx'. DATA: L_TOP TYPE I, L_LAST TYPE I. DATA:INDICATOR(100) TYPE C VALUE '正在写入,请等待.'. SET PF-STATUS 'EXCEL_PF'. PERFORM FRM_CREATE_BASIC_OBJECT. PERFORM PROGRESS_INDICATOR USING INDICATOR. LOOP AT IT_TAB . ITAB = IT_TAB-TABCONTENT. PERFORM FRM_SET_CELL. ENDLOOP. PERFORM FRM_SET_GROUP CHANGING GT_HIERARCHY.* *高度宽度自适应5 CALL METHOD DOCUMENT->EXECUTE_MACRO EXPORTING MACRO_STRING = 'module.Macro1'.ENDMODULE. " STATUS_0200 OUTPUT*&-*& 包含 ZFIR_1026_I01*&-*&-*& Module USER_COMMAND_0100 INPUT*&-* text*-*MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN '&F03' . LEAVE TO SCREEN 0. WHEN '&F15' OR'&F12' . LEAVE PROGRAM