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

Which Function Module to check validity of a date?

Former Member
0 Likes
4,727

Hi all,

Which function module can use to check the validity of a date? For example, if user key in 20060931 or 20060940, the function module should return the date is invalid. Thanks.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
1,688

Hi,

of ur using f4 help ie,

field like db_tabel_ name-date_field.

automatically f4 will come

it will chk the validity.

<b>another FM is available.</b>

Check 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

Hi all,

Which function module can use to check the validity of a date? For example, if user key in 20060931 or 20060940, the function module should return the date is invalid. Thanks.

5 REPLIES 5
Read only

anversha_s
Active Contributor
0 Likes
1,689

Hi,

of ur using f4 help ie,

field like db_tabel_ name-date_field.

automatically f4 will come

it will chk the validity.

<b>another FM is available.</b>

Check 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

Read only

Former Member
0 Likes
1,688

Hi,

Use the FM:

<b>DATE_CHECK_PLAUSIBILITY</b>

Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.

Hope it helps.

Reward if helpful.

Regards,

Sipra

Read only

anversha_s
Active Contributor
0 Likes
1,688

Hi,

If your issue solved kindly mark all helpful answers , and please close the thread.

Thanks and Regards

Anver

Read only

Former Member
0 Likes
1,688

Hi tan

u meant to say that the user will enter the date in this format

as u quoted like <b>20060940</b> or is it in a text ? "--> my assumption

or<b> 20060930</b>

just execute the code

note that this Function module takes the input in the format YYYYMMDD

data:  input(8) type c value '20060940',
        H_DATUM_OUTPUT(50)  TYPE C.

        write:/ input.

        CALL FUNCTION 'CONVERSION_EXIT_LDATE_OUTPUT'
          EXPORTING
           input         = input
         IMPORTING
           OUTPUT        =  H_DATUM_OUTPUT.

           if h_datum_output eq ' '.
           write:/ 'Invalid date format' .
           else.
           write:/ 'Valid date format' .
           endif.

by changing the date value,

check this also.

input(8) type c value '20060930'

input(8) type c value '20060931'

o/p is fine .

hope this helps regards,

vijay.

Read only

Former Member
0 Likes
1,688

Hi,

declare variable or select-option s

select-options s_date for mkpf-budat.

system implicitly check for validi date

else

use FM

month_plus_detrmine or any date fM

Regards

amole

Regards

amole