09-12-2008 1:15 PM
Hi Fox,
The bellow coding should terminate the function after a certain time in seconds (as input parameter) and displays the variable count. But it terminates at the end with the short dump since the count becomes an overflow. Thanks for you help.
Function xxxx
import: time_out type i.
DATA: c_syuzeit TYPE sy-uzeit,
count TYPE i.
c_syuzeit = sy-uzeit.
c_syuzeit = c_syuzeit + time_out.
WHILE c_syuzeit > sy-uzeit.
ADD 1 TO count.
ENDWHILE.
ENDFUNCTION xxx.
09-12-2008 2:11 PM
Hi,
Sy-uzeit will always contain the time the report has been launched (it will not change during runtime). To update this variable you can use the ABAP command "GET TIME".
Kind regards,
John.
09-12-2008 1:20 PM
09-12-2008 1:22 PM
what is the problem?
here: WHILE c_syuzeit > sy-uzeit.
ADD 1 TO count.
ENDWHILE.
the value of syuzeit is not changed at all, which means the condition (c_syuzeit > sy-uzeit) will remain true for ever (or until count is overflown)
09-12-2008 1:28 PM
well I thought the sy-uzeit is refreshed by the system automatically, isn't it like this ?
09-12-2008 1:33 PM
>
> well I thought the sy-uzeit is refreshed by the system automatically, isn't it like this ?
But your
c_syuzeit = sy-uzeit.
c_syuzeit = c_syuzeit + time_out.
condition would also be refreshed again if sy-uzeit is refreshed by the system automatically.
means again ENDLESS loop found
Amit.
09-12-2008 1:41 PM
>
> well I thought the sy-uzeit is refreshed by the system automatically, isn't it like this ?
yeah, you must be right. Than probably the counter was too big, could you please try with smaller, like 1?
09-12-2008 1:50 PM
>
> Hi Fox,
I guess the endless loop will continue until Fox responds..
~Suresh
09-12-2008 1:57 PM
>
> >
> > well I thought the sy-uzeit is refreshed by the system automatically, isn't it like this ?
>
> yeah, you must be right. Than probably the counter was too big, could you please try with smaller, like 1?
I Guess Sy-uziet would not be refreshed as the while loops goes on.
I found Sy-uziet remain same in below piece of code:
DATA: c_syuzeit TYPE sy-uzeit,
count TYPE i.
data: time_out type i value '1'.
c_syuzeit = sy-uzeit.
c_syuzeit = c_syuzeit + time_out.
(Break-point)WHILE c_syuzeit > sy-uzeit.
ADD 1 TO count.
ENDWHILE.
PS:since Function would not be called in Recursive way.
Amit.
09-12-2008 2:00 PM
>
> I Guess Sy-uziet would not be refreshed as the while loops goes on.quote}
I have also read it somewhere, I just could not find it now.
I tried the following piese of code and sy-uzeit changes:
WRITE : / sy-uzeit.
WAIT UP TO 2 SECONDS.
WRITE : / sy-uzeit.
So, probably in some cases it changes, in some not. Would be great to know exactly when
09-12-2008 2:03 PM
>
> >
> > I Guess Sy-uziet would not be refreshed as the while loops goes on.quote}
>
> I have also read it somewhere, I just could not find it now.
>
> I tried the following piese of code and sy-uzeit changes:
> WRITE : / sy-uzeit.
> WAIT UP TO 2 SECONDS.
> WRITE : / sy-uzeit.
>
> So, probably in some cases it changes, in some not. Would be great to know exactly when
My quess is that wait up to n seconds is just a sap macro (such as break username) which actually uses the get time statement in order to calculate the seconds.
Kostas
09-12-2008 1:24 PM
Hi,
in this:
WHILE c_syuzeit > sy-uzeit.
ADD 1 TO count.
ENDWHILE.
You don't change any value of c_syuzeit and sy-uzeit, therefore you get an endless loop.
Change any value of them an insert an exit-contition.
Regards, Dieter
09-12-2008 1:49 PM
09-12-2008 1:52 PM
this is not correct since
c_syuzeit = sy-uzeit.
c_syuzeit = c_syuzeit + time_out.
are not part of the loop
09-12-2008 1:57 PM
Hi,
sy-uzeit will not refresh automatically. You should add the get time statement.
e.g
DATA: c_syuzeit TYPE sy-uzeit,
count TYPE i.
c_syuzeit = sy-uzeit.
c_syuzeit = c_syuzeit + time_out.
WHILE c_syuzeit > sy-uzeit.
get time.
ADD 1 TO count.
ENDWHILE.
Kostas
09-12-2008 2:19 PM
Hi Kami,
Well Well Well!!!!!!!!
I got the mistake u r doing.
Check below code.
DATA: time TYPE sy-uzeit,
counter TYPE i.
time = sy-uzeit + 3.
WHILE time > sy-uzeit.
ADD 1 TO counter.
ENDWHILE.
WRITE:/1 'counter = ', counter.
Just debug this code. It works fine without any issues.
But if u directly execute the same code it gives timeout.
Here is the explanation.
When u debug for each statement COMMIT WORK will be executed and system fields will be updated like date, time.
(U can see the status message COMMIT WORK executed by the system.) But when u execute directly COMMIT WORK happend for the whole code once.
So sy-uzeit will ramain same in the loop.
So this condition will never fails.
Hope u understand.
Thanks,
Vinod.
09-12-2008 1:37 PM
Hello
1. Declare count TYPE p.
2. Quite unnecessary increase counter. Try simple count = 0.
09-12-2008 1:50 PM
09-12-2008 2:12 PM
that would process synchronous processing and this is not expected.
09-12-2008 2:11 PM
Hi,
Sy-uzeit will always contain the time the report has been launched (it will not change during runtime). To update this variable you can use the ABAP command "GET TIME".
Kind regards,
John.
09-12-2008 2:14 PM
09-12-2008 2:23 PM
see note 24094:
Summary
Symptom
Although a program runs for what is clearly a long time, the System time field remains at the same value.
Cause and prerequisites
The system time is only occasionally updated (usually only after screen display).
Solution
Use the key word GET TIME, ....
. . .
Header Data
Release Status:
Released on: 31.07.1995 22:00:00
Priority:
Category:
Primary Component: BC-ABA
Affected Releases
Release-Independent