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: 

Problem in Date Range

satish_kumar127
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

jrg_wulf
Active Contributor
0 Kudos

Hi Satish,

by only looking on the select-option, i'd say , there's nothing wrong with it.

The option BT signals an open interval, meaning that both, low and high value are included in the selction.

Whithout further knowledge of your source, where you actually use the select-option, it's next to impossible to analyse your problem.

Please provide a bit more information.

Best regards - Jörg

6 REPLIES 6

Former Member
0 Kudos

Hi satish,

You can create a range table for date and pass option as equal and then use this for making selection.


Regards
Giri

jrg_wulf
Active Contributor
0 Kudos

Hi Satish,

by only looking on the select-option, i'd say , there's nothing wrong with it.

The option BT signals an open interval, meaning that both, low and high value are included in the selction.

Whithout further knowledge of your source, where you actually use the select-option, it's next to impossible to analyse your problem.

Please provide a bit more information.

Best regards - Jörg

0 Kudos

hi jorg,

thanks for the input

the following is my query

SELECT mblnr mjahr zeile bwart matnr lifnr ebeln ebelp lgort budat_mkpf meins menge werks FROM mseg

                                                       INTO CORRESPONDING FIELDS OF TABLE it_mseg

                                                       WHERE lifnr IN s_lifnr

                                                         AND matnr IN s_matnr

                                                         AND werks IN  s_werks

                                                         AND budat_mkpf IN v_month

here budat_mkpf  is the date field (ddmmyyyy) AND V_MONTH is my input (mmyyyy).

is it giving any problem.

regards

satish

0 Kudos

Hi Satish,

Edit v_month.

concatenate v_month-low '01' to v_month-low.

concatenate v_month-high '31' to v_month-high.

jrg_wulf
Active Contributor
0 Kudos

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 Kudos

hi jorg,

you are really awesome. thanks for the wonderful kt. my issue has been resolved.

Thanks a lot.

regards

satish