READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid].
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
is deleted. If the program cannot be loaded, the content of
itab remains unchanged. By default, the source text of the active version of the program is read.
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.
|0 (means:||The program was imported.|
|4 (means:||The specified program was not found in the repository.|
|8 (means:||The specified program is a system program protected against reads.|
A precise working knowledge of the programs' structures and names is vital if the statement
READ REPORTis 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
After a program is imported into an internal table
source, a dedicated line
is replaced by different source code from another internal table
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 ...
... MAXIMUM WIDTH INTO wid
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
The following program determines the widest and narrowest source code in the programs of a package saved in the database table TADIR
SELECT obj_name AS name FROM tadir WHERE pgmid = 'R3TR' AND object = 'PROG' AND devclass = 'SABAPDEMOS' INTO TABLE @DATA(programs). DATA(max) = 0. DATA(min) = 1000000. DATA(width) = 0. DATA source TYPE TABLE OF string WITH EMPTY KEY. LOOP AT programs ASSIGNING FIELD-SYMBOL(<prog>). READ REPORT <prog> INTO source MAXIMUM WIDTH INTO width. IF width > max. max = width. DATA(max_name) = <prog>. ENDIF. IF width < min AND width <> 0. min = width. DATA(min_name) = <prog>. ENDIF. ENDLOOP.
Cause: At least one line of the source code is longer than the rows of the internal table