SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd
[PROGRAM prog] [DIRECTORY ENTRY dir]
[WITH CURRENT SWITCHSTATES]
If the internal table does not contain syntactically correct ABAP source code, then:
The error message of the first syntax error is assigned to variable
messmust be a character-like data object.
The line number of the first syntax error, with reference to the program in which it occurs (either the source code in
itabor an integrated include program included there) is assigned to the variable
linexpects the data type
The first token with errors is assigned to the variable
wrdmust be a character-like data object.
DIRECTORY ENTRY are
used to set the attributes for the syntax check. The addition
WITH CURRENT SWITCHSTATES
specifies which switch configuration is used for the syntax check. The other
error_handling additions can be used to identify other attributes of the first syntax error.
|0 (means:||The internal table
|4||The internal table
|8||A runtime error occurred in the syntax check.|
If a runtime error occurs during the syntax check (
sy-subrc has the value 8), a database rollback is executed in the usual manner. As usual, the short dump of the runtime error can be found in
ABAP Dump Analysis.
If the internal addition
is specified with ERR, the value 6 can also occur for
... PROGRAM prog
... DIRECTORY ENTRY dir
These additions are used to specify the program attributes used for the syntax check.
PROGRAMaddition is used to specify in
progthe name of an ABAP program whose program attributes are to be used for the syntax check.
progmust be a character-like data object, whose content is not case-sensitive. If the specified program is not found, the standard attributes specified below are used.
DIRECTORY ENTRYaddition, you must specify a data object dir, whose data type corresponds to the structure of database table TRDIR from ABAP Dictionary. In the components of this structure, you can specify the required program attributes. Invalid values are replaced implicitly by internally defined standard values.
At least one of the two additions
PROGRAM or DIRECTORY
ENTRY must be specified. If both additions are specified, the program attributes are determined by the structure
It is advisable to use the addition
PROGRAM, since the components of the structure
dirand their valid values can be interpreted within the system only. If the addition
DIRECTORY ENTRYis nevertheless used in application programs, the content of the structure
dirshould be set by reading the appropriate entry from the database table TRDIR and by modifying only individual components as required.
Examples of program attributes that are important for the syntax check are the program types and the ABAP language version.
Syntax check for source code in
itab. By reading the attributes of the current
program from the database TRDIR into the structure
dir, these can be used
DIRECTORY ENTRY. When the version ID in the component
dir-uccheck is set, the first syntax check is executed in the same way as for programs with the obsolete language version
Non-Unicode ABAP. The second syntax check is executed as for programs with language version
Standard ABAP (Unicode).
The first syntax check finds the error indicating that the program is not Unicode-enabled. The second
syntax check always identifies the error when the addition
CHARACTER MODE is missing from the statement
DATA: itab TYPE STANDARD TABLE OF string, mess TYPE string, lin TYPE i, wrd TYPE string, dir TYPE trdir. itab = VALUE #( ( `PROGRAM test.` ) ( `DATA dat TYPE d.` ) ( `DATA len TYPE i.` ) ( `DESCRIBE FIELD dat LENGTH len.` ) ). SELECT SINGLE * FROM trdir WHERE name = @sy-repid INTO @dir. dir-uccheck = ' '. SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd DIRECTORY ENTRY dir. IF sy-subrc = 4. MESSAGE mess TYPE 'I'. ENDIF. dir-uccheck = 'X'. SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd DIRECTORY ENTRY dir. IF sy-subrc = 4. MESSAGE mess TYPE 'I'. ENDIF.
... WITH CURRENT SWITCHSTATES
This addition causes the syntax check to use the switch configuration of Switch Framework, in the state it had when the current transaction was called. Without the addition, the switch configuration valid when the statement is executed is used.
This addition causes the syntax check to run with the same switch states from Switch Framework as were
used when the statement
GENERATE SUBROUTINE POOLwas executed.
Without the addition, the syntax check is performed in the same way as for every regular compilation of ABAP programs.