Entering content frameChanging Existing Programs Dynamically Locate the document in its SAP Library structure

Since you cannot check the syntax when a program is generated dynamically, you may want to have a set of syntactically correct structures in the system that you can load into an internal table, modify, and write back to the system. Such structures can consist of reports, subroutines, include programs, or modules from the module pool. Use the following syntax:

Syntax

READ REPORT <prog> INTO <itab>.

This statement reads program <prog> that is stored in the library into internal table <itab>.

Now, you can modify the internal table and create a new program as described in Creating a New Program Dynamically.

Example

Assume the following simple report:

REPORT ZSTRUC1.

WRITE / 'Hello, I am a little structure!'.

and the following lines of another program:

DATA CODE(72) OCCURS 10.

READ REPORT 'ZSTRUC1' INTO CODE.

APPEND 'SKIP.' TO CODE.
APPEND 'WRITE / ''and I am a dynamic extension!''.' TO CODE.

INSERT REPORT 'ZDYN2' FROM CODE.

In this example, the existing executable program (report) ZSTRUC1 is read into internal table CODE, it is extended by two additional lines and written to program ZDYN2. After the ABAP Editor for ZDYN2 has been called, the screen looks as follows:

This graphic is explained in the accompanying text

 

 

 

 

Leaving content frame