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

changing the system time

Former Member
0 Likes
2,496

Hi Friends,

I am printing the system time in one of the forms. Now I have to reduce the time by two hours. Is it possible for me to change the time by doing 'SY-UZEIT - 2'. If not please suggest me as to how to achieve this.

Thanks,

Raj

1 ACCEPTED SOLUTION
Read only

christian_wohlfahrt
Active Contributor
0 Likes
2,156

Hi Raj!

How about using

write sy-uzeit TIME ZONE tz.

For tz, a data object of type TIMEZONE from the ABAP Dictionary must be specified. It must contain a time zone from the column TZONE of the database table TTZZ in uppercase letters. If tz is initial, the UTC reference time is output.

Have a look into the statement documentation for more details.

Regards,

Christian

14 REPLIES 14
Read only

Former Member
0 Likes
2,156

Hi

SY-UZEIT is system time, so you can change it, I don't understand why you want to update it, but you can use a variable:

DATA: NEW_TIME TYPE SY-UZEIT.

A) Minus 2 second: NEW_TIME = SY-UZEIT - 2.

B) Minus 2 minute: NEW_TIME = SY-UZEIT - 120.

C) Minus 2 hours : NEW_TIME = SY-UZEIT - 7200.

Max

Read only

Former Member
0 Likes
2,156

Hi,

data: v_time type syuzeit.

v_time = sy-uzeit - 7200.

write: / sy-uzeit.

write: /'Minus 2 hours - ', v_time.

Thanks,

Naren

Read only

0 Likes
2,156

I need to do this in the text editor. Can I use the same in the text editor?

Raj

Read only

Former Member
0 Likes
2,156

data: time type sy-uzeit.

<b>Time = sy-uzeit - 7200.</b>

Regards,

Prakash.

Read only

christian_wohlfahrt
Active Contributor
0 Likes
2,157

Hi Raj!

How about using

write sy-uzeit TIME ZONE tz.

For tz, a data object of type TIMEZONE from the ABAP Dictionary must be specified. It must contain a time zone from the column TZONE of the database table TTZZ in uppercase letters. If tz is initial, the UTC reference time is output.

Have a look into the statement documentation for more details.

Regards,

Christian

Read only

Former Member
0 Likes
2,156

Hi,

I believe you cannot declare time specific data type in the Sap script editor..

And it has to be done in the print program..

If you are having smartforms..you can do it initialization event..

THanks,

Naren

Read only

0 Likes
2,156

Hi

You can try to create a form and call it in the sapscript.

/: DEFINE &MY_TIME& = ' '

/: PERFORM CHANGE_TIME IN PROGRAM <Z....>

/: CHANGING &MY_TIME&

/: ENDPERFORM

In program Z.... you have to define the routine

FORM CHANGE_TIME TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

DATA: NEW_TIME TYPE SY-UZEIT.

READ TABLE OUT_TAB INDEX 1.

IF SY-SUBRC = 0.

NEW_TIME = SY-UZEIT - ......

WRITE NEW_TIME TO OUT_TAB-VALUE.

MODIFY OUT_TAB INDEX 1.

ENDIF.

ENDFORM.

Max

Read only

0 Likes
2,156

Just one more question. I am printing this time in text editor next to one more field. Do I use continuation or just define it from the next line.

Thanks,

Raj

Read only

0 Likes
2,156

Thanks Max. That solved my problem. I've awarded points to you.

Raj

Read only

0 Likes
2,156

Max,

I have a problem again. My company is located in US and in London. This form is being used even in London. Th server is taking London time and so for US orders I subtracted two hours from the system time. Now I need to add a condition in the program that the system takes the system time at London and subtract the two hours in USA. Can you give me the code for this.

Thanks,

Raj

Read only

0 Likes
2,156

Hi

I believe you should check the user data there you can find the Time zone of the user.

In the system variable SY-TZONE you have the time zone of the server and in SY-ZONLO user one.

Max

Read only

0 Likes
2,156

Max,

since I am trying to print the time, I have used SYST-TIMLO which is the local time of the user, but did not work. Would you suggest if that can be made to work?

Thanks,

Raj

Read only

Former Member
0 Likes
2,156

Hi,

For sy-timlo see the documentation..

In the following cases, the local time cannot be calculated:

- The time zone has not been entered in the user master record

or

- The time zone in the user master record is invalid

or

- The time zones are inactive (table TTZCU).

If this happens, the system time (SYST-UZEIT) is returned.

Thanks,

Naren

Read only

0 Likes
2,156

Narendran,

My system is returning Sy-UZEIT same as you mentioned. What would be my other option? Please advice.

Thanks,

Raj