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

Any Function Moduel Available to validate date

Former Member
0 Likes
1,382

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

11 REPLIES 11
Read only

suresh_datti
Active Contributor
0 Likes
1,350

try CONVERT_DATE_TO_INTERNAL

~Suresh

Read only

0 Likes
1,350

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.

Read only

Former Member
0 Likes
1,350

Hi,

use the released function module DATE_CHECK_PLAUSIBILITY

of function group SCON.

Regards, rob Dielemans

Read only

Former Member
0 Likes
1,350

Hi Chandu,

'DATE_CHECK_PLAUSIBILITY'

Refer this thread

call function 'DATE_CHECK_PLAUSIBILITY'
       exporting
            date                      = p_datum
       exceptions
            plausibility_check_failed = 1
            others                    = 2.

Read only

Former Member
0 Likes
1,350

Use CONVERT_DATE_TO_INTERNAL .

if sy-subrc = 1, then it is invalid.

Regards,

ravi

Read only

Former Member
0 Likes
1,350

in the control panel change ur date settings to mm/dd/yyyy

then use FM CONVERT_DATE_TO_INTERNAL , this will validate the date

Read only

Former Member
0 Likes
1,350

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

Read only

0 Likes
1,350

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.

Read only

0 Likes
1,350

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

Read only

Former Member
0 Likes
1,350

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.

Read only

Former Member
0 Likes
1,350

Direct Answer,

Use this Function Module: <b>RP_CHECK_DATE</b>

The input should be in MMDDYYYY (Std.) format.

Feel free to Reward Points