‎2010 Mar 04 9:47 PM
Dear experts,
I have a small requirement where in I need to split the qty at the decimal place and use the non decimal value as a character field.
Eg: WA_ITAB-LFIMG = 12.000
I want only 12 into one variable which has only capacity of 4 characters (Lfimg has 1313 characters).
I tried the following code, but it did not work.
I was able to successfully split the value and pass it onto the corresponsing entries but unable to pass the value into a variable of 4 characters,
Can some one please help me in this.
It_itab has lfimg
data : var(17) type c,
qty(13) type c,
qty_dec(3) type c,
val(4) type c.
constants : ca(1) type c value '.'.
read table it_itab into wa_itab index 1.
var = wa_itab-lfimg.
split var at ca into qty qty_dec. " This worked
val = qty. " This did not work
Thanks
-Amit
‎2010 Mar 04 10:22 PM
Hi Amit,
use TRUNC function:
data :
qty_dec(3) type c,
val(4) type c.
val = trunc( WA_ITAB-LFIMG ).
qty_dec = ( WA_ITAB-LFIMG - trunc( WA_ITAB-LFIMG ) ) * 1000.
Regards,
Clemens
‎2010 Mar 04 10:04 PM
Debug your code and explain more clearly what did not work.
I suspect var and also qty are filled right bound with leading spaces, so your last statement moves only 4 spaces to val.
Thomas
‎2010 Mar 04 10:22 PM
Hi Amit,
use TRUNC function:
data :
qty_dec(3) type c,
val(4) type c.
val = trunc( WA_ITAB-LFIMG ).
qty_dec = ( WA_ITAB-LFIMG - trunc( WA_ITAB-LFIMG ) ) * 1000.
Regards,
Clemens