2016 Jan 05 11:16 AM
Hi Experts,
I need to make a report program to find all global variables in a program(mentioned in the selection screen) and display internal table and work area separately.
By using the function module 'GET_GLOBAL_SYMBOLS' I found out all the variables. Now I have to differentiate each as internal table, work area and other variable.
Please suggest how to differentiate.
Thanks in Advance.
Ann
2016 Jan 05 12:05 PM
Hi Experts,
I need to make a report program to find all global variables in a program(mentioned in the selection screen) and display internal table and work area separately.
By using the function module 'GET_GLOBAL_SYMBOLS' I found out all the variables. Now I have to differentiate each as internal table, work area and other variable.
Please suggest how to differentiate.
Thanks in Advance.
Ann
2016 Jan 05 11:19 AM
2016 Jan 05 11:31 AM
Can we differentiate variable as work area or internal table by using CL_ABAP_TYPEDESCR.
2016 Jan 05 11:53 AM
Hi,
Not really - that's for run time use. The results I get back have [] appended for internal tables. If there's a reference type you can read the data dictionary tables (dd01x-dd04x)
As for work areas etc, you would need to parse the programs I would think.
Regards
Rich
2016 Jan 05 12:18 PM
It looks like you're right. I tried to find appropriate FM or class, but I couldn't.
But I have found a report RS_ACI_SHOW_AST. It performs parsing of the ABAP report and outputs a list of statements.
This is a sample program.
And here is the output generated by the report:
So, may be it is possible to analyze statements with the specific types (for example, DATA DEFINITION, FIELD-SYMBOLS, PARAMETER DEFINITION and so on) and get the names of the variables and their data types names.
For example, Node 9 contains STRUCT-OP "TABLE OF..". Hence, this variable is an internal table.
Node 11. It has type SCARR-CARRID. You can use CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( P_NAME = 'SCARR-CARRID' ) to determine the actual type of this variable.
And so on..
But there also some bad news. The report RS_ACI_SHOW_AST is extremely complicated. More than it, it is marked for internal use only.
2016 Jan 05 12:05 PM
2016 Jan 05 12:13 PM
Hi Ann,
In the same function module RFIELDLIST table you have a type field which will hold whether it is an internal table,work area or variable.
internal table - type h
work area - u
variable of type char - C
variable of type string - g
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |