‎2007 Aug 20 2:28 PM
Hi
I was looking into a poosibility of making a dynamic declaration refercing a formal parameter. is it possible. below is my code:
FORM WRITE_DATA USING P_TYPE P_SNAME.
CREATE DATA p_type TYPE (P_SNAME).
.....
ENDFORMCan you pls let me know on how to acheive it
‎2007 Aug 20 3:08 PM
Hi Prabhu,
that works in my program.
DATA: transtru TYPE dd03l-tabname.
CREATE DATA fs_it_data_ref
TYPE STANDARD TABLE OF (transtru)
WITH DEFAULT KEY.
So yes, it's possible.
Kind Regards
Henner
‎2007 Aug 20 2:52 PM
Hi,
Check for possibility to use GENERATE SUBROUTINE in your case
aRs
‎2007 Aug 20 3:03 PM
‎2007 Aug 20 3:08 PM
Hi Prabhu,
that works in my program.
DATA: transtru TYPE dd03l-tabname.
CREATE DATA fs_it_data_ref
TYPE STANDARD TABLE OF (transtru)
WITH DEFAULT KEY.
So yes, it's possible.
Kind Regards
Henner
‎2007 Aug 20 3:11 PM
hi henner
thks for ur reply. here the variable in my requirement <b>fs_it_data_ref</b> is a formal parameter in a form routine and the value present in the formal parameter should be referenced for dynamic declaration.
‎2007 Aug 20 3:18 PM
Hi Prabhu,
additionally you have to call your form like this:
data: p_name type ref to data.
data: s_name type fieldname value 'LFDNR'.
perform abc using p_name s_name.
FORM abc USING p_name type ref to data
s_name type fieldname.
create data p_name type (s_name).
ENDFORM. " abc
‎2007 Aug 20 3:21 PM
yeah. i had tried this too. but how to populate the variable p_name with values ,say item1, so that in the form routine a dynamic variable called item1 is created? i'm unable to acheive this.
‎2007 Aug 20 3:18 PM
‎2007 Aug 20 3:23 PM
this should work
REPORT zpwtest .
START-OF-SELECTION .
DATA : v_i TYPE i ,
v_c TYPE c .
PERFORM check_data USING v_i v_c .
*---------------------------------------------------------------------*
* FORM check_data *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_V_I *
* --> P_V_C *
*---------------------------------------------------------------------*
FORM check_data USING p_v_i
p_v_c.
DATA: p_i TYPE REF TO data .
CREATE DATA p_i LIKE p_v_i .
ENDFORM. " check_data
‎2007 Aug 20 3:35 PM
hi pawan
my requirement is as below:
FORM WRITE_DATA USING P_TYPE P_SNAME.
CREATE DATA p_type TYPE (P_SNAME).
...
ENDFORM
PS: P_TYPE is a formal parameter which can take some input value like street. and i need to create a variable called street dyncamically. is it possible?
‎2007 Aug 20 3:48 PM
sorry.. i sound absurd in previous replies...
can i ask you why so you want variable 'variable name' ? Hope my question is inline with your req.
‎2007 Aug 20 3:53 PM
its a kinda requirement which i thought of using. i have a meterial doc number to which P_ is prefixed and i need to create a variable say P_4500234 for each material doc number and process. i do have other woraround but thought if this would be feasible to implement in abap?
‎2007 Aug 20 4:03 PM
Hi,
Please check this code, may this one will help you.
report z0002.
parameters : p_field(40) type c default 'MARA_MATNR'.
* The dynamic program source table
data: begin of inctabl occurs 10,
line(72),
end of inctabl.
data: lng type i, typesrting(6).
* Create the dynamic internal table definition in the dyn. program
inctabl-line = 'program zdynpro.'. append inctabl.
concatenate 'data: p_type like ' p_field '.'into inctabl-line
separated by space.
append inctabl.
concatenate 'P_TYPE = 123.' SPACE into inctabl-line
separated by space.
append inctabl.
concatenate 'write : / P_TYPE.' SPACE into inctabl-line
separated by space.
append inctabl.
insert report 'zdynpro'(001) from inctabl.
submit zdynpro and return.
break-point.
.
aRs
‎2007 Aug 20 4:06 PM
Hi Prabhu,
if i understood you correctly, it's not possible what you like to do, because
create data just gives you a pointer like for the above example, then you can assign the pointer to
a field symbol that takes over the type of s_name then.
I'm not sure, but i think what you need is the class
CL_APAP_TYPEDESCR and it's subclasses like
CL_ABAP_TYPEDESCR
--CL_ABAP_DATADESCR |
--CL_ABAP_ELEMDESCR | --CL_ABAP_REFDESCR | --CL_ABAP_COMPLEXDESCR |
--CL_ABAP_STRUCTDESCR | --CL_ABAP_TABLEDESCR |
--CL_ABAP_OBJECTDESCR |
|--CL_ABAP_CLASSDESCR
|--CL_ABAP_INTFDESCR
I think it's able to make dynamic declarations like you need then, but i never
needed it and never used it.
Kind Regards
Henner
‎2007 Aug 20 4:12 PM