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 is in valid format

Former Member
0 Likes
660

Hi,

I am uploading the data from the flat file to the internal table. I want to check whether the date is in valid format or not and pass the data to a BAPI. Is there any function Mdoule or any other way to do the validation.

The date format I want is yyyymmdd

Regards

Hema

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
593

Hi,

u can use DATE_CHECK_PLAUSIBILITY FM..

hope this helps.

regards,

chithra

4 REPLIES 4
Read only

Former Member
0 Likes
594

Hi,

u can use DATE_CHECK_PLAUSIBILITY FM..

hope this helps.

regards,

chithra

Read only

Former Member
0 Likes
593

Hi Hema,

You can use this FM:

<b>CONVERT_DATE_FORMAT</b>

<b>DATE_CHECK_PLAUSIBILITY</b>

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
593

Hi,

Try FM ISU_DATE_FORMAT_CHECK.

Regards,

Shashank

Read only

Former Member
0 Likes
593

hi..

you can use FM as

CONVERT_DATE_FORMAT

DATE_CHECK_PLAUSIBILITY

beyond that a macro can also be used at place to check the date validity as used in below program..

PROGRAM ZDATE_VALIDATE .

  • Validation of Date

DEFINE VAL_DATE.

CLEAR: %_DATE1,

%_DATE2.

%_DATE1(4) = &1. "Year

%_DATE1+4(2) = &2. "Month

%_DATE1+6(2) = &3. "Date

%_DATE2 = %_DATE1 - 1.

%_DATE2 = %_DATE2 + 1.

IF %_DATE1 <> %_DATE2.

SY-SUBRC = 1.

ELSE.

SY-SUBRC = 0.

ENDIF.

END-OF-DEFINITION.

DEFINE VALDATE.

***************************************************

  • Passing Parameters: &1 - Date

  • &2 - Date Format

*

  • Date Format:

  • DDMMYYYY MMDDYYYY YYYYMMDD YYYYDDMM

*

  • SY-SUBRC Return Value:

  • 1 invalid date

  • 0 Valid Date

  • 2 Invalid Format

***************************************************

DATA: %_DATE1 LIKE SY-DATUM ,

%_DATE2 LIKE SY-DATUM ,

%_DATE3(8).

case &2.

when 'DDMMYYYY'.

val_date &14(4) &12(2) &1+0(2).

when 'MMDDYYYY'.

val_date &14(4) &10(2) &1+2(2).

when 'YYYYMMDD'.

val_date &10(4) &14(2) &1+6(2).

when 'MMYYYYDD'.

val_date &12(4) &10(2) &1+6(2).

when others.

sy-subrc = 2.

endcase.

END-OF-DEFINITION.

***********************************************

  • SAMPLE USE of above MACRO *

***********************************************

DATA: V_DATE(8).

V_DATE = '30022002'.

*=>

VALDATE V_DATE 'DDMMYYYY'.

*=>

IF SY-SUBRC = 0.

WRITE:/ 'Valid Date'.

ELSEIF SY-SUBRC = 1.

WRITE:/ 'Invalid Date'.

ELSEIF SY-SUBRC = 2.

WRITE:/ 'Invalid Format'.

ENDIF.

*********************************************************************

*-- End of Program

hope it helps you..

regards,

Anananya.S