‎2008 Dec 17 4:33 PM
Hi,
i have to select some records from DB table to internal table itab.
consider following query , which brings all records at once in itab
select * from kna1 into table itab where kunnr between '10200' and '90500'.
i want to do this in parts ... say selecting 1000 records at a time....
can anyone please tell me how to do it ?
Thanks.
‎2008 Dec 17 5:05 PM
hi,
actually because of memory issues, i have to select records in parts....in same internal table.
1) select 1st to 1000 records in itab with where clause : do processing : refresh itab.
2) select 1001st to 2000th in itab with where clause : do processing : refresh itab.
Thanks.
‎2008 Dec 17 4:35 PM
‎2008 Dec 17 4:35 PM
‎2008 Dec 17 4:36 PM
By Clicking F1 on Select,would give you all possibilities for Select query.
‎2008 Dec 17 4:38 PM
Hi,
You can use the PACKAGE n in the Select Statement in this will select the number of records specified in the n variable.
SELECT ... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab
[PACKAGE SIZE n] ...
‎2008 Dec 17 4:39 PM
Hi thanks..
But can i use ... " upto n rows " ...with " where clause"..
can you please give an example ?
‎2008 Dec 17 4:42 PM
yes u can use it with where.
and as amit suggested use f1 u'll get its description along with example.
‎2008 Dec 17 4:43 PM
Hi
SELECT *
FROM mast UP TO 1000 ROWS
INTO wa_matnr
WHERE matnr in s_matnr.
ENDSELECT.
Amit is right you can get examples in SAP Help so use F1 .
Neha
‎2008 Dec 17 4:57 PM
Thanks neha....
points assigned to all...
i have one more question ..
what if i want to select first 1000 records ....
then next time from 1001st record to 2000th record and so on....
‎2008 Dec 17 5:02 PM
correct if i'm wrong, but i dont think thats possible.
do u want these records in different internal tables everytime or the same one?
like first 100 rows in itab1 then next 100 in itab2 so on...
‎2008 Dec 17 5:05 PM
hi,
actually because of memory issues, i have to select records in parts....in same internal table.
1) select 1st to 1000 records in itab with where clause : do processing : refresh itab.
2) select 1001st to 2000th in itab with where clause : do processing : refresh itab.
Thanks.
‎2008 Dec 17 5:08 PM
>
> 2) select 1001st to 2000th in itab with where clause : do processing : refresh itab.
If you Will do refresh itab here,unfortunately you will lost your First 1000 records, And So On
‎2008 Dec 17 5:18 PM
try like this.
I dont have sap system to test it so u check it out.
data: count type i.
select * from <table> into wa
where <condition>
if count < 1000.
append wa into itab.
count + 1
endif.
if count = 1000
do ur processing.
count = 0.
refresh itab.
endif.
endselect.
‎2008 Dec 17 5:23 PM
Hi Amit,
Can u please tell me if its possible to select first 1000 records then do processing then move onto next 1000 record . how will we form the selecty query.
Are we going to use two selects and in tht case will the second query choose the next 1000 ignoring the first 1000?
‎2008 Dec 17 5:13 PM
hi amit,
that the logic ..i m trying to use..
1) with the first 1000 records in table.... i will do processing on that data...so i can delete it now..
2) then selecting next 1000 ....do processing ...and refreshing itab....and so on...
‎2008 Dec 17 5:17 PM
Yes since you doesn't need previous 1000 records for further processing than you may proceed.Correct.
‎2008 Dec 17 5:21 PM
hi..
thats good...i think it will work...
let me try..
Thanks all for ur replies...
points assigned to all....