cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Abap Routine for Comparing Dates by sy-datum and sy-uzeit

tnecnivo
Active Contributor
0 Kudos
4,373

Hi BI/ABAP gurus,

I am trying to compare the fields DUE_TS.

DUE_TS consist of Timestamp of Due Date. (e.g. 20160130223025)


I then split DUE_TS timestamp into 2 parts, dates and times

My condition as below:-

If DUE_TS(dates) is Greater/Equal than system date and DUE_TS(time) is greater/equal than system time.

then show 'X'.

Else show '<blank>'.

My routine below doesn't seems to work.

Can anyone point out where the mistake might be?


DATA: date like sy-datum,

       time like sy-uzeit.

date = SOURCE_FIELDS-DUEDT+0(8).

time = SOURCE_FIELDS-DUEDT+8(6).

IF date GT sy-datum or

    date = sy-datum and time GT sy-uzeit.

RESULT = 'X'.

ELSE.

RESULT = ''.

ENDIF.


Many thanks.

View Entire Topic
RafkeMagic
Active Contributor
0 Kudos

try using brackets...


IF date GT sy-datum

OR ( date = sy-datum and time GT sy-uzeit ).

  RESULT = 'X'.

ELSE.

  RESULT = ''.

ENDIF.

tnecnivo
Active Contributor
0 Kudos

Hi Raf,

Thanks, your code works, and actually my initial codes works too, I just didn't scroll down and check thoroughly.

Kind regards