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: 

Select batch by batch

Former Member
0 Kudos

Hi ,

i need to select database table records by batch by batch , for example first 1 - 5000 , next 5001 to 10000 etc and store all the values in the database table .Can any one help me out how to achive this ?

Iam using package size but it is giving me dump

Sri

5 REPLIES 5

Former Member
0 Kudos

Package Size can be used in this way:

SELECT * FROM <DBTAB> INTO TABLE ITAB PACKAGE SIZE n

WHERE <COND>.

LOOP AT ITAB ASSIGNING <LFS_STRC>.

.... processing...

ENDLOOP.

ENDSELECT.

Does this hint solve the problem.

If not then please explain the problem completely. May be paste your source code which gives dump.

Kind Regards

Ravi

tarangini_katta
Active Contributor
0 Kudos

Hi sriram,

try with this example.

REPORT demo_select_into_package .

DATA: wa TYPE spfli,

itab TYPE SORTED TABLE OF spfli

WITH UNIQUE KEY carrid connid.

SELECT carrid connid

FROM spfli

INTO CORRESPONDING FIELDS OF TABLE itab

PACKAGE SIZE 3.

LOOP AT itab INTO wa.

WRITE: / wa-carrid, wa-connid.

ENDLOOP.

SKIP 1.

ENDSELECT.

Thanks

0 Kudos

hi Sriram,

You can check the data types of fields of internal table and table from which you are fetching valus or you can use cursors

Following is one example for using cursors:

DATA: BEGIN OF count_line,

carrid TYPE spfli-carrid,

count TYPE i,

END OF count_line,

spfli_tab TYPE TABLE OF spfli.

DATA: dbcur1 TYPE cursor,

dbcur2 TYPE cursor.

OPEN CURSOR dbcur1 FOR

SELECT carrid count(*) AS count

FROM spfli

GROUP BY carrid

ORDER BY carrid.

OPEN CURSOR dbcur2 FOR

SELECT *

FROM spfli

ORDER BY carrid.

DO.

FETCH NEXT CURSOR dbcur1 INTO count_line.

IF sy-subrc <> 0.

EXIT.

ENDIF.

FETCH NEXT CURSOR dbcur2

INTO TABLE spfli_tab PACKAGE SIZE count_line-count.

ENDDO.

CLOSE CURSOR: dbcur1,

dbcur2.

Regards,

Komal

0 Kudos

Hi ,

For example if iam making package type as 3 and my data base will have less the 3 enteries , how package size will behave ?

Regards,

Sri

Former Member
0 Kudos

yes