10-09-2008 2:21 PM
Hi Friends ,
I have one table which contains three fields ,1) unique identifier ,2) number of digits before decimal and 3) number of decimals.
In one other table there are 2 fields,1)unique identifier , and 2) VALUE in float format e.g 4.000000000000000E+01
4.000000000000000E+00
Identifier is common field between this two tables.
I wan to write the VALUE field in my report,by the number of decimals given in first table.
So how can i create dynamic variable at runtime that will contain number of decimals as given in my table.
Thanks,
Brij
10-09-2008 2:37 PM
Hi
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>.
Regards,
Vind
10-09-2008 2:37 PM
Hi
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>.
Regards,
Vind