ABAPINSERT_REPORT - INSERT REPORT
CL_GUI_FRONTEND_SERVICES - Frontend Services CPI1466 during BackupThis documentation is copyright by SAP AG.
INSERT REPORT
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] }.
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
Effect
This statement places the contents of itab as source code into the ABAP program specified in prog in theRepository.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 tableTRDIR.
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 theprofile parameter zcsa/system_language.
- The creation date and the date of the last change, along with the corresponding time, are set to the current values.
- The program author and 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, the attributes of an existing program remain intact if the program 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.
- The setting for the Unicode check is activated if the current program is aUnicode program and anon-Unicodeprogram 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 sourcecode line in itab can contain a maximum of 255 characters. prog must be a character-typeflat data object, which can contain no more than 30 characters, and the content of which can be either upper or lowercase.
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. |
Notes
- The INSERT REPORT statement must be used with extreme caution because it can completely overwriteexisting programs without warning. You can prevent any inadvertent overwriting by checking whether the specified name already exists in the NAME column of system table TRDIR.
- If you use INSERT REPORT to create a new program, this program is not assigned to a package,so that it is not connected to the correction or transport systems. You must assign the program to a package in the ABAP Workbench. Otherwise, it is only suitable for temporary tasks in the current system.
- If you want to use the INSERT REPORT statements for programs that are organized inframework programs andincludeprograms when created in the ABAP Workbench, it is essential that you know the name of the program and how it is structured.
- The program name that is created should comply with the naming conventions of theABAP 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 texts dynamically unnecessary (see the list indynamic program processing).
Addition 1
... MAXIMUM WIDTH INTO wid
Effect
If you use the MAXIMUM WIDTH addition, the number of characters of the longest source code line in itab is assigned to the variable wid, which must be of 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 setting for theUnicode check remains intact in the overwritten program.
Note
With this setting, the source code of non-Unicode programs can be overwritten fromUnicode programs without the Unicode check being implicitly activated.
Addition 3
... PROGRAM TYPE pt
Effect
This addition specifies the program type of the created or overwritten program according to the content of pt, whichmust be a data object of the data type c and length 1 that contains a valid program type ID. The following table lists the IDs of all program types, which must be uppercase.
| 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 created or overwritten program according to the content of fp,which 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
... UNICODE ENABLING uc
Effect
This addition specifies the setting of the Unicode check for the created or overwritten program according to the content of uc, whichmust 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.
Note
With this addition, the source code of non-Unicode programs can be overwritten from Unicode programswithout the Unicode check being implicitly activated. You can also create Unicode programs from non-Unicode programs.
Addition 6
... DIRECTORY ENTRY dir
Effect
This addition specifies the program attributes for the created or overwritten program according to the content of dir, which must be a structure of the data typeTRDIR from the ABAP Dictionary. In the componentsof this structure, you can specify the desired program attributes. Invalid contents result in invalidprogram attributes. All program attributes are obtained from dir, with the exception of the creationand change dates, and the corresponding times, program authors, and 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 DIRECTORY ENTRY addition, it is strongly recommended that you only set the contents of dir by reading the attributes of an existing program from the database table TRDIR.
Example
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 forUnicodesystems. 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.
Exceptions
Catchable Exceptions
- 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 charactersand 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 charactersand 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
Vendor Master (General Section) Vendor Master (General Section)
This documentation is copyright by SAP AG.
Length: 19946 Date: 20120522 Time: 233652 triton ( 428 ms )






