ABAP - Keyword Documentation →  ABAP - Reference →  program editing →  Dynamic Program Editing →  Source Code → 

INSERT REPORT

Quick Reference

Syntax

INSERT REPORT prog FROM itab
              [MAXIMUM WIDTH INTO wid]
              { [KEEPING DIRECTORY ENTRY]
              | { [PROGRAM TYPE pt]
                  [FIXED-POINT ARITHMETIC fp]
                  [VERSION vs] }
              | [DIRECTORY ENTRY dir] }.

Extras:

1. ... MAXIMUM WIDTH INTO wid

2. ... KEEPING DIRECTORY ENTRY

3. ... PROGRAM TYPE pt

4. ... FIXED-POINT ARITHMETIC fp

5. ... VERSION vs

6. ... DIRECTORY ENTRY dir

Effect

This statement passes the content of itab to the ABAP program specified in prog in the repository as source code. 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:

If none of the additions are specified, an existing programs attributes remain intact if it is overwritten, but with the following exceptions:

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
0 The program specified in prog was successfully created or overwritten.
4 An error occurred when creating or overwriting the program specified in prog.

Security Note

If used wrongly, dynamic programming techniques can present a serious security risk. Any dynamic content that is passed to a program from the outside must be checked thoroughly or escaped before being used in dynamic statements. This can be done using the system class CL_ABAP_DYN_PRG or the predefined function escape. See ABAP Command Injections.

Notes

Addition 1

... MAXIMUM WIDTH INTO wid

Effect

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.

Addition 2

... KEEPING DIRECTORY ENTRY

Effect

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 ABAP language version remains intact in the overwritten program.

Addition 3

... PROGRAM TYPE pt

Effect

This addition specifies the attribute program type for the new 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

Addition 4

... FIXED-POINT ARITHMETIC fp

Effect

This addition specifies the attribute fixed point arithmetic for the new 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.

Addition 5

... VERSION vs

Effect

This addition specifies the ABAP language version for the new or overwritten program in accordance with the content of vs. vs must be a data object of the data type c and length 1. It can have the following values for the version ID:

vs ABAP language version Meaning
X Standard ABAP (Unicode) basic version, Unicode check activated
2 ABAP for Key Users Restricted language scope for enhancements by key users
3 Static ABAP with restricted object use Restricted use of external repository objects and dynamic language elements are not permitted
- Obsolete ABAP (Non-Unicode) obsolete, Unicode check deactivated

Technically, the addition supplies the column UCCHECK of database table TRDIR. You should not specify values other than the ones shown here. If incorrect values are specified as a literal and this is known statically, a syntax error occurs. However, an unknown value is always stored in database table TRDIR. Values not contained in the above table act like a version that does not support any language elements.

Note

An obsolete addition UNICODE ENABLING has the same significance as VERSION.

Addition 6

... DIRECTORY ENTRY dir

Effect

This addition specifies the program attributes for the new 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 content produces 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.

Note

When using the addition DIRECTORY ENTRY, it is strongly recommended that the content of structure dir is set only by reading the attributes of an existing program from database table TRDIR, and subsequently making specific changes to individual components.

Example

Switches parts of a program to Unicode. A program of language version Obsolete ABAP (Non-Unicode) is imported and, using an example, the statement DESCRIBE FIELD is switched to the syntax for Unicode systems. The source code of the program is then overwritten with the modified source code and the ABAP language version is set to Standard ABAP (Unicode).

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
       WHERE name    = @prog AND
             uccheck = ' '
       INTO  (@uc).

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 VERSION 'X'.
  ENDIF.
ENDIF.


Exceptions

Handleable Exceptions

CX_SY_WRITE_SRC_LINE_TOO_LONG

Non-Handleable Exceptions



Continue
INSERT REPORT - Internal Additions