This statement is for internal use only.
It cannot be used in application programs.
1. SCAN ABAP-SOURCE itab1 ...TOKENS INTO itab2
...STATEMENTS INTO itab3.
2. SCAN AND CHECK ABAP-SOURCE itab1 ...RESULT INTO itab2.
SCAN ABAP-SOURCE itab1 ...TOKENS INTO itab2
...STATEMENTS INTO itab3.
Parts marked with " ..." are interchangeable
1. ... FROM n1
2. ... TO n2
3. ... KEYWORDS FROM itab4
4. ... LEVELS INTO itab5
5. ... STRUCTURES INTO itab6
6. ... OVERFLOW INTO c1
7. ... WITH ANALYSIS
8. ... WITH COMMENTS
9. ... WITH INCLUDES [IMPLEMENTATIONS FROM itab]
10. ... WITH TYPE-POOLS
11. ... WITH LIST TOKENIZATION
12. ... PRESERVING IDENTIFIER ESCAPING
13. ... WITHOUT TRMAC
14. ... [INCLUDE] PROGRAM FROM c2
15. ... INCLUDE INTO c3
16. ... MESSAGE INTO c4
17. ... WORD INTO c5
18. ... LINE INTO n3
19. ... OFFSET INTO n4
20. ... WITH EXPLICIT ENHANCEMENTS [IMPLEMENTATIONS FROM itab]
21. ... FRAME PROGRAM FROM c2
22. ... ENHANCEMENTS INTO itab
Breaks down the ABAP source code in the source code table itab1
into tokens according to the rules of the ABAP scanner. The tokens are written - one per line - to the
token table itab2. The source code to be broken down need
not necessarily be contained in an internal table. It can be specified in any character-like field.
In particular, you can use fields of the type STRING. However, this variant only makes sense if the program to be broken down does not contain any comments.
The token table itab2 must have the structure
STOKES. If you specify the addition WITH ANALYSIS,
the token table must have the extended structure STOKESX.
(For reasons of downward compatibility, STOKEN and
STOKEX can still be used. The main difference is that in the new structures the character
string which makes up the token is typed with reference to the data type
STRING. With the structures STOKEN and
STOKEX, a C field of length 30 and an OVERFLOW area are used instead.
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
chained statement "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.
Return Value
The fields of the structure STOKES, and thus the columns of the token table itab2, have the following meaning:
If you specify the structure STOKEN, 3 more fields are filled and you must consider the following:
The fields of structures SSTMNT, and thus the columns of the statement table itab3, have the following meaning:
... FROM n1
... TO n2
Breaks down the source code table itab1 into tokens not
from start to finish, but only from line n1 to line n2.
The additions FROM n1 and TO
n2 must, in this order, follow the specification of the source code table itab1.
... KEYWORDS FROM itab4
Does not return all statements, only those specified in the key word table itab4.
If the key word table is empty (i.e. it contains 0 lines), all the statements are selected.
The lines of the key word table are treated as a character field.
To select a
Native-SQL statement or a macro definition,
you can specify the pseudo key words EXEC_SQL or
DEFINE_MACRO. It makes no difference whether the statements EXEC or DEFINE occur as well.
Native SQL statements and macro definitions are returned
as one statement (of type E or M even if the expansion of a macro definition results in more than one statement.
If the key word table contains a blank line, blank statements are also selected.
... LEVELS INTO itab5
Stores details about each edited source code unit (source code table itab1 itself, expanded
include-programs, expanded macro definitions) in the level table itab5.
Specification of a level table makes sense only with the addition WITH INCLUDES.
The level table itab5 must have the structure SLEVEL.
The fields of the structure SLEVEL - and consequently the columns of the level table itab5 have the following meaning:
If the source code unit contains include programs or macro calls, the line range
[FROM, TO] in the statement table also covers the statements in subordinate source code units.
Enhancements of type E are saved as normal includes in the level table.
... STRUCTURES INTO itab6
Details of the construction of the source text table are given in the structure table itab6.
The fields in SSTRUC (which are also the columns of structure table itab6) have the following meanings:
Flags whether the end of the structure is described semantically ('X' if there is a special statement, otherwise blank).
Index of the first statement of the structure in the statement table itab3.
Index of the last statement of the structure in the statement table itab3.
Index of the first substructure of the structure in structure table itab6.
Index of the last substructure of the structure in structure table itab6.
Index of the structure in the structure table itab6
that contains the structure as a substructure (0 if the structure is the root structure of a structure tree).
... OVERFLOW INTO c1
The addition is only allowed and required if the token table itab2
has the structure STOKEN or STOKEX.
If a token is too large to be stored in the token table in the field STR,
it is placed in the overflow area c1. The offset of the
token in the overflow area then lies in the token table in the field OFF1.
... WITH ANALYSIS
Breaks down each token t = a+b(c) according to the logic of the RSYN key word >ANALY into its three components a, b and c.
Offset and length of components a, b and c are stored in the fields
LEN1, OFF2, LEN2,
OFF3, and LEN3
in the token table. (The offset of OFF1 is always 0 and therefore not required.)
If you specify the addition WITH ANALYSIS, the token
table itab2 must have the structure
STOKESX, so that the fields LEN1,
OFF2, LEN2, OFF3 and LEN3 are available.
If the token table has the structure STOKEX, you must consider the following:
If the whole token exists in the token table, the offset specifications are relative to the token start.
If the token is in the overflow area c1, the offset specifications are relative to the start of the overflow area.
... WITH COMMENTS
Returns comments also, with each individual comment representing a token. The system additionally stores
entries for each full block of comments in the table itab3,
differentiating between comments that occur within statements and those that occur at program level.
In itab3, an entry for a comment within a statement always comes before the statement containing the comment.
Look at the following program fragment. The preceding numbers are the indexes of the tokens.
1 * An example *
2 * with scattered comments
6 MOVE
3 * Inserted comment 1
7 X
4 * Inserted comment 2
8 TO
9 Y
5 * Inserted comment 3
.
SCAN then enters the following values for the components
TYPE, FROM
and TO (in this order from left to right) into itab3.
'P' | 1 | 2 | |
'S' | 3 | 5 | |
'K' | 6 | 9 |
If the addition ... WITH COMMENTS is used, the table
itab2 must have the line type STOKES or STOKESX.
... WITH INCLUDES [IMPLEMENTATIONS FROM itab]
Also breaks down subordinate source code units (included programs, called macros) into tokens.
In addition, >source code plug-ins of explicit and implicit
enhancement options which may exist
are automatically inserted in the source code to be split. The optional addition
IMPLEMENTATIONS FROM itab can be used to limit the number of inserted enhancements to the
number specified in itab. If
itab is empty, no enhancements are inserted. addition LEVELS INTO itab5.
... WITH TYPE-POOLS
... WITH LIST TOKENIZATION
Tokens of the form (a1, a2, a3) are not returned as tokens but broken down into the elementary components.
... PRESERVING IDENTIFIER ESCAPING
By default, exclamation marks before labels are deleted. Exclamation marks can be used to distinguish between labels and key
words. This addition prevents their deletion.
... WITHOUT TRMAC
If a statement begins neither with an ABAP/4 key word nor with a DEFINE
macro, the system does not check whether this is a TRMAC
macro, but assumes an unknown statement. (Unknown statements are flagged in the statement table
itab3 with a U in the field TYPE.)
To
avoid unnecessary database accesses to the table TRMAC,
you should use the addition WITHOUT TRMAC whenever you
assume that the source code to be scanned contains unknown statements. Unknown statements are particularly
likely to occur if you use the addition FROM n1, because the scanner does not start at the beginning of the source code, but from a specified point.
If you use WITHOUT TRMAC with
WITH INCLUDES, TRMAC macros are not expanded because the system does not recognize them as subordinate source code units.
... [INCLUDE] PROGRAM FROM c2
... INCLUDE INTO c3
... MESSAGE INTO c4
... WORD INTO c5
... LINE INTO n3
... OFFSET INTO n4
The above additions have the same meaning as those for the SYNTAX-CHECK statement: c2 is an input field for a program name to be assigned to the source code, while the fields c3, c4, c5, n3, and n4 are output fields in case an error occurs.
In release 7.00, the addition PROGRAM FROM was renamed
to INCLUDE PROGRAM FROM to clearify the difference between
the main program and the source code unit to be broken down. If the addition is used in its previous
form PROGRAM FROM, it sets the main program and the source code text unit to be scanned at the same time.
To be able to analyze errors without modifying programs, use the additions
INCLUDE INTO, MESSAGE INTO,
WORD INTO, LINE INTO and OFFSET INTO. These provide information about the errors which have occurred.
... WITH EXPLICIT ENHANCEMENTS [IMPLEMENTATIONS FROM itab]
When you specify WITH EXPLICIT ENHANCEMENTS, the existing source code plug-ins for explicit enhancement options are automatically inserted into the source code that has been broken down.
The optional addition IMPLEMENTATIONS FROM can limit the
number of inserted enhancements to the number specified in itab. If itab is empty, no enhancement is inserted.
... FRAME PROGRAM FROM c2
This addition specifies the main program for the source code text to be broken down. This is required for the correct insertion of
source code plug-ins.
... ENHANCEMENTS INTO itab
Specifications of the enhancement implementations available in the source code that is processed are saved in enhancement table itab. It therefore only makes sense to specify an enhancement table together with additions WITH INCLUDES or WITH EXPLICIT ENHANCEMENTS.
The level table itab has to have the line structure SENHMT, whose fields have the following meaning:
SCAN AND CHECK ABAP-SOURCE itab1 ...RESULT INTO itab2.
Parts marked with " ..." are interchangeable
1. ... PROGRAM FROM c1 2. ... INCLUDE INTO c2
3. ... MESSAGE INTO c3
4. ... WORD INTO c4
5. ... LINE INTO n1
6. ... OFFSET INTO n2
Effect
The syntax of the program in table itab1 is checked. During
the check, all of the information from the program, such as statement structures, statements, tokens,
data objects, types and do on are placed into the result field. This field must have the type SYSCH_RESULT, which is defined in
type group SYSCH.
You must therefore declare type group SYSCH in your ABAP
program using a TYPE-POOLS statement.
... PROGRAM FROM c1
... INCLUDE INTO c1
... MESSAGE INTO c3
... WORD INTO c4
... LINE INTO n1
... OFFSET INTO n2
The above additions have the same effect as the corresponding additions in the statement
SYNTAX-CHECK: c1 is an input field for
a program name to be assigned to the source code, the fields c2,
c3, c4, n1 and n2 are output fields, used when errors occur.
To enable you to analyze errors without having to modify the program, you should specify the
INCLUDE, MESSAGE,
WORD, LINE and OFFSET additions for the information about the error that occurred.
Catchable Exceptions
CX_SY_SCAN_SOURCE_TOO_WIDE