1、点“系统"--状态
2、在状态窗口中,”程序”文本框中为该事务码的程序,双击可以打开源代码;,
4
*&---------------------------------------------------------------------* *& Report ZFIRP0037 *&---------------------------------------------------------------------* *&回款查询表 2021-10-08 Create by Yitieling *&---------------------------------------------------------------------* REPORT zfirp0037. TABLES :bseg,kna1.**定义结构TYPES: BEGIN OF gty_out,bukrs LIKE bseg-bukrs, "公司代码belnr LIKE bseg-belnr, "凭证编号gjahr LIKE bseg-gjahr, "年度h_bldat LIKE bseg-h_bldat, "票据日期hkont LIKE bseg-hkont, "借方科目shkzg LIKE bseg-shkzg, "借贷hkont1 LIKE bseg-hkont, "贷方科目kunnr LIKE bseg-kunnr, "客户号name1 LIKE kna1-name1, "客户名称xref1 LIKE bseg-xref1, "业务员wrbtr LIKE bseg-wrbtr, "金额sgtxt LIKE bseg-sgtxt, "摘要h_blart LIKE bseg-h_blart, "凭证类型prctr LIKE bseg-prctr, "利润中心h_budat LIKE bseg-h_budat, "过帐日期vtweg TYPE vtweg,END OF gty_out.*标准的ALV输出 * slis 类型池 全局变量 定义,多数没用, DATA: g_repid TYPE sy-repid,g_line TYPE slis_fieldcat_alv,gt_fieldcat TYPE slis_t_fieldcat_alv,gt_layout TYPE slis_layout_alv,gt_sortinfo TYPE slis_sortinfo_alv,gt_lvc_title TYPE lvc_title,gt_list_top_of_page TYPE slis_t_listheader,gt_events TYPE slis_t_event,gt_fcat TYPE lvc_t_fcat,gt_table TYPE REF TO data,gs_settings TYPE lvc_s_glay,f2code LIKE sy-ucomm VALUE '&TEA'. DATA g_status_set TYPE slis_formname VALUE 'SET_STATUS'.* 定义用于输出的内表 DATA: gt_tab TYPE STANDARD TABLE OF gty_out WITH HEADER LINE. DATA: gt_tab2 TYPE STANDARD TABLE OF gty_out WITH HEADER LINE.**定义双击执行事务代码 用, 猜的 DATA ok_code LIKE sy-ucomm.DATA: g_ucomm LIKE sy-ucomm VALUE '&IC1'.DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE."用来存储屏幕字段参数值,传递录屏参数 * messages of call transaction DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE."记录执行BDC过程中产生的消息 DATA: ls_mss LIKE bdcmsgcoll.*选择屏幕 SELECT-OPTIONS:s_kunnr FOR bseg-kunnr,"客户号s_bukrs FOR bseg-bukrs,"公司代码s_prctr FOR bseg-prctr,"利润中心s_xref1 FOR bseg-xref1,"业务员s_ktokd FOR kna1-ktokd,"客户组s_pzlx FOR kna1-ktokd,"凭证类型s_rq FOR bseg-h_bldat OBLIGATORY.AT SELECTION-SCREEN.PERFORM frm_chk_auth_prctr. **功能 程序 ** 1 正常回款 START-OF-SELECTION.SELECT DISTINCTb~bukrs,b~belnr,b~gjahr,b~h_bldat,a~hkont,b~shkzg,b~hkont,b~kunnr,c~name1,b~xref1,b~wrbtr,b~sgtxt,b~h_blart,b~prctr,b~h_budat, b~xref2 AS vtwegINTO TABLE @gt_tabFROM bseg AS aINNER JOIN bseg AS bON a~bukrs = b~bukrs AND a~belnr = b~belnr AND a~gjahr = b~gjahrINNER JOIN kna1 AS cON b~kunnr = c~kunnrWHERE ( a~hkont LIKE '1002%' OR a~hkont LIKE '1121%' OR a~hkont LIKE '1012%' ) "1002*银行存款 1121 应收票据 1012 其它货币资金 1122* 应收帐款AND a~shkzg = 'S'AND ( b~hkont LIKE '1122%' )AND b~shkzg = 'H'AND b~h_monat <> '000' AND b~kunnr <> ''AND c~ktokd IN @s_ktokd "客户类别AND b~bukrs IN @s_bukrsAND b~kunnr IN @s_kunnrAND b~xref1 IN @s_xref1AND b~h_blart IN @s_pzlxAND a~prctr IN @s_prctr "利润中心AND b~h_bldat IN @s_rq.**2 处理退款调款 ,需要变为负数SELECT DISTINCTb~bukrs,b~belnr,b~gjahr,b~h_bldat,a~hkont,b~shkzg,b~hkont,b~kunnr,c~name1,b~xref1,b~wrbtr,b~sgtxt,b~h_blart,b~prctr,b~h_budat,b~xref2 AS vtwegINTO TABLE @gt_tab2FROM bseg AS aINNER JOIN bseg AS bON a~bukrs = b~bukrs AND a~belnr = b~belnr AND a~gjahr = b~gjahrINNER JOIN kna1 AS cON b~kunnr = c~kunnrWHERE ( a~hkont LIKE '1002%' OR a~hkont LIKE '1121%' OR a~hkont LIKE '1012%' )AND a~shkzg = 'H'AND ( b~hkont LIKE '1122%' )AND b~shkzg = 'S'AND b~h_monat <> '000' AND b~kunnr <> ''AND c~ktokd IN @s_ktokd "客户类别AND b~bukrs IN @s_bukrsAND b~kunnr IN @s_kunnrAND b~xref1 IN @s_xref1AND b~h_blart IN @s_pzlxAND a~prctr IN @s_prctr "利润中心AND b~h_bldat IN @s_rq.**FIELD-SYMBOL 指针 可直接更改内表字段的值 .LOOP AT gt_tab2 ASSIGNING FIELD-SYMBOL(<fs_out>).<fs_out>-wrbtr = <fs_out>-wrbtr * -1.ENDLOOP.APPEND LINES OF gt_tab2 TO gt_tab.**去掉前导000LOOP AT gt_tab ASSIGNING FIELD-SYMBOL(<fs_out2>).SHIFT <fs_out2>-kunnr LEFT DELETING LEADING '0'.SHIFT <fs_out2>-belnr LEFT DELETING LEADING '0'.SHIFT <fs_out2>-prctr LEFT DELETING LEADING '0'.ENDLOOP.END-OF-SELECTION.**执行函数PERFORM frm_show_alv.* 输出 alv 报表 FORM frm_show_alv .DEFINE append_alv_field.CLEAR g_line.g_line-fieldname = &1.g_line-tabname = 'GT_ALV'.g_line-reptext_ddic = &2.g_line-seltext_l = &2.g_line-seltext_m = &2.g_line-seltext_s = &2.g_line-cfieldname = &3.g_line-ctabname = &4.g_line-no_out = &5.g_line-no_zero = &6.g_line-outputlen = &7.g_line-qfieldname = &8.g_line-just = &9.g_line-ddictxt = 'L'.g_line-do_sum = 'X'.APPEND g_line TO gt_fieldcat.END-OF-DEFINITION.**ALV 显示字段REFRESH:gt_fieldcat.gt_layout-colwidth_optimize = 'X'. " 自适应宽度gt_layout-zebra = 'X'. " 自适应宽度append_alv_field 'BUKRS' '公司' '' '' '' '' '' '' ''.append_alv_field 'H_BLDAT' '票据日期' '' '' '' '' '' '' ''.append_alv_field 'BELNR' '凭证号' '' '' '' '' '' '' ''.append_alv_field 'KUNNR' '客户号' '' '' '' '' '' '' ''.append_alv_field 'NAME1' '客户名称' '' '' '' '' '' '' ''.append_alv_field 'XREF1' '业务员' '' '' '' '' '' '' ''.append_alv_field 'HKONT' '借方科目' '' '' '' '' '' '' ''.append_alv_field 'SHKZG' '借贷' '' '' '' '' '' '' ''.append_alv_field 'HKONT1' '贷方科目' '' '' '' '' '' '' ''.append_alv_field 'WRBTR' '金额' '' '' '' '' '' '' ''.append_alv_field 'SGTXT' '摘要' '' '' '' '' '' '' ''.append_alv_field 'H_BLART' '类型' '' '' '' '' '' '' ''.append_alv_field 'PRCTR' '利润中心' '' '' '' '' '' '' ''.append_alv_field 'H_BUDAT' '过帐日期' '' '' '' '' '' '' ''.append_alv_field 'VTWEG' '渠道' '' '' '' '' '' '' ''.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTINGi_callback_program = sy-repid"i_callback_pf_status_set = g_status_set "'FORM_PF_STATUS_SET'"i_callback_user_command 设置鼠标或键盘事件, 双击调用其它事件的,FORM_USER_COMMAND 须在后面单独定义i_callback_user_command = 'FORM_USER_COMMAND' "双击事件调用命令处,客户命令指定子程序is_layout = gt_layoutit_fieldcat = gt_fieldcatTABLESt_outtab = gt_tab "指定要显示的内表名称EXCEPTIONSprogram_error = 1OTHERS = 2.IF sy-subrc NE 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.ENDFORM.***双击联查原始凭证,参数:凭证号,公司代码,年度 FORM form_user_command USING i_ucomm LIKE sy-ucomm "双击is_selfield TYPE slis_selfield. "选择的行数CASE i_ucomm .WHEN '&IC1'."双击事件READ TABLE gt_tab INDEX is_selfield-tabindex.IF sy-subrc = 0.IF is_selfield-value IS NOT INITIAL. * IF is_selfield-fieldname = 'belnr'."选中行的列名=凭证编号SET PARAMETER ID 'BLN' FIELD gt_tab-belnr.SET PARAMETER ID 'GJR' FIELD gt_tab-gjahr. * ENDIF.SET PARAMETER ID 'BUK' FIELD gt_tab-bukrs.CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.ENDIF.ENDIF.ENDCASE. ENDFORM.**权限检查 FORM frm_chk_auth_prctr.DATA: message TYPE string.SELECT prctr,bukrsINTO TABLE @DATA(t_auth)FROM cepc_bukrsWHERE prctr IN @s_prctr AND bukrs IN @s_bukrs AND kokrs = '8000'.LOOP AT t_auth INTO DATA(wa_auth).AUTHORITY-CHECK OBJECT 'K_PCAR_REP'ID 'BUKRS' FIELD wa_auth-bukrsID 'PRCTR' FIELD wa_auth-prctrID 'KSTAR' DUMMY. * ID 'ACTVT' FIELD 'xxxxxxxx'.IF sy-subrc <> 0.message = '公司代码:' && wa_auth-bukrs && '利润中心:' && wa_auth-prctr.MESSAGE e053(zmm) WITH message.ENDIF.ENDLOOP.ENDFORM.*FORM form_pf_status_set USING rt_extab TYPE slis_t_extab. * * SET PF-STATUS 'STANDARD'. *ENDFORM. *FORM no_zero CHANGING clike. * CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' * EXPORTING * input = clike * IMPORTING * output = clike. *ENDFORM. ********** *MODULE user_command_0100 INPUT. * CASE ok_code. * WHEN 'OK'. * * LEAVE TO SCREEN 0. * WHEN 'CAN'. * LEAVE TO SCREEN 0. * WHEN OTHERS. * ENDCASE. *ENDMODULE. *在ACDOCA表中,公司代码RBUKRS,会计年度GJAHR,借贷标识DRCRK,期间POPER(排除期间为00),科目号RACCT,利润中心PRCTR,客户KUNNR,公司代码货币RHCUR,以公司代码货币计金额 HSL, **1)以公司代码,年度,期间 为选择条件,筛选出凭证编码BELNR为集合一 *2)在集合一的基础上,筛选出满足: *(借贷标识DRCRK=S,科目号RACCT=1002*或者1121*,借贷标识DRCRK=H,科目号RACCT=1122* )或者 *(借贷标识DRCRK=S,科目号RACCT=1122*,借贷标识DRCRK=H,科目号RACCT=1002*或者1121*)的凭证编码为集合二 ****************3)取集合二两种情况的应收账款RACCT=1122* 所在行的公司代码金额HSL,以及客户KUNNR(客户为空的排除掉),利润中心PRCTR,金额求和之后乘以负一 ****************举例:借方1002*贷方1122*满足,借方1121*贷方1122*满足,借1002*借1121*贷1122*贷1122*多借多贷也满足