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: 

FM for validating date coming from a file

Former Member
0 Kudos

HI All,

I have to validate date that needs to be validated before passing it to DB.

Is der any FM for same

I tried CONVERT_DATE_TO_INTERNAL.

But it accepts date only in one specified format.

6 REPLIES 6

Former Member
0 Kudos

Try using DATE_CHECK_PLAUSIBILITY

0 Kudos

I want to pass date as 12/31/2009

but it accepts 12312009

0 Kudos

Use

REPLACE all OCCURRENCES OF '/' in lw_endda with '.'.

REPLACE all OCCURRENCES OF '/' in lw_begda with '.'.

0 Kudos

Hi,

Try below mentioned logic because SAP is accepting YYYYMMDD format only,

data: a(10) type c value '23/09/2009'.

data: d(2) type n,

m(2) type n,

y(4) type n.

data: date(8).

split a at '/' into d m y.

concatenate y m d into date.

write:/ date.

-Rajneesh Gupta

0 Kudos

Hi,

This is very simple...try using the below mention steps

1.Declare 3 var of type c with lenght d(2),m(2)and yr(4)

2.split your date at '/ into the above variables

3.concatenate the variables and pass the concatenated values to the FM

This will definetly helps you and solve your problem.

Pooja

Former Member
0 Kudos

hi,

try this

Use Function module DATE_CHECK_PLAUSIBILITY to validate a date.

1)If you given a invalidate date then it will ask you to enter a valid date.

2)After changing it to correct value, you can click on SAVE button or if you want to continue with the invalid date then click on USE INVALID VALUE button.

Try with this code.

PARAMETER P_DATE TYPE SYDATUM.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = P_DATE

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

OTHERS = 2.

IF sy-subrc 0.

MESSAGE E000(ZI) WITH 'INPUT DATE IS INVALID DATE'.

ENDIF.

Regards,

RItesh J