Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

convert quantity field to timestamp

Madhurivs23
Participant
0 Likes
657

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
575

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.

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

2 REPLIES 2
Read only

Former Member
0 Likes
575

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.

Read only

Former Member
0 Likes
576

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.