06-10-2011 7:58 AM
Hi,
I want to convert the quantity field to timestamp. for e.g.
I have value in quantity field as 1.6 . That I want to convert to 1hr36 minutes.
Is there any FM to do this.
Or how shall I write the code for this?
Thanks in advance,
rgds,
MAdhuri S
06-10-2011 9:19 AM
Try this
DATA:
str TYPE char10,
n1 TYPE p DECIMALS 2,
n2(2) TYPE n,
n3 TYPE t,
n4 TYPE p DECIMALS 2,
n5(6) TYPE c,
n6 TYPE p DECIMALS 2. .
n1 = '1.6'. "assign your value
n6 = '60'.
n2 = trunc( n1 ).
n4 = ( n1 - n2 ) * n6 .
n5 = '000000'.
n5(2) = n2.
n2 = n4.
n5+2(2) = n2.
n3 = n5.
WRITE n3 TO str.
WRITE: / 'Time =', str.
06-10-2011 8:11 AM
Hi,
find out the position of decimal by :
if v_qty co '.' .
v_position = sy-fdpos .
endif .
use offset and get digit before decimal. Store it into V_hrs.
And multiply the decimal digits by 60 to get number of mins.
06-10-2011 9:19 AM
Try this
DATA:
str TYPE char10,
n1 TYPE p DECIMALS 2,
n2(2) TYPE n,
n3 TYPE t,
n4 TYPE p DECIMALS 2,
n5(6) TYPE c,
n6 TYPE p DECIMALS 2. .
n1 = '1.6'. "assign your value
n6 = '60'.
n2 = trunc( n1 ).
n4 = ( n1 - n2 ) * n6 .
n5 = '000000'.
n5(2) = n2.
n2 = n4.
n5+2(2) = n2.
n3 = n5.
WRITE n3 TO str.
WRITE: / 'Time =', str.