Monday, 15 September 2025

Enhance SAP FBL1N, FBL3N & FBL5N: Add Custom Fields in 3 Easy Steps (ABAP Guide)

Enhance SAP FBL1N, FBL3N & FBL5N: Add Custom Fields in 3 Easy Steps (ABAP Guide)

Enhance SAP FBL1N, FBL3N & FBL5N: Add Custom Fields in 3 Easy Steps (ABAP Guide)

In SAP Financial Accounting (FI), line item reports such as FBL1N (Vendor Line Items), FBL3N (G/L Account Line Items), and FBL5N (Customer Line Items) are heavily used. Business users often require custom fields in these reports. This guide explains how to add custom fields step by step with ABAP.

Step 1: Append Structure to RFPOSX

Extend the standard structure RFPOSX by appending your custom fields.

Step 2: Run Program RFPOSXEXTEND

Execute program RFPOSXEXTEND to regenerate the structure and make the appended fields available in the FBL reports.

Step 3: Implement BADI FI_ITEMS_CH_DATA

Implement BADI FI_ITEMS_CH_DATA and enhance method CHANGE_ITEMS to fill the new custom fields.

ABAP Code Example


METHOD if_ex_fi_items_ch_data~change_items.
  CONSTANTS : lc_fbl1n TYPE tcode VALUE 'FBL1N'.
  CONSTANTS : lc_fbl3n TYPE tcode VALUE 'FBL3N'.
  CONSTANTS : lc_fbl5n TYPE tcode VALUE 'FBL5N'.

  IF sy-tcode = lc_fbl1n.
    LOOP AT ct_items ASSIGNING FIELD-SYMBOL(<fs_items>).
      IF NOT <fs_items>-konto IS INITIAL.
        SELECT CONCAT( adrc~name1, adrc~name2 )
          FROM adrc
          INNER JOIN lfa1 ON adrc~addrnumber = lfa1~adrnr
          WHERE lfa1~lifnr = @<fs_items>-konto
          INTO @<fs_items>-zvend_name UP TO 1 ROWS.
        ENDSELECT.
      ENDIF.
      SELECT SINGLE txt50 FROM skat INTO <fs_items>-zhkontnm
        WHERE ktopl = '2000' AND saknr = <fs_items>-hkont AND spras = 'E'.
    ENDLOOP.
  ENDIF.

  IF sy-tcode = lc_fbl5n.
    LOOP AT ct_items ASSIGNING <fs_items>.
      IF NOT <fs_items>-konto IS INITIAL.
        SELECT CONCAT( adrc~name1, adrc~name2 )
          FROM adrc
          INNER JOIN kna1 ON adrc~addrnumber = kna1~adrnr
          WHERE kna1~kunnr = @<fs_items>-konto
          INTO @<fs_items>-zcust_name UP TO 1 ROWS.
        ENDSELECT.
      ENDIF.
      SELECT SINGLE txt50 FROM skat INTO <fs_items>-zhkontnm
        WHERE ktopl = '2000' AND saknr = <fs_items>-hkont AND spras = 'E'.
    ENDLOOP.
  ENDIF.

  IF sy-tcode = lc_fbl3n.
    LOOP AT ct_items ASSIGNING <fs_items>.
      SELECT SINGLE txt50 FROM skat INTO <fs_items>-zhkontnm
        WHERE ktopl = '2000' AND saknr = <fs_items>-hkont AND spras = 'E'.
      IF NOT <fs_items>-konto IS INITIAL.
        SELECT SINGLE txt50 FROM skat INTO <fs_items>-zsaknrnm
          WHERE ktopl = '2000' AND saknr = <fs_items>-konto AND spras = 'E'.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDMETHOD.
  

Best Practices

  • Always use append structure instead of modifying standard objects.
  • Run RFPOSXEXTEND after appending fields to regenerate structures.
  • Optimize SELECT queries to avoid performance bottlenecks.
  • Use SPRSL for language-dependent texts.

Conclusion

By appending structure RFPOSX, running program RFPOSXEXTEND, and implementing BADI FI_ITEMS_CH_DATA, you can successfully add custom fields to reports FBL1N, FBL3N, and FBL5N. This enhancement ensures upgrade safety, flexibility, and fulfills business requirements effectively.

No comments:

Post a Comment

ABAP CDS View Part 10 : Authorization & DCL untuk ABAP CDS

Authorization & DCL di ABAP CDS | Panduan Lengkap (PFCG, @AccessControl, DCL) Authorization & DCL untuk ABAP CDS — Pandua...