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

Date range validation

former_member182354
Contributor
0 Likes
2,587

I have a requirement where i have to check date range in select option and if its more than 45days the I have to give an Informatory message and exit the programme , How can I do that ??

Urgent Plzz..

1 ACCEPTED SOLUTION
Read only

former_member673464
Active Contributor
0 Likes
1,392

hi raghavender ,

You can subtract one date from other date and the result gives you the number of days.Use abbend message to display if it is greater than 45 days.

regards,

veeresh

6 REPLIES 6
Read only

Former Member
0 Likes
1,392
If not s_date-low is initial and
  not s_date-high is initial.
  diff = s_date-high - s_date-low.
  if diff GT 45.
  message e001(ZZ) with 'Enter date range within 45 
  days'.
  endif.

endif.

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

former_member673464
Active Contributor
0 Likes
1,393

hi raghavender ,

You can subtract one date from other date and the result gives you the number of days.Use abbend message to display if it is greater than 45 days.

regards,

veeresh

Read only

Former Member
0 Likes
1,392

hi

if s_date-low is not initial and s_date-high is not initial.

if s_date-high-s_date-low > 45.

message 'Enter a lower range' type 'E'.

endif.

endif.

if helpful, reward

Sathish. R

Read only

Former Member
0 Likes
1,392

Hi,

try this code...

TABLES: zpr_prog_item.

DATA: cnt TYPE i.

SELECT-OPTIONS date FOR zpr_prog_item-date_shoot.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = date-high

i_datum_von = date-low

IMPORTING

e_tage = cnt

EXCEPTIONS

DAYS_METHOD_NOT_DEFINED = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF cnt < 45.

LEAVE TO LIST-PROCESSING.

WRITE:/ date-low,

/ date-high,

/ cnt.

ELSE.

MESSAGE i000(zsam).

LEAVE SCREEN.

ENDIF.

regards,

Bhuvana.

Read only

Former Member
0 Likes
1,392

Hi Raghavender,

You can do it by following way.......



If not s_date-low is initial and
  not s_date-high is initial.
  w_diff = s_date-high - s_date-low.
  if w_diff GT 45.
  message e398(00) with 'Enter date range within 45 
  days'.
**for exiting the program you can use 
STOP.
  endif.
 
endif.

Thanks and Regards,

Kunjal Patel

Read only

Former Member
0 Likes
1,392

this is the code

select-options:

s_date type sy-tatum.

at selection-screen.

if s_date-high - s_date-low eq '45' .

message error

endif.