Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 


Former Member
0 Kudos

Has anyone used the "scan" keyword? I will be reading a report program into an internal table, after which i need to read the tables contents and find the list of datatypes used in it. Also i need to map these datatypes then to its corresponding database fields. Can someone please help.


Active Contributor
0 Kudos


GUI_UPLOAD can split files automatically, when using open dataset you can use SPLIT string AT val INTO fields... explicitly - why do you want to search in a structure?

I don't see more flexibility, search this forum e.g. for split or dataset - you will find some nice examples.



Former Member
0 Kudos

Hi Sidhartha,

This keyword is actually for internal use by SAP.

However, we use it in a check program to enforce the standardization of ABAP coding (so all global variables start with gv_, all constants start with co_) and to check if ABAP code is build correctly (Is ALWAYS a check on SY-SUBRC available after certain commands).

How to use it:

Take a look at the next partial source code.

DATA: BEGIN OF int_abap OCCURS 0,    " Internal table for storing ABAP code
        line(73) TYPE c,
      END OF int_abap.
DATA : BEGIN OF int_sttmts OCCURS 0. " All statements
        INCLUDE STRUCTURE sstmnt.
DATA:  END OF int_sttmts.
DATA : BEGIN OF int_tokens OCCURS 0. " All keywords
        INCLUDE STRUCTURE stokex.
DATA:  END OF int_tokens.
DATA : BEGIN OF int_levels OCCURS 0. " Levels of includes
        INCLUDE STRUCTURE slevel.
DATA:  END OF int_levels.
DATA : BEGIN OF int_lines OCCURS 0,  " Internal table for storing ABAP
       END OF int_lines.
* Cleaning
  CLEAR: int_sttmts,
  REFRESH: int_sttmts,
* Using the SCAN command
  SCAN ABAP-SOURCE int_abap TOKENS INTO int_tokens
                            STATEMENTS INTO int_sttmts
                            WITH ANALYSIS
                            WITH INCLUDES
                            LEVELS INTO int_levels.
* Do something with the result
  LOOP AT int_sttmts.
    LOOP AT int_tokens FROM int_sttmts-from TO int_sttmts-to.
      CONCATENATE int_lines-line int_tokens-str INTO int_lines-line
        SEPARATED BY space.
    APPEND int_lines.
    CLEAR int_lines.

Hope this answers your question,



0 Kudos

Hi Rob,

Thanx for such a fast response. Actually the problem i have is how to use the information i get out of the SCAN keyword. Using scan i get the statements type internal table which contains all the statements in my source code as well it also identifies whether its a keyword or not. The problem now is to figure out how to find out whether each line of statements internal table is for a datatype definition or not. I want to have an internal table that will contain the list of all datatypes used in my code. Then i need to resolve if any of these fields are mapped to any database fields or not. Please help.