Register Login

Interactive reporting (Drill down reporting ) - example

Updated May 20, 2018

In this example you have a mainreport REPORT1. From REPORT1 you
can drill down to REPORT2 and from REPORT2 you can drill down
to REPORT3.

Tip: Use hotspots to fire the AT LINE-SELECTION event.
When the cursor is over the hotspot, it cganges to a hand,
and you just have to click on the hostspot, instead of
double clicking.

Note: To see how to recognize if the user has selected a valid line, take a look at
How to check if a valid line is selected before drill down.


START-OF-SELECTION.
* Read data for REPORT1 into itab1

END-OF-SELECTION.
PERFORM write_report1.

TOP-OF-PAGE.
* Write list header for REPORT1

AT USER-COMMAND.
* Respond when the user presses a function key
CASE sy-ucomm.
WHEN 'REPORT2'.
PERFORM write_reprt2.
WHEN 'REPORT3'.
PERFORM write_reprt3.
ENDCASE.


AT LINE-SELECTION.
* Istead of pressing a button can perform the same actions
* as i AT USER-COMMAND, by double clicking a line
* sy-lsind contains the list level.
* Each time an interactive list event occurs, sy-lsind is
* automatically increased by 1.
* At REPORT1 sy-lsin = 0

CASE sy-lsind.

WHEN 1.
PERFORM write_reprt2.
WHEN 2.
PERFORM write_reprt3.
ENDCASE.

TOP-OF-PAGE.
* Write report header for report1 ( sy-lsind = 0 )

TOP-OF-PAGE DURING LINE-SELECTION.
* Write report header for sub reports
CASE sy-lsind.
WHEN 1.
* Write report header for REPORT2.
WHEN 2.

* Write report header for REPORT3.
ENDCASE.


FORM WRITE_REPORT1.
LOOP at itab1.
* write report1.......

* Hide keyfields used for the select statement of
* report2
HIDE: itab1_year, itab1_month.

ENDLOOP.
ENDFORM.

FORM WRITE_REPORT2.

SELECT * FROM databasetable2 into itab2
WHERE year = itab1_year AND
month = itab1_month.

LOOP at itab2.

* write report2 .......

* Hide keyfields used for the select statement of
* report3
HIDE: itab2_carrid.

ENDLOOP.
ENDFORM.


FORM WRITE_REPORT3.

SELECT * FROM databasetable3 into itab3
WHERE carrid = itab2_carrid.

LOOP at itab3.

* write report3 .......

* No need to hide keyfields, as further drill down is not
* possible

ENDLOOP.
ENDFORM.


×