Application Development 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: 

sy-uzeit is only initialized once?

Former Member
0 Kudos

I have written a simple program:

1, Assign sy-uzeit to a time variable: tm_start

2, Loop 100000 times

3, Get the seconds difference between current sy-uzeit and tm_start

The difference is always 0 even if the loop runs moe than a minute.

If I debug the program, sy-uzeit is only initialized in the beginning of the problem.

During the program, it will not be updated anymore.

Does anyone know how to update sy-uzeit to make it up-to-date?

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Atish,

Thanks for your input.

I have the same understanding as you before I create this testing program.

If you run my program, debug and stop at do loop for more than a minute, you can find the strange result.

13 REPLIES 13

former_member156446
Active Contributor
0 Kudos

do one thing... send the sy-uzeit into a varaible vl_initial... and send the time to vl_final after the loop and check the difference... it should be an alternative...

vl_initial = sy-uzeit.

loop at

endloop.

vl_final = sy-uzeit.

write:/ 'diff:' , vl_final - vl_intial.

Former Member
0 Kudos

assign sy-uzeit to a varaible v_timevl_initial = sy-uzeit.

loop at

v_timevl_initial = sy-uzeit.

write:/ 'diff:' , vl_final - v_timevl_initial .

endloop.

Former Member
0 Kudos

Thanks for the update.

This is my program:

tm_start = sy-uzeit.

BREAK-POINT.

DO 100000 TIMES.

ENDDO.

tm_diff = sy-uzeit - tm_start.

WRITE / tm_diff.

The tm_diff is always 0.

So that's why I suspected that the sy_uzeit is only initiated once.

Hope I have explained myself clearly this time.

_

0 Kudos

data tm_start type sy-uzeit.

data tm_diff type sy-uzeit.

tm_start = sy-uzeit.

wait up to 10 seconds.

tm_diff = sy-uzeit - tm_start.

WRITE / tm_diff.

matt
Active Contributor

sy-uzeit is fixed throughout the run of a program unless you use GET TIME.

GET TIME sets sy-uzeit to the current time.

matt

Former Member
0 Kudos

Good morning, everyone.

Former Member
0 Kudos

Use GET TIME STAMP FIELD to get the current time.

Regards,

Atish

Former Member
0 Kudos

Thanks Atish.

The statement, which is provided by you, need the DDIC data type to store the time stamp result.

And it does serve the purpose.

But regarding my question about sy-uzeit, do you have any clarification for it?

0 Kudos

Hi David,

It is not that sy-uzeit is intialized once. The reason as why you are getting difference always zero is the difference is less than a second. Sy-uzeit can have minimum value as Seconds only. It can't have milliseconds or microseconds thats why I suggested the other keywords.

Regards,

Atish

Former Member
0 Kudos

Hi Atish,

Thanks for your input.

I have the same understanding as you before I create this testing program.

If you run my program, debug and stop at do loop for more than a minute, you can find the strange result.

0 Kudos

HI,

try like this.


DATA:tm_start TYPE SY-UZEIT,
     tm_end TYPE sy-uzeit,
     tm_diff(2).

GET TIME FIELD tm_start.

DO 10000 TIMES.

ENDDO.

GET TIME FIELD tm_end.

tm_diff = tm_end - tm_start.

WRITE:/ tm_diff.

rgds,

bharat.

Former Member
0 Kudos

Hi Matt,

Your answer is quite helpful.

And it's the answer that I'm chasing by this post.

Anyway, I'm a newbie.

So Bharat's source code is more understandable for me.

Hence I marked Bharat's answer as solved problem at the first glance.

Thank you so much for your great help!

David.

matt
Active Contributor
0 Kudos

Fine - I'm not a points hunter! But your question was re an already written program.

>I have written a simple program:

>1, Assign sy-uzeit to a time variable: tm_start

>2, Loop 100000 times

>3, Get the seconds difference between current sy-uzeit and >tm_start

>The difference is always 0 even if the loop runs moe than a minute.

All you had to do with your already written program was use GET TIME, on it's own, with no additions, before you read sy-uzeit.

Cheers

matt