‎2007 Sep 26 5:02 AM
Hi,
What is the use of PACKAGE SIZE in select statement?Can anyone give me an example for that?
Regards,
Hema
‎2007 Sep 26 5:05 AM
Hi Hema,
Lets say you expect the data selected will be very huge so there may be chance that the time out may occur at select statement or the internal table may not be able to hold those huge entries so you restrict the number of entries and split the whole selection in parts using package size.
Regards,
Atish
‎2007 Sep 26 5:06 AM
Hi Hema..
This option can be use to Restrict the Number of rows fetched from database in a Single access especially while fetching large number of records into internal table.
this can improve the performance.
SELECT * FROM <DBTABLE> APPENDING TABLE <ITAB> PACKAGE SIZE 1000.
<b>reward if Helpful.</b>
‎2007 Sep 26 5:09 AM
Hi Folks,
Can we use this package size in all situations or does it have any limitations?
K.Kiran.
‎2007 Sep 26 5:06 AM
<b>... PACKAGE SIZE n</b>
Effect
Works like ... INTO wa, except that the selected data is not placed in the internal table itab line by line, but in packets of n lines. The old contents of itab are overwritten.
n <= 0 causes a runtime error.
Internally, n is placed in a type I field. Here, the usual conversion rules apply (see MOVE).
After leaving the processing loop, the contents of the internal table itab are undefined.
If the result of the selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read.
Example
Output a list of all airlines (with short description and name):
DATA: itab TYPE STANDARD TABLE OF SCARR WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 10.
FIELD-SYMBOLS: <FS> TYPE scarr.
SELECT * INTO TABLE itab PACKAGE SIZE 20 FROM scarr.
LOOP AT itab ASSIGNING <FS>.
WRITE: / <FS>-carrid, <FS>-carrname.
ENDLOOP.
ENDSELECT.
‎2007 Sep 26 5:07 AM
Hi hema,
Package size can be used if you for example only want to finish processing a limited amount of data at a time due to lack of memory.
The example below read 50 records at a time from VBAK into an internal table, and selects the corresponding entries from vbap into an internal table. Then the two internal tables can be processed, and the next 50 records from VBAk can be read. Remember to reinitialize tha tables before the next read.
REPORT z_test.
TYPES:
BEGIN OF t_vbak,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
END OF t_vbak,
BEGIN OF t_vbap,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
meins LIKE vbap-meins,
END OF t_vbap,
BEGIN OF t_report,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
meins LIKE vbap-meins,
END OF t_report.
DATA:
li_vbak TYPE t_vbak OCCURS 0,
l_vbak TYPE t_vbak,
li_vbap TYPE t_vbap OCCURS 0,
l_vbap TYPE t_vbap,
li_report TYPE t_report OCCURS 0,
l_report TYPE t_report.
START-OF-SELECTION.
SELECT vbeln erdat
FROM vbak
INTO TABLE li_vbak PACKAGE SIZE 50.
SELECT posnr matnr meins
FROM vbap
INTO TABLE li_vbap
FOR ALL ENTRIES IN li_vbak
WHERE vbeln = li_vbak-vbeln.
IF sy-subrc = 0.
* Now you have the two internal tables li_vbak and li_vbap filled
* with data.
* Do something with the data - remember to reinitialize internal
* tables
ENDIF.
ENDSELECT.
Thanks,
Reward If Helpful.
‎2007 Sep 26 5:16 AM
Hi,
Let us assume the internal table has 3000 records and I have used a package size of 1000.How can the remaining 2000 records be retrived?
Regards,
Hema
‎2007 Sep 26 5:27 AM
Hi Hema,
Initially your internal table has no data.
Using Package Size Statement we can Restrict the Selection Criteria from the Data base only.
Thanks.
‎2007 Sep 26 5:46 AM
Hi Hema,
PACKAGE SIZE is used in SELECT...ENDSELECT so SAP will take care of next records fetching also.
Regards,
Atish
‎2007 Sep 26 5:50 AM
Atish,
Do you mean to say that PACKAGE SIZE should <b>only be used</b> when the select statement is of structure select and end select?
Thanks,
K.Kiran.