‎2008 May 25 8:05 AM
Dear experts,
Let's say I have a blocking date and time period
12/05/2008 23:00 and
13/05/2008 07:00.
And now my problem is how do I program to check whether the current time is within the given time period as mentioned above?
Say, the current date and time now is 12/05/2008 23:45. Is there any standard function can validate it?
Thanks for everyone will can provide the answer.
‎2008 May 25 9:59 AM
You can the current date and time from the systems variables SY-DATM and SY-UZEIT. Write a code as:
PARAMETERS: p_date1 TYPE datum obligatory,
p_time1 TYPE syuzeit obligatory,
p_date2 TYPE datum obligatory,
p_time2 TYPE syuzeit obligatory.
AT SELECTION-SCREEN.
IF sy-datum NOT BETWEEN p_date1 AND p_date2.
MESSAGE e001(ztest) WITH 'Invalid Date'.
ELSEIF sy-datum = p_date1.
IF NOT sy-uzeit GE p_time1.
MESSAGE e001(ztest) WITH 'Invalid Time'.
ENDIF.
ELSEIF sy-datum = p_date2.
IF NOT sy-uzeit lE p_time2.
MESSAGE e001(ztest) WITH 'Invalid Time'.
ENDIF.
ENDIF.
Hope this code helps.
‎2008 May 25 8:15 AM
hi there....
the current date is stored in the system variable sy-datum and the current time resides in sy-uzeit. So u can use these two variables to check whether the current time and date is within ur defined limits. to define the limit, make sure the variables which hold the value of ur limiting date and time, should be declared as of type sy-datum and sy-uzeit.
Do reward if helpful or get back if u hav further queries.
‎2008 May 25 9:59 AM
You can the current date and time from the systems variables SY-DATM and SY-UZEIT. Write a code as:
PARAMETERS: p_date1 TYPE datum obligatory,
p_time1 TYPE syuzeit obligatory,
p_date2 TYPE datum obligatory,
p_time2 TYPE syuzeit obligatory.
AT SELECTION-SCREEN.
IF sy-datum NOT BETWEEN p_date1 AND p_date2.
MESSAGE e001(ztest) WITH 'Invalid Date'.
ELSEIF sy-datum = p_date1.
IF NOT sy-uzeit GE p_time1.
MESSAGE e001(ztest) WITH 'Invalid Time'.
ENDIF.
ELSEIF sy-datum = p_date2.
IF NOT sy-uzeit lE p_time2.
MESSAGE e001(ztest) WITH 'Invalid Time'.
ENDIF.
ENDIF.
Hope this code helps.