‎2006 Aug 18 12:43 PM
Hi,
I am having input field in 10 digit charecter format in BDC. I would like validate the date. Input date will in the mm/dd/yyyy format.
Regards
Chandra Reddy
‎2006 Aug 18 12:44 PM
‎2006 Aug 18 12:44 PM
Use 'DATE_CHECK_PLAUSIBILITY' for date check
data: lv_date type sy-datum,
lv_msg(50) type c.
lv_date = '20051314'.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = lv_date
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 into lv_msg.
write: lv_msg.
ENDIF.The above said FM is used to check whether the date is valid or not.
‎2006 Aug 18 12:45 PM
Hi,
use the released function module DATE_CHECK_PLAUSIBILITY
of function group SCON.
Regards, rob Dielemans
‎2006 Aug 18 12:45 PM
‎2006 Aug 18 12:48 PM
Use CONVERT_DATE_TO_INTERNAL .
if sy-subrc = 1, then it is invalid.
Regards,
ravi
‎2006 Aug 18 12:50 PM
in the control panel change ur date settings to mm/dd/yyyy
then use FM CONVERT_DATE_TO_INTERNAL , this will validate the date
‎2006 Aug 18 1:36 PM
By Using the FM convert_date_internal. It is forcing me to correct the date in the flat file. I want to check the date is valid or not. If valid subrc = 0.
Regards
Chandra Reddy
‎2006 Aug 18 1:41 PM
Hi chandu,
1. If valid subrc = 0.
The FM
CONVERT_DATE_TO_INTERNAL
is used in the same way as u want.
2. We pass the date
in the user format (mm/dd/yyyy)
and it will return sy-subrc = 0, if ok.
3. just copy paste to get a taste of it.
4.
report abc.
PARAMETERS : MYDATE(10) TYPE C DEFAULT '15.08.2006'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
DATE_EXTERNAL = MYDATE
ACCEPT_INITIAL_DATE =
IMPORTING
DATE_INTERNAL =
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
write 😕 'INVALID DATE'.
ELSE.
WRITE 😕 'VALID'.
ENDIF.
regards,
amit m.
‎2006 Aug 18 1:42 PM
Chandu,
U can use the below logic.
lurdate = '08/16/2006'. "from your file
concatenate lurdate6(4) lurdate(2) lurdate3(2)into ldate.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = ldate
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
write: 'invalid date'.
Regards
Anurag
‎2006 Aug 18 1:56 PM
Hi again,
1. The date will always be in the format
mm/dd/yyyyy
2. This format will be fixed
(independent of the user settings in r/3)
3. If thats the case, then
we can extract the year, month, date
from this character field (mm/dd/yyyy)
and check if date is ok or not.
4. Just copy paste.
(enter date on screen (in mm/dd/yyyy) format,
it will give message if ok / not ok.
5.
report abc.
data : DATE1 TYPE SY-DATUM.
*----
MM/DD/YYYY FORMAT
PARAMETERS : MYDATE(10) TYPE C DEFAULT '08/15/2006'.
*----
CONCATENATE MYDATE6(4) MYDATE0(2) MYDATE+3(2) INTO DATE1.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = DATE1
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE 😕 'INVALID DATE'.
ELSE.
WRITE 😕 'VALID'.
ENDIF.
regards,
amit m.
‎2006 Aug 18 1:58 PM
Direct Answer,
Use this Function Module: <b>RP_CHECK_DATE</b>
The input should be in MMDDYYYY (Std.) format.
Feel free to Reward Points