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

Background program to exit after a runtime limit

Former Member
0 Likes
618

Hi all, I have a program for a long time background processing (generating certain data exports from sap). I can schedule this program to be started at evening every day, but I also need to force it to exit itself after some time limit (at early morning).

I tried to use GET RUN TIME function, but unfortunately it returns microsedons olny in integer format, integer (4 bytes) can hold only cca 70 minutes (if you translate it to microsedonds). Doesn't matter if you use LOW or HIGH run time resolution.

I also tried the GET TIME STAMP function, but do not know how to substract the start and the current timestamps and how to get the result in minutes. It substracts them only in decimal format - not like a date format.

Please help if you have some idea...

Thanks, B. Riha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
578

Hi,

Check the below logic where P_DATE/P_TIME represent your start date/time & P_DATE1/P_TIME1 represent your current time stamping.

I couldn't find the exact function module you have mentioned, so tried to use simple math to calculate the difference in minutes. Hope this is of some help.

data : l_mins type i.
data : l_max type sy-uzeit value '240000'.
data : l_total type p.

parameters : p_time type sy-uzeit default '123108'.
parameters : p_date type sy-datum.
parameters : p_time1 type sy-uzeit default sy-uzeit.
parameters : p_date1 type sy-datum default sy-datum..

initialization.
p_date = sy-datum - 3.

start-of-selection.

if p_date1 = p_date.
   l_total = p_time1 - p_time.
else.
   l_mins =  ( p_date1 - p_date - 1 ) * 24 * 60.
   l_total = ( l_max - p_time ) + p_time1.
endif.
l_mins = l_mins + trunc( l_total / 60 ).

write : l_mins.

Thanks,

Pavan

3 REPLIES 3
Read only

Former Member
0 Likes
578

Hi,

You should look to improve the code.

[abap tips|http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp]

Cheers.

...Reward if useful.

Read only

Former Member
0 Likes
579

Hi,

Check the below logic where P_DATE/P_TIME represent your start date/time & P_DATE1/P_TIME1 represent your current time stamping.

I couldn't find the exact function module you have mentioned, so tried to use simple math to calculate the difference in minutes. Hope this is of some help.

data : l_mins type i.
data : l_max type sy-uzeit value '240000'.
data : l_total type p.

parameters : p_time type sy-uzeit default '123108'.
parameters : p_date type sy-datum.
parameters : p_time1 type sy-uzeit default sy-uzeit.
parameters : p_date1 type sy-datum default sy-datum..

initialization.
p_date = sy-datum - 3.

start-of-selection.

if p_date1 = p_date.
   l_total = p_time1 - p_time.
else.
   l_mins =  ( p_date1 - p_date - 1 ) * 24 * 60.
   l_total = ( l_max - p_time ) + p_time1.
endif.
l_mins = l_mins + trunc( l_total / 60 ).

write : l_mins.

Thanks,

Pavan

Read only

Former Member
0 Likes
578

Hi, thank you Pavan - I was able to solve my problem, the alghoritm you postet helped!

Thanks again.

B.