Dynamic variable/data selection - multiple selections.. how?

Question: Hi,

I am trying to get an infopackage selection which restricts the data selection to the most current 3 months and I can do this (so currently, I'd want month 11/2002 up to 01/2003). However, this is also bringing in special periods (13-16/2002) which we do not want, we only want 11,12/2002, 0/2003 and 1/2003.

As such the only way I can think of specifying this is to have a multiple selection - but if I try adding more than one selection for year/period and assigning a new abap exit it only allows me to use the same one..

So, I'm wondering if someone can help me add the additional selections via just one ABAP routine.. This is what I'm currently doing to give me one range.. how do I add another please?

$$....................
data: l_idx like sy-tabix.
data: month_low(3) TYPE N.
data: month_high(3) TYPE N.
data: year_low(4) TYPE N.
read table l_t_range with key
fieldname = 'FISCPER'.
l_idx = sy-tabix.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
* set high range to current month and year
year_low = sy-datum+0(4).
month_high = sy-datum+4(2).
if month_high = 1.
month_low = 0.
else.
month_low = month_high.
endif.
concatenate year_low month_low into l_t_range-low.
concatenate year_low month_high into l_t_range-high.
modify l_t_range index l_idx.
p_subrc = 0.
$$...........

Any help would be much appreciated.

Answer:
rather than a range include 3 separate lines on your range table so work out your first date & store as I EQ l_t_range-low and append your range table. then work out your second date & append and so on....

it might not be pretty but it works!

party on

Answer:
Consider the following changes:

$$....................
data: l_idx like sy-tabix,
month_low(3) type n,
month_high(3) type n,
year_low(4) type n,
year_high(4) type n,
date like sy-datum,
i type n.
clear: month_low, month_high, year_low, year_high.

read table l_t_range with key fieldname = 'FISCPER'.
l_idx = sy-tabix.

l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
* set high range to current month and year
year_high = sy-datum+0(4).
month_high = sy-datum+4(2).

date = sy-datum.
for i = 1 to 3.
* take the first day of the month
date+6(2) = '01'.
* get the last day of the previous month
date = date - 1.
i = i + 1.
next i.
month_low = date+4(2).
year_low = date(4).

concatenate year_low month_low into l_t_range-low.
concatenate year_low month_high into l_t_range-high.
modify l_t_range index l_idx.

p_subrc = 0.
$$...........

cheers,

El Belgio

Answer:
This would be a great solution if I knew how to code it in ABAP... I'm guessing I need to use INSERT or something but I couldn't work out the syntax of how to do that. Would you be able to show me in ABAP how I could that please?

Thanks very much for your reply...


rather than a range include 3 separate lines on your range table so work out your first date & store as I EQ l_t_range-low and append your range table. then work out your second date & append and so on....

it might not be pretty but it works!

party on
Copyright ?2007 - 2008 www.jt77.com