Application Development 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: 

Validation of Date Field

Former Member
0 Kudos

I Need to validate date fields in following manner ..

Date field must be parameter.

Start Date should always be 01.04.XXXX and End Date should always be 31.03.XXXX.

XXXX represents the current Year.

The the user can only change XXXX

Plzzz Help me...

8 REPLIES 8

Former Member
0 Kudos

Hi,

You can check it by using offsets in AT SELECTION SCREEN event..

in AT SELECTION SCREEN ON date1-low.

IF date1-low+0(2) NE '01'.

display your error message.

ENDIF.

IF date1-high NE '31'.

display msg.

ENDIF.

Former Member
0 Kudos

Hi,

p_startdate

p_enddate

IF p_startdate+4(4) NE '0401'.

..error.

ENDIF.

IF p_enddate+4(4) NE '0331'.

..error.

ENDIF.

0 Kudos

but the date field has to be initialised in the format 01.04.XXXX

XXXX Shows current year.

Former Member
0 Kudos

Hi,

Add 2 parameters to selection screen - Start year and end year.

In at selection screen event validate Start year and end year. If start year is bigger than end year, display error message.

Once years are entered correctly. Concatenate Start year with 0104 to get Start date and End year with 3103 to get End date.

Hope this approach helps. I have seen this question earlier. I hope this gets answered now.

ashish

Former Member
0 Kudos

Hi,

Try this..

SELECT-OPTIONS SO_DATE FOR SY-DATUM NO EXTENSION.

AT SELECTION-SCREEN.

  • get the select-option.

READ TABLE SO_DATE INDEX 1.

IF NOT ( SO_DATE-LOW4(2) = '04' AND SO_DATE-LOW6(2) = '01'

and SO_DATE-HIGH4(2) = '03' AND SO_DATE-LOW6(2) = '31' ).

MESSAGE E208(00) WITH 'Date not within the range'.

ENDIF.

Thanks

Naren

0 Kudos

Your code really worked...

But The input box for date has to be initialised in 01.04.XXXX.

where XXXX should always show the current year

0 Kudos

Try this

Data: l_date type sy-datum,

l_year(4) type c,

l_default_date(8) type c.

select-options s_date for sy-datum.

initialization.

l_date = sy-datum.

l_year = l_date(4).

CONCATENATE l_year '04' '01' INTO l_default_date.

s_date-low = l_default_date.

s_date-option = 'EQ'.

s_date-sign = 'I'.

append s_date.

Reward points if usefull

Regards,

Niyaz

Former Member
0 Kudos

Hi Milind,

Refer this code.

Select-options : S_date for sy-datum.

Initialization.

w_date = sy-datum.

w_year = w_date+0(4).

Concatenate w_year '04' '01' into d_date1.

Concatenate w_year '03' '31' into d_date2.

S_date-low = d_date1.

S_date-sign = 'I'.

S_date_option = 'EQ'.

append S_date.

S_date-high = d_date2.

S_date-sign = 'I'.

S_date_option = 'EQ'.

append S_date.

At selection-screen on value request for s_date.

If s_date-low4(2) ne '04' or If s_date-low6(2).

message e001.

endif.

If s_date-high4(2) ne '04' or If s_date-high6(2).

message e002.

endif.

Regards,

Hemant