SAP - Syntax CHECK - Guide
Get Example source ABAP code based on a different SAP table
GUIDELINE 3.6
Syntax Check
ABAP_BACKGROUND
The syntax check provides syntax errors and syntax warnings:
Errors that could cause program termination if the ABAP program is executed. This priority also includes all constructs that should not be used at all, because they indicate program errors and are very likely to make the program behave incorrectly.
This priority refers to all constructs that do not necessarily cause incorrect behavior, but are obsolete, for example, and should be replaced by current constructs. Priority 2 errors can become priority 1 errors or syntax errors in future releases.
Includes all errors where correction would be beneficial, but not necessarily essential, for the current release. However, the possibility of raising the priority in future releases is not ruled out.
The
The operational package concept means that the syntax check also checks package violations. In this case, whether a syntax error or only a syntax warning occurs depends on the encapsulation level set for the corresponding package.
ABAP_RULE
Take all warnings of the ABAP syntax check seriously. Syntax warnings are not permitted in completed programs.
ABAP_DETAILS
You must always correct the causes of syntax warnings because they generally lead to unpredictable errors. These warnings are often reclassified as errors by SAP in subsequent
Selected syntax check warnings can be hidden using pragmas. With respect to the package check, selecting
Bad example
The following source code causes a syntax warning. An internal table is accessed using a freely specified key, even though a secondary key with the same components exists. This access performs a linear search.
DATA itab TYPE HASHED TABLE OF spfli
WITH UNIQUE KEY carrid connid
WITH NON-UNIQUE SORTED KEY cities COMPONENTS cityto cityfrom.
...
READ TABLE itab WITH KEY cityfrom = '...' cityto = '...'
ASSIGNING <(><<)>fs>.
Good example
The following source code corrects the above example. Here, the secondary key is used to access the table. The access performs a binary search. Hiding the syntax warning using the associated program
DATA itab TYPE HASHED TABLE OF spfli
WITH UNIQUE KEY carrid connid
WITH NON-UNIQUE SORTED KEY cities COMPONENTS cityto cityfrom.
...
ASSIGN itab[ KEY cities
COMPONENTS cityfrom = '...' cityto = '...' ] TO <(><<)>fs>.