一. 相关问题概览
1. 固定资产业务过渡科目摘要增强功能-F-02
需用表BKPF、BSEG、T001。通过BUKRS、BELNR、GJAHR三个字段相等关联BKPF与BSEG。通过BKPF-BUKRS = T001-BUKRS关联。
在做SAP资产购置业务的财务凭证,包括手工凭证、以及集成采购凭证时,产生的科目BSEG-HKONT为1601990001,在资产购置SAP系统自动生成第二张自动凭证时,在BKPF- NUMPG =“ ”BSEG-SGTXT=原凭证摘要+原凭证(XXXXXXXXXX)。
2. 固定资产业务过渡科目摘要增强功能-MIGO
类似F-02事务码的功能,在做MIGO收货的时候,也会同时生成两张会计凭证,要求自动生成第二张自动凭证时,在BSEG-SGTXT=原凭证摘要+原凭证(XXXXXXXXXX),且总账科目限定在1601990001内。
3. 主营业务收入等科目自动反记账功能
新建科目反记账配置表ZFI_FJZ,字段包括从科目HKONTF(BSEG-HKONT)、到科目HKONTT(BSEG-HKONT)、SHKZG借贷方(CHAR 1) 值=H或S。
科目若包含在配置表ZFI_FJZ中,在凭证过账时,按照BSEG-HKONT取出对应ZFI_FJZ-SHKZG:若BSEG-SHKZG=ZFI_FJZ-SHKZG,BSEG-XNEGP=空;若BSEG-SHKZG<>ZFI_FJZ-SHKZG, BSEG-XNEGP=X。
二. 问题图片描述
1. 固定资产业务过渡科目摘要增强功能-F-02
问题概述:这个时候会产生两个财务凭证,一个是100000083,一个是100000084,按照要求需要把100000083原凭证的凭证号+凭证摘要放到100000084凭证上去,效果如下:
2. 固定资产业务过渡科目摘要增强功能-MIGO
问题概述:这个时候会产生两个财务凭证,一个是5000000077,一个是5000000078,按照要求需要把5000000078原凭证的凭证号+凭证摘要放到5000000077凭证上去,效果如下:
3. 主营业务收入等科目自动反记账功能
问题概述:科目若包含在配置表ZFI_FJZ中,在凭证过账时,按照BSEG-HKONT取出对应ZFI_FJZ-SHKZG:若BSEG-SHKZG=ZFI_FJZ-SHKZG,BSEG-XNEGP=空;若BSEG-SHKZG<>ZFI_FJZ-SHKZG, BSEG-XNEGP=X。
三. 增强位置及处理方法
1. MF05AFF0_FCODE_BEARBEITUNG程序-固定资产业务过渡科目摘要增强功能-F-02
增强位置:MF05AFF0_FCODE_BEARBEITUNG程序3383行的transaktion_verlassen子例程。
增强类型:隐式增强
代码逻辑:此处增强是两个会计凭证都生成的地方,当总账科目是1601990001时,根据bkpf和bseg表查询出两张会计凭证,然后用CHANGE_DOCUMENT函数修改第二张会计凭证行项目的sgtxt字段。
ENHANCEMENT 2 ZEHENC_SAPMF05A. "active version
* FI 20221215:固定资产业务过渡科目摘要增强功能
WAIT UP TO 1 SECONDS.
READ TABLE xbseg WITH KEY hkont = '1601990001'.
IF sy-subrc = 0.
DATA: lt_bkdf TYPE TABLE OF bkdf,
lt_bkpf TYPE TABLE OF bkpf,
ls_bkpf TYPE bkpf,
lt_bsec TYPE TABLE OF bsec,
lt_bsed TYPE TABLE OF bsed,
ls_bseg TYPE bseg,
lt_bseg TYPE TABLE OF bseg,
lt_bset TYPE TABLE OF bset.
DATA: ls_belnr_second TYPE belnr_d.
DATA: ls_xbkpf TYPE bkpf.
CLEAR: ls_bkpf,lt_bkpf[],lt_bseg[],ls_xbkpf.
DATA: ls_bkpf_judge TYPE bkpf.
CLEAR: ls_bkpf_judge.
ls_belnr_second = bkpf-belnr + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_belnr_second
IMPORTING
output = ls_belnr_second.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF ls_bkpf_judge
FROM bkpf
WHERE bukrs eq bkpf-bukrs
AND gjahr eq bkpf-gjahr
AND belnr EQ ls_belnr_second.
if ls_bkpf_judge IS NOT INITIAL.
ls_bkpf-mandt = sy-mandt.
ls_bkpf-bukrs = bkpf-bukrs.
ls_bkpf-gjahr = bkpf-gjahr.
ls_bkpf-belnr = ls_belnr_second.
APPEND ls_bkpf TO lt_bkpf.
LOOP AT xbseg.
CLEAR: ls_bseg.
ls_bseg-mandt = sy-mandt.
ls_bseg-bukrs = xbseg-bukrs.
ls_bseg-gjahr = xbseg-gjahr.
ls_bseg-buzei = xbseg-buzei.
ls_bseg-belnr = ls_belnr_second.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = xbseg-belnr
IMPORTING
output = xbseg-belnr.
ls_bseg-sgtxt = xbseg-sgtxt && '-原凭证(' && xbseg-belnr && ')'.
APPEND ls_bseg TO lt_bseg.
ENDLOOP.
CALL FUNCTION 'CHANGE_DOCUMENT'
TABLES
t_bkdf = lt_bkdf
t_bkpf = lt_bkpf
t_bsec = lt_bsec
t_bsed = lt_bsed
t_bseg = lt_bseg
t_bset = lt_bset.
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.
* FI 20221215
ENDENHANCEMENT.
2. LMIGOKG1程序-固定资产业务过渡科目摘要增强功能-MIGO
增强位置:LMIGOKD1程序的2076行的goods_movement_post方法。然后进入到LMIGOKE1程序的1094行,然后进入到LMIGOKG1程序的goods_movement_post具体方法中,创建Z_MIGO_CREATE_ACC_DOCUMENT隐式增强即可。
增强类型:隐式增强
代码逻辑:此处增强是MIGO两个会计凭证都生成的地方,当总账科目是1601990001时,根据bkpf和bseg表查询出两张会计凭证,然后用CHANGE_DOCUMENT函数修改第二张会计凭证行项目的sgtxt字段。
ENHANCEMENT 1 Z_MIGO_CREATE_ACC_DOCUMENT. "active version
" FI 20221230:MIGO自动生成会计凭证增强 LIANG ED1K924636
DATA: lt_bkdf TYPE TABLE OF bkdf,
lt_bsec TYPE TABLE OF bsec,
lt_bsed TYPE TABLE OF bsed,
lt_bset TYPE TABLE OF bset.
DATA: ls_BKPF1 TYPE BKPF,
ls_BKPF2 TYPE BKPF,
lt_BKPF TYPE TABLE OF BKPF.
DATA: LT_BKPF_RESULT TYPE TABLE OF BKPF.
DATA: ls_bseg TYPE bseg,
lt_bseg TYPE TABLE OF bseg.
DATA: ls_bseg_temp TYPE bseg.
DATA: ls_AWKEY TYPE bkpf-AWKEY.
CLEAR: lt_BKPF[],ls_BKPF1,ls_BKPF2,ls_AWKEY,ls_bseg_temp,ls_bseg,lt_bseg[],LT_BKPF_RESULT[].
ls_AWKEY = ls_emkpf-MBLNR && ls_emkpf-MJAHR.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_BKPF
FROM BKPF
WHERE AWKEY EQ ls_AWKEY.
SORT lt_BKPF BY BELNR ASCENDING.
IF sy-subrc EQ 0.
READ TABLE lt_BKPF INTO ls_BKPF1 INDEX 1.
READ TABLE lt_BKPF INTO ls_BKPF2 INDEX 2.
APPEND ls_BKPF2 TO LT_BKPF_RESULT.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_bseg
FROM bseg
WHERE BUKRS EQ ls_BKPF2-bukrs
AND BELNR EQ ls_BKPF2-BELNR
AND GJAHR EQ ls_BKPF2-GJAHR.
LOOP AT lt_bseg INTO ls_bseg.
IF ls_bseg-hkont EQ '1601990001'.
CLEAR: ls_bseg_temp.
" 取第一个行项目的行项目文本
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF ls_bseg_temp
FROM bseg
WHERE BUKRS EQ ls_bseg-bukrs
AND BELNR EQ ls_BKPF1-BELNR
AND GJAHR EQ ls_bseg-GJAHR
AND BUZEI EQ ls_bseg-BUZEI.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_bseg_temp-belnr
IMPORTING
output = ls_bseg_temp-belnr.
ls_bseg-sgtxt = ls_bseg_temp-sgtxt && '-原凭证(' && ls_bseg_temp-belnr && ')'.
MODIFY lt_bseg FROM ls_bseg.
ENDIF.
ENDLOOP.
CALL FUNCTION 'CHANGE_DOCUMENT'
TABLES
t_bkdf = lt_bkdf
t_bkpf = LT_BKPF_RESULT
t_bsec = lt_bsec
t_bsed = lt_bsed
t_bseg = lt_bseg
t_bset = lt_bset.
ENDIF.
" FI 20221230 LIANG ED1K924636
ENDENHANCEMENT.
3. ZFIR_GGBS000程序-主营业务收入等科目自动反记账功能
增强位置:LMIGOKG1程序
增强类型:隐式增强
代码逻辑:用的是出口增强,创建新的冲销凭证文本替代,替代子例程为U305,字段为bseg-xnegp。
* 反记账替代 Modify By LIANG ED1K924602 20221226
exits-name = 'U305'.
exits-param = c_exit_param_field.
exits-title = TEXT-305. "
APPEND exits.
* FI 20221226 主营业务收入等科目自动反记账功能
*
FORM u305 USING bseg-xnegp TYPE bseg-xnegp.
DATA: ls_zfi_fjz1 TYPE zfi_fjz.
DATA: ls_zfi_fjz2 TYPE zfi_fjz.
CLEAR: ls_zfi_fjz1,ls_zfi_fjz2.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF ls_zfi_fjz1
FROM zfi_fjz
WHERE hkontf <= bseg-hkont
AND hkontt >= bseg-hkont.
IF sy-subrc EQ 0.
IF bseg-shkzg = ls_zfi_fjz1-shkzg.
bseg-xnegp = ''.
ELSE.
bseg-xnegp = 'X'.
ENDIF.
ELSE.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF ls_zfi_fjz2
FROM zfi_fjz
WHERE hkontf = bseg-hkont.
IF sy-subrc EQ 0.
IF bseg-shkzg = ls_zfi_fjz2-shkzg.
bseg-xnegp = ''.
ELSE.
bseg-xnegp = 'X'.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
* FI 20221226