How to check if a valid line is selected before drill down.
There are several ways to do this. Below are two examples:
1. Clearing and testing for initial values of
keyfields in the main report.
2. Using sy-lilli to check the number of the
selected line
1. Clearing and testing for initial values of
keyfields in the main report.
END-OF-SELECTION.
* Clears the keyfields in the internal table of the main report, that are used to lookup data for the sub report.
CLEAR itab-blart.
AT LINE-SELECTION.
* Check if a valid line is selected
CHECK NOT itab-blart IS INITIAL.
* Write subreport
PERFORM xxxx
* Clear keyfield from the main report
CLEAR itab-blart.
2. Using sy-lilli to check the number of the selected line
SY-LILLI contains the absolute number of the line
from which the event was triggered.
If you know how many lines the heading of the
reports use, it's easy to check if a valid line is selected.
In this example the report heading uses 4 lines. It's the possible to check if the number of the selected line is greater than 4:
at line-selection.
CHECK SY-LILLI > 4.
PERFORM write_subreport.
Note: This will not check if an invalid line selection have been made in the bottom of the report.
*******************************************************
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.
* Instead 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.
Back to ABAP Menu:
ABAP Example Hints and Tips
Return to :-
SAP Hints and Tips on Configuration
and ABAP/4 Programming
(c) www.sap-basis-abap.com All material on this site is
Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies. The site www.sap-basis-abap.com is in no way affiliated
with SAP AG.
Any unauthorised copying or mirroring is prohibited.