Application Development and Automation 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: 
Read only

select query

Former Member
0 Likes
1,534

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,494

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.

16 REPLIES 16
Read only

Former Member
0 Likes
1,494

Hi

You can try Select up to n rows .

Neha

Read only

Former Member
0 Likes
1,494

use the upto addition

upto 1000rows

Read only

Former Member
0 Likes
1,494

By Clicking F1 on Select,would give you all possibilities for Select query.

Read only

Former Member
0 Likes
1,494

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] ...

Read only

Former Member
0 Likes
1,494

Hi thanks..

But can i use ... " upto n rows " ...with " where clause"..

can you please give an example ?

Read only

0 Likes
1,494

yes u can use it with where.

and as amit suggested use f1 u'll get its description along with example.

Read only

0 Likes
1,494

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

Read only

Former Member
0 Likes
1,494

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....

Read only

0 Likes
1,494

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...

Read only

Former Member
0 Likes
1,495

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.

Read only

0 Likes
1,494

>

> 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

Read only

0 Likes
1,494

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.

Read only

0 Likes
1,494

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?

Read only

Former Member
0 Likes
1,494

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...

Read only

0 Likes
1,494

Yes since you doesn't need previous 1000 records for further processing than you may proceed.Correct.

Read only

Former Member
0 Likes
1,494

hi..

thats good...i think it will work...

let me try..

Thanks all for ur replies...

points assigned to all....