05-20-2009 9:46 AM
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
05-20-2009 9:53 AM
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
05-20-2009 9:58 AM
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
05-20-2009 10:05 AM
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
05-20-2009 12:08 PM
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
05-21-2009 1:19 PM