03-11-2013 2:33 PM
Hi Experts,
I am modifying an existing report which causes runtime error when range table used in select clause has a lot of entries.
I did researched on using for all entries instead of range but i have a following doubt:
R_PAYER is range for kunnr.
R_PAYER is built in the program itself and is used like this:
SELECT fields from KNB1 where kunnr in r_payer.
I am modiying the above select like this:
Select fields from KNB1 for all entries in r_payer
where kunnr EQ r_payer-low.
But the above select wont work if range has a value for Container Pattern ( CP *) also it wont work if range has value as BT 1-100.
So i thought to to build a logic like this but still not able to figure out how:
if range table has more than 2000 entries :
1. Divide the range like this:
Append 1-2000 records in itab1 and select * from table appending itab1 where kunnr in itab1.
Append 2001-4000 records in itab1 and select * from table appending itab2 where kunnr in tab1
If soemone can suggest a better approach
03-11-2013 3:03 PM
You can loop through the range table, line by line, and each N lines, execute the select, like this:
data: lr_range like YOUR_RANGE,
ls_range like line of YOUR_RANGE.
loop at YOUR_RANGE into ls_range.
append ls_range into lr_range.
if lines( lr_range ) > X. " << Here you set how many lines
select from xxx
...
APPENDING lines
WHERE kunnr in lr_range.
" Clear auxiliar range table
clear lr_range.
endif.
endloop.
Hope it helps,
Guilherme Frisoni