16.6    Dynamic Program Generation

In addition to all the dynamic programming concepts discussed in this chapter, which can be used within an ABAP program, we can also generate ABAP programs dynamically. Generating a program dynamically should be used as a last resort if other dynamic programming techniques do not satisfy your requirements.

Dynamic program generation is for expert programmers and should be used with caution; it can cause serious problems if you don’t know what you’re doing. The downsides of programs generated dynamically are that these programs can’t be tested like regular programs and can involve serious security risks.

There are two types of programs that can be generated dynamically:

When generating programs dynamically, it’s a good idea to create a program statically and use that program as a template to generate new programs. You can use the READ REPORT INTO itab statement to read the source code of an existing program, which can then be used as a template to generate a new program.