需求背景:
银行回传流水文件后,通过自开发程序调用标准程序FF_5上传银行流水,上传后用户通过FEBAN事务码过账银行流水,过账凭证抬头参考和文本字段使用的是系统的默认值,需要按用户需求修改账凭证抬头参考和文本字段。
如下,在银行对账单报表页面点击保存按钮时,将文本框中输入的值按需带入到过账凭证抬头参考和文本字段
增强BADI:FEB_BADI
注:这个BADI不支持添加多个实施,标准的已有一个实施IBS_PS,如需激活自定义实施,则需先取消激活IBS_PS(IBS 行政部门的修改)
如下创建实施后在CHANGE_POSTING_DATA方法添加修改凭证抬头字段
其中 参数
T_FTCLEAR:清账数据参数
T_FTPOST:要过账的数据即过账抬头&行项目参数,参数如下
STYPE | COUNT | FNAM | FVAL |
用于内部过帐接口的记录类型 K:凭证抬头 P:凭证行项目 | 用于关联抬头和行项目 | 字段名 | 字段值 |
- METHOD if_ex_feb_badi~change_posting_data.
- DATA lv_bktxt TYPE char30.
- DATA lt_ftpost TYPE TABLE OF ftpost.
- DATA lv_count TYPE count_pi.
- DATA lv_bktx_flag TYPE c.
- DATA lv_xblnr_flag TYPE c.
- FIELD-SYMBOLS <fs_wa> TYPE ftpost.
- IF i_febko-bukrs = 'XXXX'.
- SELECT kukey,CAST( esnum AS INT4 ) AS esnum,CAST( rsnum AS INT4 ) AS rsnum,vwezw
- FROM febre WHERE kukey = @i_febep-kukey AND esnum = @i_febep-esnum
- INTO TABLE @DATA(lt_febre).
- IF sy-subrc EQ 0.
- SORT lt_febre BY esnum ASCENDING.
- DATA(lv_cnt) = lines( lt_febre ).
- DATA(lv_xblnr) = VALUE #( lt_febre[ lv_cnt ]-vwezw OPTIONAL ).
- IF lv_xblnr CS '/OCMT'.
- lv_xblnr = VALUE #( lt_febre[ lv_cnt - 1 ]-vwezw OPTIONAL ).
- lv_xblnr = shift_left( val = lv_xblnr ).
- ENDIF.
- LOOP AT lt_febre INTO DATA(ls_febre) WHERE vwezw CS 'PY'.
- lv_bktxt = shift_left( val = ls_febre-vwezw ).
- lv_bktxt = shift_left( val = ls_febre-vwezw sub = '/PY/' ).
- EXIT.
- ENDLOOP.
- IF sy-subrc NE 0.
- lv_bktxt = VALUE #( lt_febre[ 1 ]-vwezw OPTIONAL ).
- ENDIF.
- LOOP AT t_ftpost ASSIGNING <fs_wa> .
- IF <fs_wa>-fnam NE 'BKPF-BKTXT' AND <fs_wa>-fnam NE 'BKPF-XBLNR'.
- CONTINUE.
- ENDIF.
-
- lv_bktx_flag = COND #( WHEN lv_bktx_flag IS INITIAL AND <fs_wa>-fnam NE 'BKPF-BKTXT' THEN 'X' ELSE lv_bktx_flag ).
- lv_xblnr_flag = COND #( WHEN lv_xblnr_flag IS INITIAL AND <fs_wa>-fnam NE 'BKPF-XBLNR' THEN 'X' ELSE lv_xblnr_flag ).
- <fs_wa>-fval = COND #( WHEN <fs_wa>-fnam = 'BKPF-BKTXT' THEN lv_bktxt+0(25) ELSE lv_xblnr ).
- IF lv_bktx_flag EQ 'X' AND lv_xblnr_flag EQ 'X'.
- EXIT.
- ENDIF.
- ENDLOOP.
- IF lv_xblnr_flag IS INITIAL.
- lt_ftpost = VALUE #( ( stype = 'K' count = 1 fnam = 'BKPF-XBLNR' fval = lv_xblnr ) ).
- ENDIF.
- IF lv_bktx_flag IS INITIAL .
- lt_ftpost = VALUE #( BASE lt_ftpost ( stype = 'K' count = 1 fnam = 'BKPF-BKTXT' fval = lv_bktxt+0(25) ) ).
- ENDIF.
- IF lt_ftpost IS NOT INITIAL.
- MOVE-CORRESPONDING lt_ftpost TO t_ftpost KEEPING TARGET LINES.
- ENDIF.
- ENDIF.
- ENDIF.
-
-
- ENDMETHOD.
另外还有一个BADI:FIEB_CHANGE_BS_DATA(在说明算法之前改变银行数据的储存)可以修改部分字段增强的,及出口项目FEB00001C:EXIT_RFEBBU10_001 这两个增强基本相差不大EXIT_RFEBBU10_001 可以多修改T_FEBRE,因为这两个地方实现不了修改凭证抬头修改,所以这里是通过上述FEB_BADI来实现的。