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

Package size in select stat..

Former Member
0 Likes
1,958

Hi guys,

I am selecting data from MARA .

Here iam using select package size.

I need to select 500 records at a time .

say MARA is having 2000 records for my condtion.

logicaly i want to understand how it works .

If any any explain it will truely help me ...

tnks guys with expecting,

Ryan

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
1,684

Hi,

if you know that you want to selec 500 records then its easy if you use

UPTO 500 ROWS.

Regards,

sesh

Hi guys,

I am selecting data from MARA .

Here iam using select package size.

I need to select 500 records at a time .

say MARA is having 2000 records for my condtion.

logicaly i want to understand how it works .

If any any explain it will truely help me ...

tnks guys with expecting,

Ryan

8 REPLIES 8
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
1,685

Hi,

if you know that you want to selec 500 records then its easy if you use

UPTO 500 ROWS.

Regards,

sesh

Read only

0 Likes
1,684

Hi ,

No ..In blck of 500.....

ryan

Read only

0 Likes
1,684

Hi,

In this case if you use package size, the insertion in to your target INTERNAL TABLE will happen when you read 500 lines. So at a time 500 lines will be iserted into your target internal table.

SO when you say

SELECT * FROM <TABLE> INTO TABLE ITAB PACKAGE SIZE 500.

once the query fetched 500 rows it will insert it into the ITAB so in package of 500 it will insert into ITAB.

Regards,

Sesh

.

Read only

Former Member
0 Likes
1,684

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.

Read only

Former Member
0 Likes
1,684

sample code

SELECT MATNR
.INCLUDE
ERSDA
ERNAM
LAEDA
AENAM
VPSTA
PSTAT
LVORM
MTART
MBRSH
MATKL
BISMT
MEINS
BSTME
  UP TO 500 ROWS
  FROM mara
  INTO TABLE it_mara

Girish

Read only

former_member673464
Active Contributor
0 Likes
1,684

hi..

When you read several lines of a database table, you can place them in an internal table. To do this, use the following in the INTO clause:

SELECT ... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE <itab>

[PACKAGE SIZE <n>] ...

The same applies to the line type of <itab>, the way in which the data for a line of the database table are assigned to a table line, and the CORRESPONDING FIELDS addition as for flat work areas (see above).

The internal table is filled with all of the lines of the selection. When you use INTO, all existing lines in the table are deleted. When you use APPENDING; the new lines are added to the existing internal table <itab>. With APPENDING, the system adds the lines to the internal table appropriately for the table type. Fields in the internal table not affected by the selection are filled with initial values.

If you use the PACKAGE SIZE addition, the lines of the selection are not written into the internal table at once, but in packets. You can define packets of <n> lines that are written one after the other into the internal table. If you use INTO, each packet replaces the preceding one. If you use APPENDING, the packets are inserted one after the other. This is only possible in a loop that ends with ENDSELECT. Outside the SELECT loop, the contents of the internal table are undetermined. You must process the selected lines within the loop

Reading packets into an internal table

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.

regards,

veeresh

Read only

Former Member
0 Likes
1,684

this for package size

SELECT vbeln erdat 
    FROM vbak 
    INTO TABLE li_vbak PACKAGE SIZE 500. 
 
    SELECT posnr matnr meins 
      FROM vbap 
      INTO TABLE li_vbap 
      FOR ALL ENTRIES IN li_vbak 
      WHERE vbeln = li_vbak-vbeln.

Girish

Read only

former_member186741
Active Contributor
0 Likes
1,684

have a look at the wiki under ABAP general....it describes it quite well:

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abapDevelopmentand+Programming&

or this one:

[Removed by the moderator.]