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

Logic based on Date on Selection-Screen

Former Member
0 Likes
1,492

Dear friends,

I've been writing a report in which I have the date field on selection-screen. By default I have been displaying the system date on the selection-screen.

The reqiurement is that the user cannot execute the code for a date in past (less than the system date) or cannot give a date less than the sytem date

but can execute the same for a date in future (greater than the system date).

Can any one give me the logic for the same.

Regards,

Alok.

1 ACCEPTED SOLUTION
Read only

varma_narayana
Active Contributor
0 Likes
1,229

Hi

This is the code for u.

PARAMETERS : P_DATE TYPE SY-DATUM .

INITIALIZATION.

MOVE SY-DATUM TO P_dATE.

AT SELECTION-SCREEN ON P_DATE.

IF P_DATE < SY-DATUM.

MESSAGE 'Entered date cannot be in Past' Type 'E'.

**Raise any message that u created otherwise

ENDIF.

<b>Reward if Helpful</b>

6 REPLIES 6
Read only

varma_narayana
Active Contributor
0 Likes
1,230

Hi

This is the code for u.

PARAMETERS : P_DATE TYPE SY-DATUM .

INITIALIZATION.

MOVE SY-DATUM TO P_dATE.

AT SELECTION-SCREEN ON P_DATE.

IF P_DATE < SY-DATUM.

MESSAGE 'Entered date cannot be in Past' Type 'E'.

**Raise any message that u created otherwise

ENDIF.

<b>Reward if Helpful</b>

Read only

Former Member
0 Likes
1,229

Hi

write the logic in the event at selection-screen on <date field>

if p_date < sy-datum.

message e000 with 'enter a data in the future'.

endif.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
1,229

AT SELECTION-SCREEN.

IF s_date LE sy-datum.

MESSAGE e001(error) WITH 'Date should be greater than system date'.

ENDIF.

ENDIF.

try using the above code.

reward if useful

Read only

Former Member
0 Likes
1,229

Report Z10_SB_DATE MESSAGE-ID Z10SBAN.

AT SELECTION-SCREEN.

if d_date < sy-datum.

message e001 with d_date.

endif.

What this will do is that if the date(d_date) entered is less than current date,

an error message 001 (from message id z10sban) will be flashed in re

at the bottom and the execution will terminate then and there it self.

Read only

kiran_k8
Active Contributor
0 Likes
1,229

Alok,

if s_datum > sy-datum.

perform getdata.

else.

MESSAGE e034(zal) WITH s_datum.

In the message class zal give an message for 034.

In the subroutine getdata write the code.

K.Kiran.

Message was edited by:

Kiran K

Read only

Former Member
0 Likes
1,229

Hi

parameters p_date like sy-datum default sy-datum.

at selection-screen.

if p_date < sy-datum.

message w003(zf).

endif.