Ansicht
Dokumentation

ABAPINSERT_REPORT - INSERT REPORT

ABAPINSERT_REPORT - INSERT REPORT

SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.
SAP E-Book

INSERT REPORT

Short Reference



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

Additions

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 determining 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 creation date and the date of last change, along with the corresponding times, are set to the current value.
  • The program author last changed by attributes are set to the current user.
  • The program status is set to active by default. The program is compiled when it is first executed.
  • The application is set to the value of the current program.
  • Fixed point arithmetic is activated.

If none of the additions are specified, the attributes of an existing program are preserved if it is overwritten, with the following exceptions:

  • 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.
  • If the current program is from the ABAP language version , the overwritten program is always set to this language version.

  • The statement INSERT REPORT cannot currently be used in other ABAP language versions.

For itab, only a standard table without secondary table keys is allowed. A source code line in itab must be character-like and can have a maximum of 255 characters. Trailing blanks are ignored for line types with a fixed length. prog must be a character-like flat data object, which can contain no more than 30 characters, and whose content 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.
See ABAP Command Injections.

Notes

  • The statement INSERT REPORT 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, which means it is not connected to the Change and Transport System (CTS). The program must either be assigned to a package in the 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 structures and names of the program when using the statement INSERT REPORT for programs organized in a master program and using include programs, if they were created in the ABAP Workbench.
  • The program name that is created should comply with the naming conventions of the ABAP Workbench if it is to be processed using the tools in the workbench.
  • 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).

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 defines the program type of the new or overwritten program in accordance with the content of pt. pt must be a data object of data type c with length 1 that contains a valid ID for a program type. The following table shows the case-sensitive IDs of all ABAP program types.

ID Program Type
1 Executable program
F Function pool (or function group)
I Include program
J Interface pool
K Class pool
M Module pool
S Subroutine pool
T Type pool or type group

Addition 4

... FIXED-POINT ARITHMETIC fp

Effect

This addition defines the fixed-point arithmetic property of the new or overwritten program in accordance with the content of fp. fp must be a data object of data type c with length 1 that contains either 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 data type c with a length of 1, which can have the following values as version ID:

vs ABAP Language Version Meaning
X Basic version, Unicode check activated
2 Restricted language scope for enhancements by key users
3 Restricted use of external repository objects, dynamic language elements are not allowed
4 Restricted use of external repository objects, dynamic language elements are allowed
5 Restricted language scope for developments in the .
- Obsolete, Unicode check deactivated

Technically, the addition supplies the column UCCHECK of database table TRDIR. Values other than the ones shown here should not be specified. If incorrect values are specified as a literal and this is known statically, a syntax error occurs. Unknown values, on the other hand, are always saved in the database table TRDIR. Values not contained in the above table act as a version that does not support language elements.

Note

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

Addition 6

... DIRECTORY ENTRY dir

Effect

This addition defines the program attributes for the new or overwritten program in accordance with the content of dir. dir must be a structure of data type TRDIR from the 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, except for 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 nothing were specified.

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 with the obsolete language version is imported and the statement DESCRIBE FIELD is switched to the syntax for Unicode systems as an example. The source code of the program is then overwritten with the modified source code and the ABAP language version is set to .

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

Catchable Exceptions

CX_SY_WRITE_SRC_LINE_TOO_LONG

  • Cause: A line in the source code contains more than 255 characters.
    Runtime Error: INSERT_REPORT_LINE_TOO_LONG


Non-Catchable Exceptions

  • Cause: The program name prog is reserved internally; it begins with '%_T'.
    Runtime Error: INSERT_PROGRAM_INTERNAL_NAME
  • Cause: The program name prog begins with a blank, which is not permitted.
    Runtime Error: INSERT_PROGRAM_NAME_BLANK
  • Cause: The program name prog is too long; it can be no more than 40 characters long.
    Runtime Error: INSERT_PROGRAM_NAME_TOO_LONG
  • Cause: Suffix 2 in the program name prog is invalid or does not correspond to the specification apptype.
    Runtime Error: INSERT_REPORT_BAD_APPENDAGE
  • Cause: The specification apptype is invalid. Valid values are defined in the type group SREXT.
    Runtime Error: INSERT_REPORT_BAD_APPTYPE
  • Cause: Suffix 1 in the program name prog is invalid or does not correspond to the specification exttype.
    Runtime Error: INSERT_REPORT_BAD_EXTENSION
  • Cause: The specification exttype is invalid. Valid values are defined in the type group SREXT.
    Runtime Error: INSERT_REPORT_BAD_EXTTYPE
  • Cause: The value of the field uc is not 'X' or ' '.
    Runtime Error: INSERT_REPORT_ILLEGAL_FLAG
  • Cause: The value of the field pt is not '1', 'I', 'S' , 'M', 'F', 'J', or 'K'.
    Runtime Error: INSERT_REPORT_ILLEGAL_PROGTYPE
  • Cause: The program name prog is longer than 30 characters and the program does not yet exist in the library. Without the ... APPENDAGE TYPE apptype addition, the program cannot be inserted.
    Runtime Error: INSERT_REPORT_NO_APPTYPE
  • Cause: The program name prog is longer than 30 characters and the program does not yet exist in the library. Without the ... EXTENSION TYPE exttype addition, the program cannot be inserted.
    Runtime Error: INSERT_REPORT_NO_EXTTYPE







rdisp/max_wprun_time - Maximum work process run time   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 23468 Date: 20240328 Time: 233544     sap01-206 ( 246 ms )