Copyright 2024 - BV TallVision IT

Ever wondered how transaction SE16 builds it's selection screen and report ? Generate a report "on the fly".

It's normally not necessary, but in some cases a report can be generated from a report. Basically what SAP does too sometimes is generate the source (ABAP) code for a report and submit it afterwards. An example of that would be the data browser which displays the contents of tables. Here's how you could basically do that:

READ REPORT 'ZZTMP###' INTO lt_TEMP_SOURCE.  "Check existance
IF SY-SUBRC > 0.
  INSERT REPORT 'ZZTMP###' FROM lt_SOURCE_CODE.
ELSE.
  MESSAGE 'Error: Source code exists' TYPE 'E'.
ENDIF.

SUBMIT ZZTMP### AND RETURN.
DELETE REPORT 'ZZTMP###'.

Now just make sure you're complete ABAP source is held on the table lt_SOURCE_CODE.

If you want to do more than just retrieving ABAP source, have a look at the following statements as well:

  • INSERT REPORT prog FROM itab saves the source code that is contained in table itab into a (new) report. prog would be the new report name.
  • SUBMIT (prog) can be used to execute the just saved code, note that the program name prog is in between brackets, to make the submit statement start the program that is contained in variable prog rather than submitting program "prog".
  • DELETE REPORT prog to erase the temporary program again. Have a look at the help text for this statement, SAP has some warnings about the usage of this statement.

The statements above allow you to generate a report based on customised settings, the same way SAP's data browser works. Be careful with this kind of reporting, especially the simple fact that it is about a multi user system, can make things confusing.

For the more advanced retrieval of ABAP source, have a look at SAP's SCAN statement !!