04-29-2005 6:57 AM
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.
04-29-2005 7:16 AM
Hi!
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.
Regards,
Christian
04-29-2005 7:29 AM
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
line(200),
END OF int_lines.
* Cleaning
CLEAR: int_sttmts,
int_tokens,
int_levels,
int_lines.
REFRESH: int_sttmts,
int_tokens,
int_levels,
int_lines.
* 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.
ENDLOOP.
APPEND int_lines.
CLEAR int_lines.
ENDLOOP.
Hope this answers your question,
Regards,
Rob.
04-29-2005 8:04 AM
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.