‎2008 May 28 8:37 AM
Hello ABAP Experts,
i want to create a Variable name at runtime and then assign
num. values to it.
For Ex. :
data : vday type sy-datum
vday = sy-datum+6(2). + 'AAA'.
i want create variable name is" 28AAA at runtime... Bcoz every time sy-datum values are change so my variable name is also change...
Its very urgent
please help me rewards are helpful answers.
Thanks :
Vandana.
‎2008 May 28 8:42 AM
‎2008 May 28 8:46 AM
do you want the NAME of the variable changed, or do you want to change the contents of your vday variable.
If the latter is the case just concatenate sy-datum+6(2) 'AAA' into vday.
If you want to dynamically create variable names, you will have to use CREATE DATA, or maybe even use the CL_ABAPDESCR classes.
Some examples for Dynamic Creation of Data Objects:
TYPES: BEGIN OF struc,
a TYPE i,
b TYPE c LENGTH 8,
END OF STRUC.
DATA: dref TYPE REF TO DATA,
tname TYPE string,
str TYPE struc,
int TYPE i.
FIELD-SYMBOLS: <int> TYPE i,
<str> TYPE struc,
<f> TYPE any.
dref
CREATE DATA dref TYPE struc.
ASSIGN dref->* TO <str>.
<str>
36 ABC
<str>-a = 36. <str>-b = 'ABC'.
CREATE DATA dref LIKE int.
ASSIGN dref->* TO <int>.
<int>
5
<int> = 5.
tname = 'SFLIGHT'.
CREATE DATA dref TYPE (tname).
ASSIGN dref->* TO <f>.
<f>
SELECT SINGLE * FROM (tname) INTO <f>.
Edited by: Micky Oestreich on May 28, 2008 9:51 AM
‎2008 May 28 12:05 PM
Hello Micky
Thanks For your reply
concatenate sy-datum+6(2) 'AAA' into vday.
this is right but
but every time the sy-datum is change so my variable vday name is also change . and i want my variable name is change every time when the sy-datun is change...
Please Help me out.
Thanks :
Vandana
‎2008 May 28 12:09 PM
hi Vandanan,
what sense does it make to have dynamic name of the variable? Have you ever seriously thought on this?
ec