一. 相關問題概覽
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