‎2006 Nov 28 4:04 AM
hi,
i am uploading text file from user containing date. i want to validate this date , how can i do that bcoz user can enter the date in various format.how can i do that?
regards
nilesh
‎2006 Nov 28 4:06 AM
hi,
use this.
DATA: v_date TYPE sydatum.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = v_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'INvalid date'.
ELSE.
WRITE: / 'Correct date'.
ENDIF.rgds
anver
‎2006 Nov 28 4:06 AM
hi,
use this.
DATA: v_date TYPE sydatum.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = v_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'INvalid date'.
ELSE.
WRITE: / 'Correct date'.
ENDIF.rgds
anver
‎2006 Nov 28 4:09 AM
‎2006 Nov 28 4:12 AM
Check this...
DATA: v_char(6).
v_char = '121706'.
DATA: v_date TYPE sydatum.
v_date+4(2) = v_char(2).
v_date6(2) = v_char2(2).
CONCATENATE '20' v_char+4(2) INTO v_date(4).
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = v_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'INvalid date'.
ELSE.
WRITE: / 'Correct date'.
ENDIF.
‎2006 Nov 28 5:24 AM
hi,
<b><i>hope ur issue solved.
if so pls close the thread after marking all helpful answers,</i></b>
rgds
Anver
‎2006 Nov 28 6:28 AM
i am passing the value 28112006 but still this function returns invalid date(sy-subrc=1), which date format should i pass.
regards
martin
‎2006 Nov 28 6:30 AM
‎2006 Nov 28 6:35 AM
ya i am passing value using a variable of type sy-datum though it is not working.
always gives me sy-subrc = 1.
regards
martin
‎2006 Nov 28 5:43 AM
hi
good
try this function moudle
DATE_CHECK_PLAUSIBILITY Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.
thanks
mrutyun^
‎2006 Nov 28 7:02 AM
try to pass this as a parameter .
this should be like ur user settings date .
like mm/dd/yyyy or mm.dd.yyyy
since u r referring to type sy-datum in the selection screen itself if u pass a wrong format this will throw an error .
execute the code ..
parameters : p_datum like sy-datum.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = p_datum
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc <> 0 .
WRITE: / 'Wrong format in date'.
ELSE.
WRITE: / 'Correct date'.
ENDIF.regards,
vijay