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

Add or reduce sy-uzeit

Former Member
0 Likes
5,169

Hi all

How can i add or reduce a value to the field sy-uzeit?

i want to do this, for example

sy-uzeit = 103358

da_uzeit = 040000

da_uzeit = da_uzeit + sy-uzeit = 143358

which fm can i use? it's possible to do this??

Thanks for your help

Gregory

1 ACCEPTED SOLUTION
Read only

franois_henrotte
Active Contributor
0 Likes
2,792

if both variables are type T then you can just use +

data: time1 type t,

time2 type t.

time1 = '012030'.

time2 = '100102'.

time1 = time1 + time2.

==> time1 = '112132'

time1 = '112030'.

time2 = '180102'.

time1 = time1 + time2.

==> time1 = '052132'

7 REPLIES 7
Read only

Former Member
0 Likes
2,792

Hi!

Try using this FM:

EWU_ADD_TIME

You have to give the date also, because of the possible time overflow to the next day... For example if it is 20 o'clock and you wanted to add 10, it will be tomorrow 06...

Regards

Tamá

Read only

0 Likes
2,792

hi

This fm work, but i forgot to say that i'm working in CRM. This FM don´t exist in CRM.

Thanks

Gregory

Read only

0 Likes
2,792

Hi Gregory..

If the standard SAP function module is not available, you can write your own. If you are going to use this at lot many places, then go and create a new FM.

Take Import parameters as TIME1 type sy-uzeit and TIME2 type sy-uzeit, and OPTION type char1. and Export parameter as TIME_OUT.

In the logic, check the value of OPTION, (A for add, S for subtract).

IF OPTION eq 'A'.

TIME_OUT = TIME1 + TIME2.

ELSEIF OPTION eq 'S'.

TIME_OUT = TIME1 - TIME2.

ENDIF.

Thanks and Best Regards,

Vikas Bittera.

**Points for useful answers**

Read only

franois_henrotte
Active Contributor
0 Likes
2,793

if both variables are type T then you can just use +

data: time1 type t,

time2 type t.

time1 = '012030'.

time2 = '100102'.

time1 = time1 + time2.

==> time1 = '112132'

time1 = '112030'.

time2 = '180102'.

time1 = time1 + time2.

==> time1 = '052132'

Read only

Former Member
0 Likes
2,792

Hi,

You can use one of the below function modules

ADD_TIME_TO_DATE

EWU_ADD_TIME

C14B_ADD_TIME

Regards

Sudheer

Read only

Former Member
0 Likes
2,792

Hi

Ready it's solved. i created a new FM in CRM

Thanks for your helps

Regards

Gregory

Read only

Former Member
0 Likes
2,792

Hi Gregory,

Look this, maybe can help you.

Here have three PARAMETERS (Hrs, Mins and Secs), and two radiobuttons (add and subt), is easy to understand.

DATA: TIME(6),

NUM(6),

HOUR(8),

H(3),

M(3),

S(3).

SELECTION-SCREEN BEGIN OF BLOCK BLC WITH FRAME TITLE TEXT-001.

PARAMETERS: HOU(2),

MIN(2),

SEC(2),

RBADD RADIOBUTTON GROUP 001,

RBSUBT RADIOBUTTON GROUP 001.

SELECTION-SCREEN END OF BLOCK BLC.

TIME = SY-UZEIT.

IF RBADD = 'X'.

H = TIME+0(2) + HOU.

M = TIME+2(2) + MIN.

S = TIME+4(2) + SEC.

ELSE.

H = TIME+0(2) + 23 - HOU.

M = TIME+2(2) + 59 - MIN.

S = TIME+4(2) + 60 - SEC.

ENDIF.

WHILE S >= 60.

M = M + 1.

S = S - 60.

ENDWHILE.

WHILE M >= 60.

H = H + 1.

M = M - 60.

ENDWHILE.

WHILE H >= 24.

H = H - 24.

ENDWHILE.

CONCATENATE H(2) ':' M(2) ':' S(2) INTO HOUR.

WRITE: HOUR.

Regards

Allan Cristian