In this document I am going to show how to create dynamic reports in ABAP from another report and how to call those dynamic report.
First create a report with some name say ZDYNAMIC_REPORT_GEN.
Write the following code in this report.
1. First create and internal table that holds the statements that to be added into dynamic report.
DATA: lt_code TYPE TABLE OF rssource-line.
2. Now append the lines that you want to insert into report in lt_code internal table:
> Append the first line that reach report contains.
APPEND 'REPORT ZDYNAMIC_REPORT.' TO lt_code.
> Create an input parameters
APPEND 'PARAMETERS: lv_name TYPE string.' TO lt_code.
> Now display the name in output.
APPEND 'WRITE: /''Your name is : '', lv_name.' TO lt_code.
> Now insert the internal table containing lines of codes into dynamic report created through this program.
INSERT REPORT 'ZDYNAMIC_REPORT' FROM lt_code.
> Now the report is ready for execution, so call the report for execution using the dynamic report name
SUBMIT zdynamic_report VIA SELECTION-SCREEN AND RETURN.
3. Thats it. Now execute the report ZDYNAMIC_REPORT_GEN, it asks for the name, enter some name and execute. Your name will be printed in the output screen.
This is how we can create dynamic reports. It is possible to write any set of code using dynamic report.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.