INSERT REPORT prog FROM itab.
1. ... EXTENSION
TYPE exttype
2. ...
APPENDAGE TYPE apptype
3.
... STATE state
4. ...
KEEPING DIRECTORY ENTRY
5.
... DIRECTORY ENTRY trdir
6.
... UNICODE ENABLING uc
7.
... FIXED-POINT ARITHMETIC fp
8.
... PROGRAM TYPE pt
9. ... MAXIMUM WIDTH INTO w
Inserts program prog into the library or overwrites it
if it already exists. The source text is taken from the internal table itab.
The line type of the table must be character-like, that is, STRING
or C. If the line type has a fixed length, the length
should at least be 72. The program attributes (such as date, time, last changed by) are set by the system.
If you create a new program, the fixed point arithmetic indicator is set, and the program type is
set to '1' (executable program). If the program already
exists, these attributes are retained.
If you do not specify the DIRECTORY
ENTRY addition or the UNICODE ENABLING addition,
the following rule applies: If the caller has enabled the Unicode check, the check is also enabled in
the program prog. If the program prog already exists and its Unicode check is enabled, the check remains enabled.
TYPES: line(72) type c.
DATA: itab TYPE STANDARD TABLE OF line.
APPEND 'report test.' TO itab.
APPEND 'write: ''Hello world!''.' TO itab.
INSERT REPORT 'test_report' FROM itab.
System values
sy-subrc=0
The program was inserted successfully.
sy-subrc = 4
An error occurred during insertion.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Unicode Changes.
... EXTENSION TYPE exttype
Suffix 1 (characters 31-35) for program prog is checked
against exttype. exttype
must correspond to a constant from the type group SREXT. Suffix 2 (characters 36-40) may only contain spaces.
This addition is for internal use only.
Changes and further developments, which may be incompatible, are possible at any time, and without notice or warning.
... APPENDAGE TYPE apptype
Suffix 2 (characters 36-40) of program prog are checked
against apptype. apptype
must correspond to a constant from type group SREXT. The
beginning of suffix 1 (character 31 onwards), must correspond to a constant from type group SREXT.
This addition is for internal use only.
Changes and further developments, which may be incompatible, are possible at any time, and without notice or warning.
... STATE state
Determines the state in which program prog is saved in
the library.
state may be A
(for active) or I (for inactive).
"Inactive" programs are only visible to the person currently working on them. All other users work with the "active" version of the program.
In the ABAP Workbench, you can define a set of programs being edited for each user. These programs are then saved as "inactive" until they are activated. If you omit the STATE addition, the system automatically uses the "inactive" state for these programs, and "active" for all others.
This set is only available for a short within the ABAP development environment, which guarantees that
all other programs that use the INSERT REPORT command with the STATE always insert "active" reports.
This addition is for internal use only.
Changes and further developments, which may be incompatible, are possible at any time, and without notice or warning.
... KEEPING DIRECTORY ENTRY
If a program is overwritten, all attributes (except the time stamp, the version number and the user who last changed it) are retained, including the Unicode check indicator.
TYPES: line(72) TYPE C.
DATA: itab TYPE STANDARD TABLE OF line.
APPEND 'report test.' TO itab.
INSERT REPORT 'test_report' FROM itab KEEPING DIRECTORY ENTRY.
If you create a new program, the addition has no effect.
... DIRECTORY ENTRY trdir
The program attributes are taken from the directory entry trdir.
trdir must be of the type TRDIR.
The components CNAM, CDAT,
VERN, SDATE, and STIME of the directory entry are set automatically.
TYPES: line(72).
DATA: itab TYPE STANDARD TABLE OF LINE,
trdir
TYPE TRDIR.
APPEND 'report test.' TO itab.
SELECT SINGLE * FROM TRDIR INTO trdir WHERE name
= 'old_report'.
IF sy-subrc <> 0.
WRITE: / 'Program ''old_report'' does not exist.'.
ELSE.
INSERT REPORT 'new_report' FROM itab DIRECTORY ENTRY trdir.
ENDIF.
A program 'new_report' with the attributes of the program 'old_report' is created (or overwritten).
This addition is for internal use only.
Changes and further developments, which may be incompatible, are possible at any time, and without notice or warning.
... UNICODE ENABLING uc
The Unicode check indicator is set to the value of the field uc.
uc must be a C field of length 1. The values 'X'
(Unicode check;
ABAP_ON) and ' ' (no Unicode check; ABAP_OFF) are allowed.
TYPES: line(72) TYPE C.
DATA: itab TYPE STANDARD TABLE OF line.
APPEND 'report test.' TO itab.
APPEND 'data: xf(10) TYPE X.' to itab.
APPEND 'WRITE ''Hallo'' TO xf.' TO itab.
INSERT REPORT 'non_unicode_report' FROM itab UNICODE ENABLING ' '.
... FIXED-POINT ARITHMETIC fp
The indicator controlling the fixed point arithmetic is set to the value of the field
fp. The values 'X'
(fixed point arithmetic;
ABAP_ON) and ' ' (no fixed point arithmetic; ABAP_OFF) are allowed.
TYPE-POOLS ABAP.
TYPES: line(72) TYPE C.
DATA: itab TYPE STANDARD TABLE OF line.
APPEND
'report test.' TO itab.
APPEND 'DATA: p(5) TYPE P DECIMALS 2 VALUE 10.' TO itab.
APPEND 'WRITE p.' TO itab.
INSERT REPORT 'test_report' FROM itab FIXED-POINT ARITHMETIC ABAP_OFF.
... PROGRAM TYPE pt
The program type of the program prog is set to the value
of the field
pt. The values '1'
(executable programs),
'I' (includes), 'S'
(subroutine pools)
'M' (module pools), 'F'
(function groups), 'J' (interface pools), and 'K' (class pools) are allowed.
TYPES: line(72) TYPE C.
DATA: itab TYPE STANDARD TABLE OF line.
APPEND 'FORM form1.' TO itab.
APPEND '* ... do something useful ...' TO itab.
APPEND 'ENDFORM.' to itab.
INSERT REPORT 'test_report' FROM itab PROGRAM TYPE 'S'.
... MAXIMUM WIDTH INTO w
After the program is inserted successfully into the library, w contains the length of the longest line of the source text, measured in characters.
Catchable Exceptions
CX_SY_WRITE_SRC_LINE_TOO_LONG
Non-Catchable Exceptions
DELETE REPORT, READ
REPORT, SYNTAX-CHECK,
GENERATE REPORT
Creating Programs Dynamically