Add Custom File to Tcode AR01 in SAP ABAP
A step-by-step guide to extend AR01 functionality with custom fields and logic in SAP ABAP.
Introduction
In this tutorial, we will explore how to add a custom file in tcode AR01 by
enhancing the program RABEST_ALV01
. The approach involves using the
main structure FIAA_SALVTAB_RABEST
and the include structure
CI_REPRABEST
.
Main Structure and Include
- Main Structure: FIAA_SALVTAB_RABEST
- Include Structure: CI_REPRABEST
Custom Code Implementation
Below is the ABAP code snippet inserted into the program
RABEST_ALV01
to fetch additional information such as
cost center, profit center, asset class description, and long text:
FIELD-SYMBOLS: <ANLN1> TYPE ANY.
FIELD-SYMBOLS: <ANLKL> TYPE ANY.
FIELD-SYMBOLS: <KOSTL> TYPE ANY.
FIELD-SYMBOLS: <PRCTR> TYPE ANY.
FIELD-SYMBOLS: <LTEXT> TYPE ANY.
FIELD-SYMBOLS: <TXK50> TYPE ANY.
LOOP AT <itab_data>[] ASSIGNING FIELD-SYMBOL(<fs_csfield>).
ASSIGN COMPONENT 'KOSTL' OF STRUCTURE <fs_csfield> TO <KOSTL>.
ASSIGN COMPONENT 'PRCTR' OF STRUCTURE <fs_csfield> TO <PRCTR>.
ASSIGN COMPONENT 'ANLKL' OF STRUCTURE <fs_csfield> TO <ANLKL>.
ASSIGN COMPONENT 'TXK50' OF STRUCTURE <fs_csfield> TO <TXK50>.
ASSIGN COMPONENT 'LTEXT' OF STRUCTURE <fs_csfield> TO <LTEXT>.
SELECT SINGLE PRCTR FROM CSKS
INTO <PRCTR> WHERE KOSTL = <KOSTL>.
SELECT SINGLE LTEXT FROM CEPCT
INTO <LTEXT> WHERE PRCTR = <PRCTR> AND SPRAS = sy-langu.
SELECT SINGLE TXK50 FROM ANKT
INTO <TXK50> WHERE SPRAS = sy-langu AND ANLKL = <ANLKL>.
ENDLOOP.
Conclusion
By adding the above logic into RABEST_ALV01
, you can extend the AR01
report to include additional information like cost center descriptions, profit
center texts, and asset class details. This approach provides flexibility for
financial reporting in SAP.