Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in Date Range

Hi guys,

SELECT-OPTIONS: v_month FOR s068-spmon OBLIGATORY.

here v_month (month and year) is excluding given input months while fetching the data.

it's not fetching the 4th and 9th months data.

colud anybody please let me know how to make both input dates include?

Thanks in Advance

regards

satish

replied

Hi Satish,

here we go.

You're actually comparing an 8-digit DB-field to a 6-digit select-option.

Let's have a look on it, from a programs perspective

Budats inner representation is like YYYYMMDD, whereas your select-options inner representation comes as IBTYYYYMMYYYYMM. The db now interpretes the line IBT201404201409

as interval between 20.04.2014 to ... well something.

Now there're two possible ways out:

1.

change your select-option to

SELECT-OPTIONS v_month for mseg-budat_mkpf and fill it like

01.04.2014 to 30.09.2014

or 2.

create another ranges tab like

DATA: rt_budat TYPE RANGE OF mseg-budat_mkpf,

         rs_budat LIKE LINE OF rt_budat.

DATA: l_hlp TYPE DATS.

LOOP AT v_month.

  MOVE-CORRESPONDING v_month TO rs_budat

  rs_budat-low+6(2) = '01'.

* the following looks a bit lengthy, yet it's the fastest way

* to calculate the last day of any given month

  l_hlp = rs_budat-high.

  l_hlp+6(2) = '28'.               "highest day in every month

  ADD 4 TO l_hlp.                "garanteed to be in the next month

  l_hlp+6(2) = '01'.                "set to first day of next month

  SUBTRACT 1 from l_hlp.  "Let ABAP do the month-end calculation

  rs_budat-high = l_hlp.

  append rs_budat to rt_budat.

ENDLOOP.

Now use your new rangetab instead of select-option.

Personally, i'd go for the first option.

Best regards - Jörg

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question