‎2006 Mar 23 4:39 AM
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
‎2006 Mar 23 4:47 AM
Hi,
u can use DATE_CHECK_PLAUSIBILITY FM..
hope this helps.
regards,
chithra
‎2006 Mar 23 4:47 AM
Hi,
u can use DATE_CHECK_PLAUSIBILITY FM..
hope this helps.
regards,
chithra
‎2006 Mar 23 4:49 AM
Hi Hema,
You can use this FM:
<b>CONVERT_DATE_FORMAT</b>
<b>DATE_CHECK_PLAUSIBILITY</b>
Hope this will help.
Regards,
Ferry Lianto
‎2006 Mar 23 5:00 AM
‎2006 Mar 23 5:09 AM
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