INSERT REPORT
Short Reference
ABAP Syntax INSERT REPORT prog FROM itab
[MAXIMUM WIDTH INTO wid]
{ [KEEPING DIRECTORY ENTRY]
| { [PROGRAM TYPE pt]
[FIXED-POINT ARITHMETIC fp]
[UNICODE ENABLING uc] }
| [DIRECTORY ENTRY dir] }.
ABAP_ADDITIONS:
1 ... MAXIMUM WIDTH INTO wid
2 ... KEEPING DIRECTORY ENTRY
3 ... PROGRAM TYPE pt
4 ... FIXED-POINT ARITHMETIC fp
5 ... UNICODE ENABLING uc
6 ... DIRECTORY ENTRY dir
What does it do? This statement places the contents of itab as
source code into the ABAP program specified in prog in the
repository . If a program with the
specified name already exists, its source code is overwritten. Otherwise
a new program with the name specified in prog and the source code
from itab is created in the repository.
The additions for specifying the
program attributes create the program attributes in the system table
TRDIR .
If none of the additions are specified, the following default values
are set when a new program is created:
The original language is set to the system language stored in the
profile parameter
zcsa/system_language .
The creation date and the date of last change, along with the
corresponding time, are set to the current values.
The program author last changed by attributes are set to the current
user.
The program status is set to active. The program is compiled when it
is first executed.
The program type is set to
executable program .
The application is set to the value of the current program.
No logical database is connected
with the program.
Fixed point arithmetic is activated.
The setting for the Unicode check is
adopted from the current program.
If none of the additions are specified, an existing programs
attributes remain intact if it is overwritten, but with the following e
xceptions:
The date and time of the last change are set to the current value.
The last changed by attribute is set to the current user.
The version number is increased by one.
The setting for the Unicode check is activated if the current program
is a Unicode program and a
non-Unicode program is
overwritten. The setting remains active if the current program is a
non-Unicode program and a Unicode program is overwritten.
For itab , only a standard table without
secondary table keys is
permitted. The row type of itab must be character-like. A source
code line in itab can contain a maximum of 255 characters (if the
row type has a fixed length, trailing blanks are ignored). prog
must be a character-like flat data object, which can contain no more
than 30 characters, and the content of which is not case-sensitive.
System Fields
sy-subrc Meaning
0The program specified in prog was successfully created or
overwritten.
4An error occurred when creating or overwriting the program
specified in prog .
See ABAP Command Injections .
Latest notes: The INSERT REPORT statement must be used with
extreme caution, because it can completely overwrite existing programs
without warning. Any inadvertent overwriting can be prevented by
checking whether the specified name already exists in the NAME
column of the system table TRDIR .
If INSERT REPORT is used to create a new program, this program
is not assigned to a package, so that it is not connected to the Change
and Transport System. The program must either be assigned to a package
in ABAP Workbench or it is only suitable for temporary tasks in the
current system.
It is vital to have a precise working knowledge of the programs'
structures and names if using the statement INSERT REPORT for
programs organized in a master program
and using include programs (if
created in ABAP Workbench).
The program name that is created
should comply with the naming conventions of
ABAP Workbench if it is to be
processed using the Workbench's tools.
INSERT REPORT should be used in application programs in
exceptional cases only. ABAP provides many other means of dynamic
programming, which generally make creating source code dynamically
unnecessary (see the list in dynamic
program processing ).
ABAP_ADDITION_1 ... MAXIMUM WIDTH INTO wid
What does it do? If the addition MAXIMUM WIDTH is used, the number
of characters of the longest source code line in itab is assigned
to the variable wid , which must have data type i .
ABAP_ADDITION_2 ... KEEPING DIRECTORY ENTRY
What does it do? This addition is only effective when a program is
overwritten. The statement behaves as if no additions are specified (see
above), with the exception that the setting for the
Unicode check remains intact in the
overwritten program.
Latest notes: With this setting, the source code of
non-Unicode programs can be
overwritten from Unicode programs
without the Unicode check being implicitly activated.
ABAP_ADDITION_3 ... PROGRAM TYPE pt
What does it do? This addition specifies the attribute
program type for the created or
overwritten program in accordance with the setting in pt . pt
must be a data object of the data type c and length 1
containing the ID of a program type. The following table shows the
case-sensitive IDs of all ABAP program types.
ID Program Type
1 Executable program
F Function group or function pool
I Include program
J Interface pool
K Class pool
M Module pool
S Subroutine pool
T Type group or type pool
ABAP_ADDITION_4 ... FIXED-POINT ARITHMETIC fp
What does it do? This addition specifies the attribute
fixed point arithmetic for the
created or overwritten program in accordance with the content of
fp
. fp must be a data object of the data type c and
length 1 that has the value "X" or " ". The value "X" sets the fixed
point arithmetic attribute, while the value " " deactivates it.
ABAP_ADDITION_5 ... UNICODE ENABLING uc
What does it do? This addition specifies the setting of the
Unicode check for the created or
overwritten program in accordance with the content of uc . uc
must be a data object of the data type c and length 1 that
has the value "X" or " ". The value "X" activates the Unicode check
while the value " " deactivates it.
Latest notes: With this addition, the source code of non-Unicode programs
can be overwritten from Unicode programs without the Unicode check being
implicitly activated. Unicode programs can also be created from
non-Unicode programs.
ABAP_ADDITION_6 ... DIRECTORY ENTRY dir
What does it do? This addition specifies the
program attributes for the created
or overwritten program in accordance with the content of dir .
dir must be structure of the data type
TRDIR from ABAP Dictionary. The
required program attributes can be specified in the components of this
structure. Invalid contents result in invalid program attributes. All
program attributes are obtained from dir , with the exception of
the creation and change dates, and the corresponding times, program
authors or last changed by attributes, and the version numbers. The
latter are set to the same values as if no specification had been made.
Latest notes: When using the DIRECTORY ENTRY addition, it is
strongly recommended that the contents of dir are set only by
reading the attributes of an existing program from the database table
TRDIR .
Example ABAP Coding Partial conversion of a program to
Unicode . A non-Unicode program is imported
and, by means of an example, the DESCRIBE FIELD statement is
converted to the syntax for Unicode
systems . The source code of the program is then overwritten with the
modified source code and the Unicode check is activated in the program
attributes.
DATA: itab TYPE TABLE OF string,
prog TYPE sy-repid,
uc TYPE trdir-uccheck.
FIELD-SYMBOLS <(><<)>line> TYPE string.
prog = ...
SELECT SINGLE uccheck
FROM trdir
INTO (uc)
WHERE name = prog AND
uccheck = ' '.
IF sy-subrc = 0.
READ REPORT prog INTO itab.
LOOP AT itab ASSIGNING <(><<)>line>.
TRANSLATE <(><<)>line> TO UPPER CASE.
IF <(><<)>line> CS 'DESCRIBE FIELD' AND
<(><<)>line> CS 'LENGTH' AND
<(><<)>line> NS 'MODE'.
REPLACE '.' IN <(><<)>line> WITH ' IN CHARACTER MODE.'.
ENDIF.
...
ENDLOOP.
SYNTAX-CHECK FOR itab ...
IF sy-subrc = 0.
INSERT REPORT prog FROM itab UNICODE ENABLING 'X'.
ENDIF.
ENDIF.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved