ABAP Programming Syntax for Scan keyword

ABAP programming language has some keywords and scan is one among them.The syntax for this programming word is as shown below.

Basic form

SCAN ABAP-SOURCE itab1 TOKENS INTO itab2
STATEMENTS INTO itab3.

Effect

Breaks down the ABAP/4 source code in the source code table itab1 into tokens according to the rules of the ABAP/4 scanner. The tokens are written - one per line - to the token table itab2 . The token table itab2 must have the structure STOKEN . (If you specify the addition WITH ANALYSIS , the token table must have the extended structure STOKEX .)

Normally, comments are filtered out and subordinate source code units (included programs, called macros) are ignored. If you want to include these items, use the additions WITH COMMENTS and WITH ANALYSIS .

In addition to classifying the source code by token, the scanner organizes the tokens themselves into statements - using the colon-comma logic to form chain records - and the statement table itab3 contains a statement description on each line. Here, a three-part chain record "a: b, c1 c2, d." results in three entries "a b,", "a c1 c2," and "a d." in the statement table itab3 .

The statement table itab3 must have the structure SSTMNT . The statement classification characters colon, comma and period are not written to the token table itab2 . Instead, the table itab3 contains details about the position of a colon or the type (comma or period and position of the end marker in the statement description.

The return code value is set as follows:
SY-SUBRC = 0 Source code table is not empty, contains no errors and is broken down into tokens.

SY-SUBRC = 1 Source code table is not empty and is broken down into tokens, but at least one include program does not exist (can occur only in connection with the addition WITH INCLUDES ).
SY-SUBRC = 2 Source code table itab1 is empty or a blank line range was selected (applies to the additions FROM and TO ).

SY_SUBRC = 4 Scanner detects error in source code. \
SY-SUBRC = 8 Other error or RABAX in scanner.

The fields of the structure STOKEN , and thus the columns of the token table itab2 , have the following meaning:

TYPE Type of token with possible values:
I (Identifier)
S (String, i.e. character literal)
L (List, enclosed in parentheses)
C (Comment)
ROW Number of line where token occurs or where it begins (>= 1)
COL Offset of first character of token relative to start of line (>= 0)
LEN Length of token STR Character string forming the token (or just first part) OVFL Overflow flag for field STR with the following possible values:

SPACE (no overflow, token fits completely in field STR )
X (overflow, either not resolved (no overflow are specified) or token fits in overflow area c1 ))
O (overflow of token and overflow of overflow area c1 )
OFF1 Offset in overflow area, if token does not fit completely in field STR and an overlfow area c1 is specified and token fits completely in overflow area c1 .

The fields of the structure SSTMNT , and thus the columns of the statement table itab3 , have the following meaning:
TYPE Type of statement with the following possible values:
E (Native SQL statement between EXEC SQL and
ENDEXEC )
I ( INCLUDE prog )
J ( INCLUDE prog , prog does not exist, can occur only in connection with the addition WITH INCLUDES )
R (Call a macro from table TRMAC )
D (Call an internally defined macro with DEFINE )
M (Macro definition between DEFINE and END-OF-DEFINITION )
C ( COMPUTE statement, sometimes without COMPUTE as first token)
K (Other ABAP/4 key word)
N (Blank statement)
U (Unknown, non-blank statement)
LEVEL Index of source code unit in the level table itab5 (>= 1, if level table specified, otherwise 0)

FROM Index of first token of statement in the token table itab2
TO Index of last token of statement in the token table itab2 (the end marker of the statement - comma or period - counts as no more then a token)

NUMBER Statement counter in a source code unit. Covers all statements, regardless of how many are actually selected - in cases where a key word table itab4 is specified PREFIXLEN Number of tokens before the colon (with chain statements >= 1, otherwise 0)

When expanding macro calls, no position specifications are available. The relevant fields in the token table itab2 and in the statement table itab3 are then set to 0. Unlike the usual syntax check, the following are not treated as errors:

· Comma without preceding colon (the comma then acts as an end marker),
· Open chain statement sequence at end of source code,
i.e. the last statement is closed by a comma, not by a period,
· Open statement at end of source code, i.e. the last statement is closed neither by a period nor by a comma.
To be able to analyze errors without modifying programs, use the additions INCLUDE , MESSAGE , WORD , LINE and OFFSET .

These provide information about the errors which have occurred.

Related Posts:

ABAP HR head count report for sap
SAP ABAP FICO REPORT FOR GROUP CURRENCY RECONCILIATION
fico reconcilation report for company code currency report
SAP ABAP FICO report about profitability analysis
SAP ABAP fico report profitability analysis report
My sapcrm customers and consumer segmentation
Organizational challenges in crm and mysap solutions
Business View and Mysap.com
What is SAP R/3 introduction to mysap.comSyntax for report key word for sap abap