Application Development 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: 

Date Range .

Former Member
0 Kudos

Hi Guru's ,

I need date range on my selection screen upto 1 year , beyond that it should give a error message orit should exit . can you please tell me how to execute it .

Thanks

3 REPLIES 3

Former Member
0 Kudos

Hi Peter,

Try this way :

Select-options:
   s_date for sy-datum.

at selection-screen.

    if s_date-low+0(4) ne sy-datum+0(4)
   or s_date-high+0(4) ne sy-datum+0(4).

       message 'Enter Current year' type 'E'.

    endif.

Regards,

Swapna.

Edited by: NagaSwapna Thota on Sep 10, 2008 2:04 PM

Former Member
0 Kudos

Hi,

HR_HK_DIFF_BT_2_DATES

Use the above fm to find the range between two dates.

Example:

Input :

DATE1 14.01.2008

DATE2 15.01.2007

OUTPUT_FORMAT 05

Output:

YEARS 1,0000

MONTHS 0,0000

DAYS 0

Check the condition like the following,

1, year should not exceed 1

2, if year is 1, month and days should not exceed 0.

Regards,

Harish

Former Member
0 Kudos
TABLES : bsis.
data: year TYPE i,
     day type i.
select-OPTIONS so_date for bsis-budat OBLIGATORY no-EXTENSION.

AT SELECTION-SCREEN.

  CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
    EXPORTING
      BEG_DA              = so_date-low
      END_DA              = so_date-high
   IMPORTING
     NO_DAY              = day
*     NO_MONTH            =
     NO_YEAR             = year
*     NO_CAL_DAY          =
*   EXCEPTIONS
*     DATEINT_ERROR       = 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.
  ENDIF.

if year GT 1 or year EQ 1 AND day GT 0.
  MESSAGE 'Error- More than an year' TYPE 'E'.
endif.