Scenario: Need to add BASE AMOUNT column in FAGLB03 and FAGLL03 report.
To bring BASE AMOUNT in report output screen, Go to SE11 and under FAGLPOSX structure add required fields like below
To bring BASE AMOUNT in report output screen, Go to SE11 and under FAGLPOSX structure add required fields like below
To bring BASE AMOUNT values into main internal table under below place need to write logic.
1. BADI Name: FAGL_ITEMS_CH_DATA2. BADI Implementation Name: Z_FAGL_ITEMS_CH_DATA3. BADI Method Name: CHANGE_ITEMS
Sample Code
TYPES : BEGIN OF TY_BSEG,
BUKRS TYPE BSEG-BUKRS,
BELNR TYPE BSEG-BELNR,
GJAHR TYPE BSEG-GJAHR,
BUZEI TYPE BSEG-BUZEI,
MWSKZ TYPE BSEG-MWSKZ,
QSSKZ TYPE BSEG-QSSKZ,
DMBTR TYPE BSEG-DMBTR,
FWBAS TYPE BSEG-FWBAS,
HKONT TYPE BSEG-HKONT,
XREF3 TYPE BSEG-XREF3,
END OF TY_BSEG.
TYPES : BEGIN OF TY_BSET,
BUKRS TYPE BSET-BUKRS,
BELNR TYPE BSET-BELNR,
GJAHR TYPE BSET-GJAHR,
BUZEI TYPE BSET-BUZEI,
MWSKZ TYPE BSET-MWSKZ,
HKONT TYPE BSET-HKONT,
FWBAS TYPE BSET-FWBAS,
END OF TY_BSET.
DATA : LT_BSEG TYPE TABLE OF TY_BSEG,
WA_BSEG TYPE TY_BSEG,
LT_BSET TYPE TABLE OF TY_BSET,
WA_BSET TYPE TY_BSET.
DATA : LV_LOOP TYPE SY-TABIX.
IF CT_ITEMS IS NOT INITIAL.
SELECT BUKRS
BELNR
GJAHR
BUZEI
MWSKZ
QSSKZ
DMBTR
FWBAS
HKONT
XREF3 FROM BSEG INTO TABLE LT_BSEG
FOR ALL ENTRIES IN CT_ITEMS
WHERE BUKRS = CT_ITEMS-BUKRS AND BELNR = CT_ITEMS-BELNR AND GJAHR = CT_ITEMS-GJAHR AND
BUZEI = CT_ITEMS-BUZEI AND MWSKZ = CT_ITEMS-MWSKZ AND HKONT = CT_ITEMS-HKONT.
SELECT BUKRS
BELNR
GJAHR
BUZEI
MWSKZ
HKONT
FWBAS FROM BSET INTO TABLE LT_BSET
FOR ALL ENTRIES IN CT_ITEMS
WHERE BUKRS = CT_ITEMS-BUKRS AND BELNR = CT_ITEMS-BELNR AND GJAHR = CT_ITEMS-GJAHR AND
BUZEI = CT_ITEMS-BUZEI AND MWSKZ = CT_ITEMS-MWSKZ AND HKONT = CT_ITEMS-HKONT.
ENDIF.
BUKRS TYPE BSEG-BUKRS,
BELNR TYPE BSEG-BELNR,
GJAHR TYPE BSEG-GJAHR,
BUZEI TYPE BSEG-BUZEI,
MWSKZ TYPE BSEG-MWSKZ,
QSSKZ TYPE BSEG-QSSKZ,
DMBTR TYPE BSEG-DMBTR,
FWBAS TYPE BSEG-FWBAS,
HKONT TYPE BSEG-HKONT,
XREF3 TYPE BSEG-XREF3,
END OF TY_BSEG.
TYPES : BEGIN OF TY_BSET,
BUKRS TYPE BSET-BUKRS,
BELNR TYPE BSET-BELNR,
GJAHR TYPE BSET-GJAHR,
BUZEI TYPE BSET-BUZEI,
MWSKZ TYPE BSET-MWSKZ,
HKONT TYPE BSET-HKONT,
FWBAS TYPE BSET-FWBAS,
END OF TY_BSET.
DATA : LT_BSEG TYPE TABLE OF TY_BSEG,
WA_BSEG TYPE TY_BSEG,
LT_BSET TYPE TABLE OF TY_BSET,
WA_BSET TYPE TY_BSET.
DATA : LV_LOOP TYPE SY-TABIX.
IF CT_ITEMS IS NOT INITIAL.
SELECT BUKRS
BELNR
GJAHR
BUZEI
MWSKZ
QSSKZ
DMBTR
FWBAS
HKONT
XREF3 FROM BSEG INTO TABLE LT_BSEG
FOR ALL ENTRIES IN CT_ITEMS
WHERE BUKRS = CT_ITEMS-BUKRS AND BELNR = CT_ITEMS-BELNR AND GJAHR = CT_ITEMS-GJAHR AND
BUZEI = CT_ITEMS-BUZEI AND MWSKZ = CT_ITEMS-MWSKZ AND HKONT = CT_ITEMS-HKONT.
SELECT BUKRS
BELNR
GJAHR
BUZEI
MWSKZ
HKONT
FWBAS FROM BSET INTO TABLE LT_BSET
FOR ALL ENTRIES IN CT_ITEMS
WHERE BUKRS = CT_ITEMS-BUKRS AND BELNR = CT_ITEMS-BELNR AND GJAHR = CT_ITEMS-GJAHR AND
BUZEI = CT_ITEMS-BUZEI AND MWSKZ = CT_ITEMS-MWSKZ AND HKONT = CT_ITEMS-HKONT.
ENDIF.
CLEAR : LV_LOOP.
LOOP AT CT_ITEMS INTO WA_ITEMS.
LOOP AT CT_ITEMS INTO WA_ITEMS.
LV_LOOP = LV_LOOP + 1.
READ TABLE LT_BSEG INTO WA_BSEG WITH KEY BUKRS = WA_ITEMS-BUKRS BELNR = WA_ITEMS-BELNR GJAHR = WA_ITEMS-GJAHR
BUZEI = WA_ITEMS-BUZEI MWSKZ = WA_ITEMS-MWSKZ HKONT = WA_ITEMS-HKONT.
IF SY-SUBRC = 0.
WA_ITEMS-FWBAS = WA_BSEG-FWBAS.
MODIFY CT_ITEMS FROM WA_ITEMS INDEX LV_LOOP TRANSPORTING FWBAS.
ELSE.
READ TABLE LT_BSET INTO WA_BSET WITH KEY BUKRS = WA_ITEMS-BUKRS BELNR = WA_ITEMS-BELNR
GJAHR = WA_ITEMS-GJAHR BUZEI = WA_ITEMS-BUZEI
BUZEI = WA_ITEMS-BUZEI MWSKZ = WA_ITEMS-MWSKZ HKONT = WA_ITEMS-HKONT.
IF SY-SUBRC = 0.
WA_ITEMS-FWBAS = WA_BSEG-FWBAS.
MODIFY CT_ITEMS FROM WA_ITEMS INDEX LV_LOOP TRANSPORTING FWBAS.
ELSE.
READ TABLE LT_BSET INTO WA_BSET WITH KEY BUKRS = WA_ITEMS-BUKRS BELNR = WA_ITEMS-BELNR
GJAHR = WA_ITEMS-GJAHR BUZEI = WA_ITEMS-BUZEI
MWSKZ = WA_ITEMS-MWSKZ HKONT = WA_ITEMS-HKONT.
IF SY-SUBRC = 0.
WA_ITEMS-FWBAS = WA_BSET-FWBAS.
MODIFY CT_ITEMS FROM WA_ITEMS INDEX LV_LOOP TRANSPORTING FWBAS.
ENDIF.
ENDIF.
IF SY-SUBRC = 0.
WA_ITEMS-FWBAS = WA_BSET-FWBAS.
MODIFY CT_ITEMS FROM WA_ITEMS INDEX LV_LOOP TRANSPORTING FWBAS.
ENDIF.
ENDIF.
ENDLOOP.