‎2009 Dec 03 2:54 AM
Hi,
There is a request to follow the number of decimal places from table TCURX depending on the country.
For example,
data: l_decimal type i.
loop at itab.
select single decimal
into l_decimal
where waers eq itab-waers.
data: X type p decimal l_decimal.
X = 5.32424 x 3.2452542 / 2.3242352
endloop.
The declaration of the variable with the decimal using another variable is not allowed.
Do you have any other suggestions on doing this?
Thanks
‎2009 Dec 03 4:15 AM
you need to create dynamic variable.
like this
DATA lv_test TYPE REF TO data.
FIELD-SYMBOLS <X> TYPE ANY.
DATA: lv_deci TYPE i VALUE 2.
CREATE DATA lv_test TYPE p DECIMALS lv_deci.
ASSIGN lv_test->* TO <X>.
<X> = '20.333'. "Anything.
WRITE: <fs>.
Please search CREATE DATA in F1 for more details.
Chaiphon
‎2009 Dec 03 4:11 AM
hi
for dynamic declaration always use () brackets
That is :
data: X type p decimal l_decimal.
Replace as
data: X type p decimal (l_decimal).
Try This trick
with regards
Anand kumar
‎2009 Dec 03 4:15 AM
you need to create dynamic variable.
like this
DATA lv_test TYPE REF TO data.
FIELD-SYMBOLS <X> TYPE ANY.
DATA: lv_deci TYPE i VALUE 2.
CREATE DATA lv_test TYPE p DECIMALS lv_deci.
ASSIGN lv_test->* TO <X>.
<X> = '20.333'. "Anything.
WRITE: <fs>.
Please search CREATE DATA in F1 for more details.
Chaiphon
‎2009 Dec 03 5:15 AM
Chaiphon,
Thanks alot your solution worked.
Anand,
Even assigning the decimal with a variable, it still displays an error of (VAR) is not numeric.