In this post blog, I will show you how change to line items in asset document for the asset accounting system that allows you to differentiate accounts based on fixed asset type and cost center.
This method can be applied to SAP S/4HANA version 1909 and later.
In order to make necessary changes we need to create implementation for FAA_DOCLINES_CUSTOMER.
According old SAP note, ZTR_AA_REALLOC should be used. But 1909 a new BAdI and table are introduced. Now instead of ZTR_AA_REALLOC table we can use SAP standard table FIAATRV_REALLOC.
FIAATRV_REALLOC table is the maintenance table. You can use FIAATRC_REALLOC table for the Transparent table.
Use FIAATRV_REALLOC table for the asset accounting system that allows you to differentiate accounts based on fixed asset type and cost center.
Then we implement FAA_DOCLINES_CUSTOMER BAdI application. This ES_FAA_DOCLINES enhancement is located under the enhancement spot.
We apply the FAA_DOCLINES_CUSTOMER BAdI we need to transfer the accounts to the expense account starting with 7.
Create BAdI Implementation
We implement the FAA_DOCLINES_CUSTOMER BAdI that we need for AFAB.
Entering BAdI and class names then we choose our BAdI.
Activate the incoming screen and continue by to the next screen.
Double-click on BAdI and click Adjust BAdI Implementation then press the Implement button and apply our method.
Finally, we write our code in the method as follows and activate it.
Method: IF_EX_FAA_DOCLINES_CUSTOMER~CHANGE_DOCUMENT
METHOD if_ex_faa_doclines_customer~change_document.
DATA: ls_accit TYPE accit,
lv_ktopl TYPE ktopl,
lv_konto TYPE saknr,
ls_t001 TYPE t001.
SELECT SINGLE * FROM t001
INTO @DATA(s_t001)
WHERE bukrs EQ @is_posting_data-bukrs.
IF sy-subrc IS INITIAL.
IF is_posting_data-kostl IS NOT INITIAL.
SELECT * FROM fiaatrc_realloc
INTO TABLE @DATA(t_realloc)
FOR ALL ENTRIES IN @ct_accit
WHERE ktopl EQ @s_t001-ktopl
AND kokrs EQ @ct_accit-kokrs
AND kostl1 EQ @is_posting_data-kostl
AND kostl2 EQ @is_posting_data-kostl
AND vbrkon EQ @ct_accit-hkont
AND konto NE @space.
IF sy-subrc IS INITIAL.
TYPES ty_shkzg TYPE RANGE OF shkzg.
DATA(r_shkzg) = VALUE ty_shkzg( sign = 'I' option = 'EQ'
( low = 'S' )
( low = 'H' )
).
LOOP AT ct_accit ASSIGNING FIELD-SYMBOL(<accit>)
WHERE shkzg IN r_shkzg.
READ TABLE t_realloc ASSIGNING FIELD-SYMBOL(<realloc>)
WITH KEY kokrs = <accit>-kokrs
vbrkon = <accit>-hkont.
IF sy-subrc IS INITIAL.
<accit>-hkont = <realloc>-konto.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
I also suggest you to check the FAA_DOCLINES_COUNTRY BAdI too. This BAdI enables you to apply filter.
Those are steps to enhance AFAB.
I hope that helps you. And If you know any other alternative solution, feel free to comment.