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

Date Validation

Former Member
0 Likes
840

Hello Guys,

Please suggest if there is any function module which can find whether a date that i want to check lies between the two dates of select option

Regards,

Deepak

7 REPLIES 7
Read only

mahesh_madhavan
Participant
0 Likes
788

Dear Deepak,

No need for FM. Just use normal ABAP keyword 'IN'

IF lv_date_to_be_checked IN s_date_range.

* Write your logic here

ENDIF.

Cheers

Mahesh

Read only

Former Member
0 Likes
788

Hi.

I think that you only need an IF, you don't need a function module.

Best Regards,

Joana

Read only

Former Member
0 Likes
788

Hi Joana,

its working.......thanks.

Regards,

Deepak kansal

Read only

Former Member
0 Likes
788

Hi Mahesh,

Thanks for ur code........its working.

Regards,

Deepak kansal.

Read only

0 Likes
788

Hi deepak,

we can manually validate the date range entered in the select options,

Here is the code for that

at selection screen.

IF s_date[] IS INITIAL.

      MESSAGE 'PLease Enter the Date' TYPE 'S' DISPLAY LIKE 'E'.

    ENDIF.

    IF NOT s_date[] IS INITIAL.                    "for weekly date validation

      fdate = s_date-low.     "fdate----->first date

      fdate = fdate + 6.

      ldate = s_date-high.     "ldate------->last date

      IF ldate <> fdate.

        MESSAGE 'Enter the valid range of date' TYPE 'E'.

      ENDIF.

    ENDIF.

To validate the date range given in month format, here is the FM for month date validation.

IF NOT s_tdate[] IS INITIAL.

      CALL FUNCTION 'OIL_MONTH_GET_FIRST_LAST'

        EXPORTING

*         I_MONTH     =

*         I_YEAR      =

          i_date      = s_tdate-low

        IMPORTING

          e_first_day = fdate     "first date of month    
    
          e_last_day  = ldate     "last date of month

        EXCEPTIONS

          wrong_date  = 1

          OTHERS      = 2.

      IF sy-subrc <> 0.

*     Implement suitable error handling here

        MESSAGE 'Enterd date is not valid' TYPE 'S' DISPLAY LIKE 'E'.

      ENDIF.

      "To display the message to the user if lower value is wrong

      IF s_tdate-low <> fdate.

        MESSAGE 'Enter The valid first date' TYPE 'S' DISPLAY LIKE 'E'.

      ENDIF.



      "  To display the message to the user if the higher value is wrong

      IF s_tdate-high <> ldate.

        MESSAGE 'Enter the valid Last date' TYPE 'S' DISPLAY LIKE 'E'.

      ENDIF.

    ENDIF.

  ENDIF.

just try with this and hope u will get want u wanna acheive.

regards

Syed

Read only

0 Likes
788

Hi Deepak,

If your question is answered, award necessary points and mark this thread as answered.

Cheers

Mahesh

Read only

Former Member
0 Likes
788

Hi deepak kansal,

Use the below logic

IF v_date GE so_option-low AND v_date LE so_option-high.


                *Implement your code here.


ENDIF.

Cheers,

Riju Thomas.