2008 Dec 18 11:44 AM
How to validate DATE format from Excel when we are uploading
i need to restrcit in date in excel sheet other the system format YYYYMMDD
While uploading using abap program to database.
i should not allow any other date format if user wrong date in excel while Extracting to internal table
Please provide me the solution for this
2008 Dec 18 11:52 AM
Hi,
Load your data in the internal table and use FM CONVERT_DATE_TO_INTERN_FORMAT
to convert into internal SAP date format.
If you just want to check the date format u can use the FM ISU_DATE_FORMAT_CHECK
Reg,
Raj
How to validate DATE format from Excel when we are uploading
i need to restrcit in date in excel sheet other the system format YYYYMMDD
While uploading using abap program to database.
i should not allow any other date format if user wrong date in excel while Extracting to internal table
Please provide me the solution for this
2008 Dec 18 11:48 AM
Hi Vijay,
As i understand, you get the input from an Excel file. Using the input, you prepare an internal table and upadte the database using the internal table. If this is correct,
then once you have the records in your internal table, before updating the database, you can check the date format.
Loop at itab into wa.
" check the format here.
Endloop.
Best Regards,
Ram.
2008 Dec 18 11:51 AM
Hi Vijay
Use 'DATE_CHECK_PLAUSIBILITY' for date check
and
'CONVERT_DATE_TO_INTERNAL'
'CONVERT_DATE_TO_EXTERNAL'
for conversions.
see following sample code. that will give u some idea.
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 &1+4(4) &1+2(2) &1+0(2).
when 'MMDDYYYY'.
val_date &1+4(4) &1+0(2) &1+2(2).
when 'YYYYMMDD'.
val_date &1+0(4) &1+4(2) &1+6(2).
when 'MMYYYYDD'.
val_date &1+2(4) &1+0(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 you use this .....
2008 Dec 18 11:52 AM
Hi,
Load your data in the internal table and use FM CONVERT_DATE_TO_INTERN_FORMAT
to convert into internal SAP date format.
If you just want to check the date format u can use the FM ISU_DATE_FORMAT_CHECK
Reg,
Raj
2008 Dec 19 6:48 AM
ISU_DATE_FORMAT_CHECK
can please check the name
i am getting FM does not exist
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |