on 2016 Mar 10 6:45 AM
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.
Request clarification before answering.
try using brackets...
IF date GT sy-datum
OR ( date = sy-datum and time GT sy-uzeit ).
RESULT = 'X'.
ELSE.
RESULT = ''.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this
IF date GT sy-datum.
RESULT = 'X' .
ELSEIF date EQ. sy-datum and time GT sy-uzeit.
RESULT = 'X' .
ENDIF .
ELSE
RESULT = ''.
ENDIF.
Just check the nesting, I did not type it in ABAP editor, might have missed some endif.
You might call the method if available in your system.
CALL METHOD cl_abap_tstmp=>compare
EXPORTING
tstmp1 = timestamp1
tstmp2 = timestamp2
receiving
comp = result1.
result1 = -1/,0,/1 lower, equal , greater . Accordingly calculate ur result.
Regards
Anindya
Regards
Anindya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yup, just compiled the code . There were some other problem as well.
Method 1 :
IF date GT sy-datum.
RESULT = 'X' .
ELSEIF date EQ sy-datum and time GT sy-uzeit.
RESULT = 'X' .
ELSE.
RESULT = ''.
ENDIF.
Method 2 :
data temp type I .
CALL METHOD cl_abap_tstmp=>compare
EXPORTING
tstmp1 = 20160310093701 "was checking with constant values.
tstmp2 = 20160310093700
receiving
comp = temp.
Based on temp, you can calculate Result .
Documentation available here. ABAP Keyword Documentation
Regards
Anindya
User | Count |
---|---|
31 | |
15 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.