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 Field Validation

Former Member
0 Likes
1,276

HI Experts,

please help me how to validate the date field.

<<Text removed by moderator>>

Regards,

Sunita

Edited by: Matt on Nov 25, 2008 8:31 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,241

check FM DATE_CHECK_PLAUSIBILTY

10 REPLIES 10
Read only

Former Member
0 Likes
1,242

check FM DATE_CHECK_PLAUSIBILTY

Read only

Former Member
0 Likes
1,241

Hi,

Use select stmt


 AT SELECTION-SCREEN ON s_date.

SELECT SINGLE * 
         FROM table_name
         WHERE data_field  IN s_date.

  IF sy-subrc <> 0.
  message 'Error Message.' type 'E'.    
endif.

Thanks,

Krishna...

Read only

0 Likes
1,241

Hi

i tried this but its not working

any more inputs.

regards

sunita

Read only

0 Likes
1,241

HI,

Try this.

tables : bkpf.

Select-options : v_budat for bkpf-budat.(this is u r selection-screen field.)

select single * from bkpf where budat in v_budat.

Read only

0 Likes
1,241

hi,

tried this.it definitely works.

REPORT ZEX_DATEVALIDATE .

Parameters p_date like sy-datum.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

DATE = p_date

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 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.

Write:/ sy-subrc.

If the value of Sy-subrc is 0 that means the date field has a valid value.

If the input is 01/01/2008 then the output of the above program is as follows.

Validate the date

0

If the input is 31/31/2008 then the output is as follows.

Validate the date

1

thanks,

shanthi.k

Read only

Former Member
0 Likes
1,241

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = l_select_date

EXCEPTIONS

plausibility_check_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • date invalid

ENDIF.

Regards

Neha

Read only

Former Member
0 Likes
1,241

HI,

For date field validation you need not to do much

Just declare date field as type sy-datum and every validation will be managed internaly.

Syntax:

data:
   v_date type sy-datum.

OR

parameters:
         v_date type sy-datum.

Regards,

Anirban

Read only

Former Member
0 Likes
1,241

Hi,

Wat exactly you want to validate for date filed?

If you input any wrong data(including format) in the date field, system will throw an error.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,241

Hi,

As also said by others use the FM DATE_CHECK_PLAUSIBILITY:

If you are using a sekection screen than write it under the event at selection-screen on w_date, where w_date is your date field.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
     EXPORTING
          DATE                                         = p_date
     EXCEPTIONS
          PLAUSIBILITY_CHECK_FAILED   = 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 sy-subrc is 0 then the date field is valid otherwise show a message to enter date in correct format.

With luck,

Pritam.

Read only

Former Member
0 Likes
1,241

HI sunitha,

Sriram has said rightly,

if you enter a wrong format system throws an error.

let us know what validation you are looking for.

regards

Ramchander Rao.K