‎2012 Feb 28 9:53 AM
Hi All,
I have to create a Z Program which has the Program name as input (Selection Screen) and i need to display the data elements (and details ex: data type , length) used in the program .
Can anyone help me out ..
Thanks,
Pradeep.
‎2012 Feb 28 10:11 AM
‎2012 Feb 28 10:17 AM
Hi,
Maybe 'SCAN ABAP-SOURCE' would be of any use. However it's meant only for internal use. You could also check function group SEDA.
BR
Marcin Cholewczuk
‎2012 Feb 28 10:19 AM
One way would be to read the source code of the program into an internal table. Then loop over the table and find your DATA statements. Try finding them by Regex or string operations...
parameters: pa_prog type c length 30.
data: begin of source_code,
line(300) type c,
end of source_code.
read report pa_prog into source_code.
loop at source_code.
"Search for data elements ..
endloop.
‎2012 Feb 28 10:37 AM
Enjoy
Had a very tough time debugging the standard functionality
DATA:environment_types TYPE envi_types,
output_list TYPE TABLE OF senvi,
source_searched TYPE TABLE OF rsfind,
lv_dtel TYPE ddobjname,
dd04v TYPE dd04v,
para TYPE tpara,
state TYPE ddgotstate,
wa_output TYPE senvi.
PARAMETERS:pa_prog TYPE tadir-obj_name.
START-OF-SELECTION.
environment_types-dtel = 'X'.
CALL FUNCTION 'REPOSITORY_ENVIRONMENT_SET_RFC'
EXPORTING
obj_type = 'PROG'
environment_types = environment_types
object_name = pa_prog
TABLES
environment = output_list
source_objects = source_searched.
LOOP AT output_list INTO wa_output.
lv_dtel = wa_output-object.
CALL FUNCTION 'DDIF_DTEL_GET'
EXPORTING
name = lv_dtel
state = 'A'
langu = sy-langu
IMPORTING
gotstate = state
dd04v_wa = dd04v
tpara_wa = para.
ENDLOOP.
The table dd04v will have the type and length and the table output_list holds the data element in the program.
‎2012 Feb 28 11:27 AM
Hi
Thanks for your reply... I tried that code and the output is not displaying all the variables . Its randomly displaying the few.
I need what are all the variables i declared in a Program should be displayed in the output.
Thanks,
Pradeep.
‎2012 Feb 28 11:30 AM
In your first post, you mentioned "data elements", which is a specific DDIC development object, thus Keshav's reply. Now you actually seem to mean data declarations in general.
Please clarify what you really want, so people can save some time.
Thomas
‎2012 Feb 28 11:34 AM
Your actual question was "Data elements" and now you ask for "Variables". Please be sure before asking the question. Its meaningless answering a wrong quesiton.
‎2012 Feb 28 11:40 AM
Dear Thomos,
Sorry for confusing .
For Ex :
data : gv_conv_gamng TYPE char15,
gv_scrap_qty TYPE zsrem_conf-gsmng,
gv_matnr TYPE matnr,
gv_matkl TYPE matkl,
lv_matnr TYPE matnr,
gv_plaf_pwwrk TYPE pwwrk,
gv_maktx TYPE maktx.
These are the local variables i used in a Z Progam. I need the data elemnt detials of these.
Ex : For gv_matkl :
data element is maktl
data type is CHAR
lenth is 9.
Thanks,
Pradeep.
‎2012 Feb 28 11:45 AM
OK, and what output would you expect for let's say
gf_saknr like ska1-saknr,
gf_date type d,
gf_char type c length 10,
gf_long type string,
gr_alv type ref to cl_salv_table,
gt_list type ty_output_tt,
...Thomas
‎2012 Feb 28 12:30 PM
Hi,
gf_saknr like ska1-saknr,
gf_date type d,
gf_char type c length 10,
gf_long type string,
gr_alv type ref to cl_salv_table,
gt_list type ty_output_tt,
The Expected Output is :
1. The data type of gf_saknr
2. Length of gf_saknr.
‎2012 Feb 29 8:37 AM
Dear Moderator,
Please Kindly help me out in solving this Issue..
I have already given an example of my requirement.
Thanks,
Pradeep.
‎2012 Feb 29 2:51 PM
Hi,
Then you'll have to deal with READ REPORT and SCAN ABAP-SOURCE... and probably use the keyword 'DATA' with the SCAN statement. Never used this, but it seems you could use the table of tokens or statements returned.
READ REPORT 'ZREPORT" INTO abap_source.
MOVE lc_data TO l_keyword. APPEND l_keyword. "= 'DATA'
MOVE lc_include TO l_keyword. APPEND l_keyword.
SCAN ABAP-SOURCE abap_source
TOKENS INTO l_token_analysis
STATEMENTS INTO l_statements
KEYWORDS FROM l_keyword
WITH ANALYSIS
WITH INCLUDES
WITHOUT TRMAC.
Kr,
Manu.
‎2012 Mar 01 6:13 AM
As much as we like to spoonfeed you with this basic solution, but it is already in ABAP Help F1 (Processing Internal Data). nevertheless, try optimizing your search options you might be able to get a solution for this in some existing forums.