INSERT - Insert a Program

Basic form

INSERT REPORT prog FROM itab.

Extras:

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

Effect

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.

Example

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.

Notes

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Unicode Changes.

Addition 1

... EXTENSION TYPE exttype

Effect

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.

Note

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.


Addition 2

... APPENDAGE TYPE apptype

Effect

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.

Note

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.


Addition 3

... STATE state

Effect

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.

Note

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.


Addition 4

... KEEPING DIRECTORY ENTRY

Effect

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.

Example

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.

Notes

If you create a new program, the addition has no effect.

Addition 5

... DIRECTORY ENTRY trdir

Effect

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.

Example

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).

Note

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.


Addition 6

... UNICODE ENABLING uc

Effect

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.

Example

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 ' '.

Addition 7

... FIXED-POINT ARITHMETIC fp

Effect

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.

Example

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.

Addition 8

... PROGRAM TYPE pt

Effect

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.

Example

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'.

Addition 9

... MAXIMUM WIDTH INTO w

Effect

After the program is inserted successfully into the library, w contains the length of the longest line of the source text, measured in characters.

Exceptions



Catchable Exceptions

CX_SY_WRITE_SRC_LINE_TOO_LONG

Non-Catchable Exceptions

Related

DELETE REPORT, READ REPORT, SYNTAX-CHECK, GENERATE REPORT

Additional help

Creating Programs Dynamically