SAP动态树程序DialogALV报表9779.docx
SAP动态树程序Dialog ALV报表-Author:SUNZK QQ:1131341075 微信:DreamSunlight88REPORT ZFIR_1027.INCLUDE ZFIR_1027_TOP.INCLUDE ZFIR_1027_CLS.INCLUDE ZFIR_1027_SEL.INCLUDE ZFIR_1027_O01.INCLUDE ZFIR_1027_I01.INCLUDE ZFIR_1027_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 , BCJNR TYPE T012K-BCJNR, ZJLB TYPE CHAR20 , "资金类别 KHHT TYPE CHAR20 , "开户行描述 QCZHYE TYPE FDBL_DE_S ,"期初帐户余额 (2015-05-01) SRZJ_01 TYPE FDBL_DE_S , "运维收入 SRZJ_02 TYPE FDBL_DE_S , "咨询技术服务收入 SRZJ_03 TYPE FDBL_DE_S , "软件收入 SRZJ_04 TYPE FDBL_DE_S , "培训收入 SRZJ_05 TYPE FDBL_DE_S , "备用金收入 SRZJ_06 TYPE FDBL_DE_S , "其他收入 SRZJ_07 TYPE FDBL_DE_S , "运营资金昆明(收) SRZJ_08 TYPE FDBL_DE_S , "运营资金上海(收) SRZJ_09 TYPE FDBL_DE_S , "利息收入 SRZJ_10 TYPE FDBL_DE_S , "其他货币资金 SRZJ_11 TYPE FDBL_DE_S , "筹资收入 SRZJ_12 TYPE FDBL_DE_S , "借款 SRZJ_13 TYPE FDBL_DE_S , "归还借款(收) SRZJ_14 TYPE FDBL_DE_S , "提取差旅费(收) SRZJ_15 TYPE FDBL_DE_S , "提取备用金(收) SRZJ_16 TYPE FDBL_DE_S , "退款 SRZJ_17 TYPE FDBL_DE_S , "保证金 SRZJ_18 TYPE FDBL_DE_S , "一般户备用金 SRZJ_19 TYPE FDBL_DE_S , "运营资金北京(收) SRZJ_XJ TYPE FDBL_DE_S , "收入小计 ZCZJ_01 TYPE FDBL_DE_S ,"报销款 ZCZJ_02 TYPE FDBL_DE_S ,"租房合同领导租房 ZCZJ_03 TYPE FDBL_DE_S ,"工资 ZCZJ_04 TYPE FDBL_DE_S ,"预借差旅费 ZCZJ_05 TYPE FDBL_DE_S ,"预借报销款 ZCZJ_06 TYPE FDBL_DE_S ,"其他预借款 ZCZJ_07 TYPE FDBL_DE_S ,"合同付款 ZCZJ_08 TYPE FDBL_DE_S ,"培训费(员工福利) ZCZJ_09 TYPE FDBL_DE_S ,"培训费 (对公free) ZCZJ_10 TYPE FDBL_DE_S ,"办公室装修费 ZCZJ_11 TYPE FDBL_DE_S ,"办公室房租 ZCZJ_12 TYPE FDBL_DE_S ,"转款手续费 ZCZJ_13 TYPE FDBL_DE_S ,"采购软件 ZCZJ_14 TYPE FDBL_DE_S ,"软件服务费 ZCZJ_15 TYPE FDBL_DE_S ,"其他库存采购支出 ZCZJ_16 TYPE FDBL_DE_S ,"工资(代发) ZCZJ_17 TYPE FDBL_DE_S ,"社保四险/医保险 ZCZJ_18 TYPE FDBL_DE_S ,"公积金 ZCZJ_19 TYPE FDBL_DE_S ,"残保金 ZCZJ_20 TYPE FDBL_DE_S ,"个人所得税 ZCZJ_21 TYPE FDBL_DE_S ,"工会经费 ZCZJ_22 TYPE FDBL_DE_S ,"社保代理/劳务派遣费 ZCZJ_23 TYPE FDBL_DE_S ,"差旅费 ZCZJ_24 TYPE FDBL_DE_S ,"机票款 ZCZJ_25 TYPE FDBL_DE_S ,"所得税(含汇算清缴) ZCZJ_26 TYPE FDBL_DE_S ,"增值税 ZCZJ_27 TYPE FDBL_DE_S ,"附加税 ZCZJ_28 TYPE FDBL_DE_S ,"印花税 ZCZJ_29 TYPE FDBL_DE_S ,"一般户备用金(机票款,支) ZCZJ_30 TYPE FDBL_DE_S ,"租房预借款 ZCZJ_31 TYPE FDBL_DE_S ,"车位租金 ZCZJ_32 TYPE FDBL_DE_S ,"电费(办公室) ZCZJ_33 TYPE FDBL_DE_S ,"水费(办公室) ZCZJ_34 TYPE FDBL_DE_S ,"其他租赁费(办公室) ZCZJ_35 TYPE FDBL_DE_S ,"采购固定资产 ZCZJ_36 TYPE FDBL_DE_S ,"保险费 ZCZJ_37 TYPE FDBL_DE_S ,"购办公用品 ZCZJ_38 TYPE FDBL_DE_S ,"其他 ZCZJ_39 TYPE FDBL_DE_S ,"律师费 ZCZJ_40 TYPE FDBL_DE_S ,"运营资金上海(支) ZCZJ_41 TYPE FDBL_DE_S ,"运营资金昆明(支) ZCZJ_42 TYPE FDBL_DE_S ,"支取备用金 ZCZJ_43 TYPE FDBL_DE_S ,"支取差旅费 ZCZJ_44 TYPE FDBL_DE_S ,"其他服务费 ZCZJ_45 TYPE FDBL_DE_S ,"服务费(支) ZCZJ_46 TYPE FDBL_DE_S ,"保证金 ZCZJ_47 TYPE FDBL_DE_S ,"归还借款(支) ZCZJ_48 TYPE FDBL_DE_S ,"奖金 ZCZJ_49 TYPE FDBL_DE_S ,"利息支出 ZCZJ_50 TYPE FDBL_DE_S ,"付支付宝备用金 ZCZJ_51 TYPE FDBL_DE_S ,"运营资金-北京(支) ZCZJ_XJ TYPE FDBL_DE_S ,"支出小计 QMYE 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-BUDATDATA: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, 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: 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, GS_T012K TYPE T012K.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 .* BREAK AB_LUOFY. 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 CAJO_NUMBER = GS_TAB-BCJNR . "银行描述 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. SORT GT_SUB_ALV BY COMP_CODE CAJO_NUMBER FISC_YEAR POSTING_NUMBER POSITION_NUMBER. DELETE ADJACENT DUPLICATES FROM GT_SUB_ALV COMPARING COMP_CODE CAJO_NUMBER FISC_YEAR POSTING_NUMBER POSITION_NUMBER. 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, S_BUDAT FOR ISELLIST-BDATE DEFAULT SY-DATUM OBLIGATORY NO INTERVALS NO-EXTENSION.SELECTION-SCREEN END OF BLOCK BLK1.START-OF-SELECTION. REFRESH GT_T012K. 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 O