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: 

limit no of months in select option

Former Member
0 Kudos

how can we limit our selection option value to some definite period.

on some particular condition i want month should be in only in range of 12 months

9 REPLIES 9

Former Member
0 Kudos

Hi

I don't know what you mean by limiting month selection to 12 months.

However you could do some coding to check if the user has entered wrong data in the INITIALIZATION event.

Pushpraj

0 Kudos

Sorry, the event should be AT SELECTION SCREEN.

Pushpraj

0 Kudos

thanks for the reply.

i can enter date in MM/YYYY Format in my select option between any range.

but when a below checkbox is ticked then it range should not exceed 12 months.

eg 10.2008 to 11.2009 is wrong , greater than 12 months

10.2008 to 8.2009 is right , lesser than 12 months

0 Kudos

I think you are searching for this function module.. see if this helps....


SELECT-OPTIONS: s_date FOR sy-datum.
..
data: no_months type i.
..
AT SELECTION-SCREEN ON s_date.
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
  EXPORTING
    i_datum_bis         = s_date-high
    i_datum_von         = s_date-low
*   I_KZ_INCL_BIS       = ' '
 IMPORTING
   E_MONATE            = no_months.
IF no_months > 12.
MESSAGE
ENDIF.

0 Kudos

Hi,

Try FM BKK_ADD_MONTH_TO_DATE.

The date in this FM is in the SAP internal format. So you can format the From and To date by putting '01' in the 'DD' field.

So if the user enters 10.2008 on the selection screen, then your from date will be 01.10.2008. Then use this FM with importing parameter month as '12'. It will give you the To date. Then check that the selection screen date is less than this date otherwise display error.

*/..Check that the analysis period is not greater than 3 months
  lv_fdate = s_spmon-low.
  lv_fdate+6(2) = '01'.

  lv_tdate = s_spmon-high.
  lv_tdate+6(2) = '01'.

*/..Check Valid to date is within 12 months of the Valid from date
  CALL FUNCTION 'BKK_ADD_MONTH_TO_DATE'
    EXPORTING
      months  = '12'
      olddate = lv_fdate
    IMPORTING
      NEWDATE = lv_ndate.

  IF lv_tdate > lv_ndate.
****Display error 
  ENDIF.

0 Kudos

many thanks to you . i got the answer.

VXLozano
Active Contributor
0 Kudos

AT SELECTION-SCREEN ON object.

Check help about that event. There you can add code checking the content of the "object". There you can check if the user is trying to put more than 12 months, for example.

Good luck.

Former Member
0 Kudos

thanks for the reply.

i can enter date in MM.YYYY Format in my select option between any range.

but when a below checkbox is ticked then it range don't exceed 12 months.

eg 10.2008 to 11.2009 is wrong , greater than 12 months

10.2008 to 9.2009 is right , lesser than 12 months

Former Member
0 Kudos

Hi..

if you want to restrict to only for definit period.

you can use no-extension after the selection-options declaration.

see this

-


select-options: s_year for bseg-gjahr

no-extension.

All the best..

GSANA