You can add ABAP Code in SAP Query report to enhance your report, Open your infoset via tcode SQ02 and click Extras button toolbar.
You can choose any event depend on your requirement to add your ABAP Code.
These are the explanation for Event in listbox Code Section :
- DATA Section :
Global Data Declaration will go under this Event.
- INITIALIZATION Section :
As the name suggests it is used to initialize the variable with initial values.
- AT SELECTION-SCREEN OUTPUT :
This event is triggered before the display of selection screen.
- START-OF-SELECTION :
This event is triggered before starting any database accesses. Usually Data fetching logic goes under it.
- RECORD Processing :
Corresponds to the GET coding with Info-sets without a logical database. As there is no hierarchical view of the data, all the join tables are addressed.
- END-OF-SELECTION :
The END-OF-SELECTION code consists of two parts (Before list output and After list output). The first part is processed before the list is output and the second part afterwards. It is the right section to do aggregated calculations and actions that can only be done when data from all the selected records has been extracted.
For Example Case :
Add Variable Declaration in DATA code section event.
1 2 3 4 |
DATA : gv_str TYPE string. FIELD-SYMBOLS : <gi00> TYPE table, <gw00> TYPE any. |
<GI00> is the Internal table which contain result data that to be displayed on report. you can modify this internal table.
END-OF-SELECTION ( After List )
1 2 3 4 5 6 7 8 9 10 11 12 13 |
gv_str = '%G00[]'. ASSIGN (gv_str) TO <gi00>. LOOP AT <gi00> ASSIGNING <gw00>. ASSIGN COMPONENT 'MSEG-BWART' OF STRUCTURE <gw00> TO <fv_any>. IF <fv_any> IS NOT INITIAL. SELECT SINGLE shkzg INTO lv_shkzg FROM t156 WHERE bwart = <fv_any>. IF lv_shkzg = 'H'. ASSIGN COMPONENT 'MSEG-DMBTR' OF STRUCTURE <gw00> TO <fv_any>. <fv_any> = <fv_any> * -1. ENDIF. ENDIF. ENDLOOP. |