READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid].
... MAXIMUM WIDTH INTO wid
This statement reads the source text of the program specified in prog from the Repository and copies its row into the internal table itab. The previous content of itab is deleted. If the program cannot be loaded, the content of itab remains unchanged.
For prog, you have to specify a
flat character-type data object that contains
the name of the program to be read (upper or lower case is irrelevant). The internal table itab must be a
standard table with character-type
(before release 6.10 flat) row type. When the row length of the internal table is fixed, it must be
long enough for the longest program line. Program lines that are too long, are cut off to the right ; since release 6.10, a catchable exception occurs.
System fields
sy-subrc | Relevance |
0 | The program was imported. |
4 | The specified program was not found in the repository. |
8 | The specified program is a system program protected against read access. |
... MAXIMUM WIDTH INTO wid
If you use the addition MAXIMUM WIDTH, the number of characters of the longest imported source text row is assigned to the variable wid (expects the data type i, as of release 6.10) .
After import of a program into the internal table itab, further lines are attached to the source text. After that, a temporary sub-routine-pool is generated from the changed program and one of its sub-programs called.
DATA prog TYPE c LENGTH 30.
DATA itab TYPE TABLE OF string.
prog = '...'.
READ REPORT prog INTO itab.
IF sy-subrc = 0.
APPEND 'FORM subr.' TO itab.
...
APPEND 'PERFORM ...' TO itab.
APPEND 'ENDFORM.' TO itab.
GENERATE SUBROUTINE POOL itab NAME prog.
PERFORM ('SUBR') IN PROGRAM (prog).
ENDIF.
Catchable Exceptions
CX_SY_READ_SRC_LINE_TOO_LONG