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

Calculation Problem

rahul2000
Contributor
0 Likes
449

Dear all,

I am doing something like this

W_CTIME = ( WA_VBRK-ERDAT - WA_LIKP-ERDAT + WA_VBRK-ERZET - WA_LIKP-ERZET ).

.

But the moment my

WA_LIKP-ERZET is greater than WA_VBRK-ERZET my calculation goes wrong.

w_ctime is of type MKPF-CPUTM.

cAN ANYONE HELP?

4 REPLIES 4
Read only

former_member386202
Active Contributor
0 Likes
428

Hi,

You should fallow the BODMAS rule

Try like this

W_CTIME = ( WA_VBRK-ERDAT - WA_LIKP-ERDAT ) + ( WA_VBRK-ERZET - WA_LIKP-ERZET ).

Regards,

Prashant

Read only

Nawanandana
Active Contributor
0 Likes
428

hai

can u plz send me ur requirement clearly coz we cant recadnize ur data error or type problem..

regard

nawa

Read only

Former Member
0 Likes
428

hi,

if WA_VBRK-ERDAT > WA_LIKP-ERDAT.

W_CTIME = ( WA_VBRK-ERDAT - WA_LIKP-ERDAT + WA_VBRK-ERZET - WA_LIKP-ERZET ).

else if WA_VBRK-ERDAT < WA_LIKP-ERDAT.

W_CTIME = ( WA_LIKP-ERDAT-WA_VBRK-ERDAT + WA_VBRK-ERZET - WA_LIKP-ERZET ).

endif.

hope this will be helpful.

regrds,

karthik

Read only

Former Member
0 Likes
428

Hi,

If you calculate directly the hour/min calculation will not be done. multiply the date difference with 3600 (i.e., 60 * 60 )

Use the below logic for calculation.

l_f_date = WA_VBRK-ERDAT,

l_f_date1 = WA_LIKP-ERDAT.

l_f_time1 = WA_VBRK-ERZET

l_f_time2 = WA_LIKP-ERZET.

if l_f_date >= l_f_date1.

if l_f_time1 > l_f_time2.

l_f_time = ( ( l_f_date - l_f_date1 ) * 60 * 60 ) + ( l_f_time1 -

l_f_time2 ).

endif.

else.

if l_f_time1 >= l_f_time2.

l_f_time = ( ( l_f_date1 - l_f_date ) * 60 * 60 ) + ( l_f_time1 -

l_f_time2 ).

else.

l_f_time = ( ( l_f_date - l_f_date1 ) * 60 * 60 ) + ( l_f_time2 -

l_f_time1 ).

endif.

endif.

Hope this helps you.