ABAP Keyword Documentation → ABAP - Reference → program editing → Dynamic Program Editing → Source Code
READ REPORT
Other versions: 7.31 | 7.40 | 7.54
Syntax
READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid].
Addition
Effect
This statement reads the source code of the program specified in prog
from the
repository and copies its
lines into the internal table itab
. The previous content of itab
is deleted. If the program cannot be loaded, the content of itab
remains unchanged.
prog
expects a
flat character-like data object, which contains the name of the program to be read; the name is not case-sensitive. The internal table itab
must be a
standard table without
secondary table keys
with a character-like 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 raise a catchable exception. In
the case of the row type string
, the length of each row is dictated by the length of the imported program line. An empty program line produces an empty string.
System Fields
sy-subrc | Meaning |
---|---|
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. |
Notes
-
A precise working knowledge of the programs' structures and names is vital if the statement
READ REPORT
is used for programs organized in a master program and with include programs when they were created in ABAP Workbench. -
The names of the master programs for class pools and
function groups do not
match the names of the global class or function group (see statements
CLASS-POOL and
FUNCTION-POOL
).
Addition
... MAXIMUM WIDTH INTO wid
Effect
If the addition MAXIMUM WIDTH
is used, the number of characters of the longest
imported source code line is assigned to the variable wid
(expects the data type i
).
Example
After a program is imported into an internal table source
, a dedicated line
is replaced by different source code from another internal table insertion
.
After a syntax check, a subroutine pool is generated from the modified program. The required security checks are indicated by comments.
DATA:
template TYPE c LENGTH 30,
generated TYPE c LENGTH 30,
source TYPE TABLE OF string,
insertion TYPE TABLE OF string,
idx TYPE i,
mess TYPE string,
lin TYPE i,
wrd TYPE string.
template = '...'.
"Authority checks
...
READ REPORT template INTO source.
IF sy-subrc <> 0.
RETURN.
ENDIF.
"Fill insertion
...
FIND '* insertion' IN TABLE source MATCH LINE idx.
DELETE source INDEX idx.
INSERT LINES OF insertion INTO source INDEX idx.
SYNTAX-CHECK FOR source MESSAGE mess LINE lin WORD wrd
PROGRAM template.
...
"Security checks
...
GENERATE SUBROUTINE POOL source NAME generated.
"Execution
...
Example
See also Program Generation.
Exceptions
Catchable Exceptions
CX_SY_READ_SRC_LINE_TOO_LONG
-
Cause: At least one line of the source code is longer than the rows of the internal table
itab
.
Runtime Error:READ_REPORT_LINE_TOO_LONG