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

select-options

Former Member
0 Likes
779

in My selection screen, select-option for date

I want validation on date range . It should not be more than one month.

like 01.01.2008 to 01.02.2008. it should work.

if more than one month i.e 01.01.2008 to 01.03.2008. then msg will be there "not more than one month."

point is assured

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
743

Hi jim kelly,

Try this code :

data: date type sy-datum,

days type i.

select-options s_date for date.

at selection-screen.

days = s_date-high - s_date-low.

if days > 30.

message i000(sabapdocu) with 'Not more than 30 days'.

endif.

loop at s_date.

endloop.

Plzz reward if it is useful,

Mahi.

7 REPLIES 7
Read only

Former Member
0 Likes
743

Use the DAYS_BETWEEN_TWO_DATES to get the no of days between two days and then do validetion.


REPORT  ztest.
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS: s_date FOR sy-datum.
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON s_date.

  DATA: lv_day TYPE i.

  READ TABLE s_date INDEX 1.
  IF sy-subrc EQ 0.
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
      EXPORTING
        i_datum_bis             = s_date-high
        i_datum_von             = s_date-low
      IMPORTING
        e_tage                  = lv_day
      EXCEPTIONS
        days_method_not_defined = 1
        OTHERS                  = 2.
    IF sy-subrc EQ 0.
      IF lv_day > '30'.
        MESSAGE e000(001) WITH 'Date range more than one month'.
      ENDIF.
    ENDIF.

  ENDIF.

Read only

Former Member
0 Likes
744

Hi jim kelly,

Try this code :

data: date type sy-datum,

days type i.

select-options s_date for date.

at selection-screen.

days = s_date-high - s_date-low.

if days > 30.

message i000(sabapdocu) with 'Not more than 30 days'.

endif.

loop at s_date.

endloop.

Plzz reward if it is useful,

Mahi.

Read only

Former Member
0 Likes
743

Use these FMs to get ur desire result.

'SLS_MISC_GET_LAST_DAY_OF_MONTH'

HR_99S_INTERVAL_BETWEEN_DATES

regards

Read only

Former Member
0 Likes
743

Hi,

Try this i think it will help u.. think in this way and try to solve it...

Data : date1 type sy-datum,

date2 type sy-datum.

Date2 = Date10(4)-HIGH - Date10(4)-LOW

At selection-screen on field date.

if Date2 > 1.

Message E00(z001) // Not more than one month.

endif.

Regards

Read only

Former Member
0 Likes
743

Hi Jim,,

There are two way of doing the things.

1. by taking the date difference by standard function module.

2. Just Simple take the difference of the two date in another work area.

regard

Swati

Read only

Former Member
0 Likes
743

Hi Jim,

check out this..

REPORT ztest1.

DATA: date TYPE d.

DATA: l_month type I.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_date FOR sy-datum.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN on s_date.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = s_date-low

endda = s_date-high

IMPORTING

C_MONTHS = l_month.

IF l_month > 1.

MESSAGE s000(ztest) WITH 'Not more than 1 month'.

ENDIF.

Read only

Former Member
0 Likes
743

thanks to all problem has been solved

point has been given