cancel
Showing results for 
Search instead for 
Did you mean: 

dates validation

Former Member
0 Kudos

hi all,

i am accepting a file from presentation server and updating the same in DB. if i give special characters also it is accepting. can anybody tell me how to validate the dates.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ateeq,

U can use the FM, 'DATE_CHECK_PLAUSIBILITY' to check whether a date is valid or not.

Regards,

Phani

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Ateeq,

Try this...

data: lv_date type sy-datum,
      lv_msg(50) type c.
lv_date = '20051314'.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
  EXPORTING
    DATE                            = lv_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 into lv_msg.
 write: lv_msg.
ENDIF.

The above said FM is used to check whether the date is valid or not.

As sasikumar said you can also use the FM, 'CONVERT_DATE_TO_INTERNAL' to check the validity of date.

hope this might help you.

Regards,

Phani

Message was edited by: Phani Kumar Sivapuram

Former Member
0 Kudos

You can call the FM 'CONVERT_DATE_TO_INTERNAL' as described by sasi earlier, and if the FM returns an error, you can send that record to the corresponding error table that you maintain.

This is what you would have to do:

if sy-subrc <> 0.

<move record to error itab>

endif.

Hope this helps.

Sudha

Former Member
0 Kudos

u can use FM DATE_CHECK_PLAUSIBILITY

rgds,

PJ

Former Member
0 Kudos

hai guys, my problem has been solved by using both the functions... but i am dilemma to allocate points.

Message was edited by: Ateeq K

Former Member
0 Kudos

hi,

l_date type d

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = '10023/39'

IMPORTING

DATE_INTERNAL = l_date

EXCEPTIONS

DATE_EXTERNAL_IS_INVALID = 1

OTHERS = 2

i don't thing so it give error

after this fm using sy-subrc you check whether the date is value or not

If sy-subrc <> 0

move to error table

endif

cheers,

sasi

Former Member
0 Kudos

hi,

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

DATE_EXTERNAL = file_date

IMPORTING

DATE_INTERNAL = l_date

EXCEPTIONS

DATE_EXTERNAL_IS_INVALID = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

date is invalid

ENDIF.