‎2008 Dec 03 11:27 AM
Hi All,
How do i declare a variable in ABAP so that the type is dynamic?
I've seen dynamic parameters, internal tables and select-options.
But, I need to declare a variable and declare the type dynamic, Something like below:
DATA gv_field LIKE (gv_dynamic_type).
Any help will be appreciated.
Thanks
‎2008 Dec 03 11:28 AM
‎2008 Dec 03 11:30 AM
check this sap help reference
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm
‎2008 Dec 03 11:31 AM
Check out this code:
PARAMETERS: P_TABLE LIKE DD03L-TABNAME.
FIELD-SYMBOLS: <FS_TABLE> TYPE TABLE,
<WA_TABLE> TYPE ANY.
DATA: XTABLE TYPE REF TO DATA." It tells compiler that the data object type will be defined at runtime
CREATE DATA XTABLE TYPE TABLE OF (P_TABLE)." It creates data XTABLE at runtime
ASSIGN XTABLE->* TO <FS_TABLE>." before using this field symbol in LOOP, its must be assigned
SELECT * FROM (P_TABLE) INTO TABLE <FS_TABLE> ORDER BY PRIMARY KEY.
LOOP AT <FS_TABLE> ASSIGNING <WA_TABLE>.
ENDLOOP.
‎2008 Dec 03 11:39 AM
‎2008 Dec 03 1:55 PM
‎2008 Dec 16 6:26 AM
Hi,
Did u get the way for doing that dynamic declaration types...
If so could u please help me with the sample code on how to do that
Regards
kishore
‎2014 Apr 25 9:42 AM
FIELD-SYMBOLS: <fs_field> type any.
data g_field type ref to data.
data g_name type string.
g_name = 'BUT021_FS-ADDRNUMBER'."could be any name
create data g_field type (g_name).
ASSIGN g_field->* TO <FS_FIELD>."is now of type BUT021_FS-ADDRNUMBER