Dynamic program generation
The ABAP language also allows the creation of ABAP programs at runtime. An INSERT REPORT
statement may be used for creating a new program specified by the a name in the statement. Dynamic program generation should only be used when there is no alternate option.
Also, you may generate a subroutine pool using a GENERATE
subroutine pool statement. A subroutine pool is generated, and is of a temporary nature. The subroutines in the pool may be called from within the generation program.
On the other hand, the programs created via the INSERT REPORT
statement are permanent and overwrite any prior existing programs with the same name. Within the generation program, the new program may be called via a SUBMIT
statement.
Getting ready
We will use the concepts of dynamic program generation in order to show how a simple requirement may be solved. We will take as input two program names. The code of the first program will be read and then any comments or unwanted blank lines will...