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

reg: package size

Former Member
0 Likes
1,548

Hi,

I have seen "package size" which used by some people to increase performance. Can anybody explain?

Hi,

I have seen "package size" which used by some people to increase performance. Can anybody explain?

12 REPLIES 12
Read only

Former Member
0 Likes
1,510

I wouldn't say that it increases performance. It's a way to read and process a large amount of data so that it avoids memory problems.

Rob

Read only

0 Likes
1,510

Hi bob,

Thanks for ur quick response.

But I could not understand i.e what is the way etc.,

Could u plz give more explnation.

Read only

Former Member
0 Likes
1,510

use search, it was discussed recently.

It is used together with open cursor if youz want to very large amount of data, then you should use package size of about 10.000 records.

Otherwise there is no general recipe to improve performance, always analyse your actual problems!

Siegfried

Read only

Former Member
0 Likes
1,510

Hi Krishna,

This should answer ur question

http://www.sap-img.com/abap/package-size.htm

If you cannot open link , chk this


*What's the purpose of using PACKAGE SIZE in select statement?*  
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. 

Edited by: Chandrasekhar Jagarlamudi on Feb 25, 2008 9:52 PM

Read only

0 Likes
1,510

Hai ,

Go Through The Following Code For 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.

The output is:

The example reads packets of three lines each into the sorted table ITAB. In each pass of the SELECT loop, the internal table has a different sorted content.

If you were to use APPENDING instead of INTO, the list would look like this:

In each loop pass, a new packet is sorted into the internal table

Read only

Former Member
0 Likes
1,510

Hi Paluri,

The idea behind the addition PACKAGE SIZE is to split a large amount of records into smaller lots and processing those lots individually. Usually, it results in a better memory and time compsumption.

To be able to do this, you have to use the addition PACKAGE SIZE together with a cursor. I'll introduce a small modification to the code already provided by Chandrasekhar.


REPORT  z_test.
...
DATA:
  l_cursor  TYPE cursor.

START-OF-SELECTION.
  OPEN CURSOR l_cursor FOR
    SELECT vbeln erdat
    FROM vbak.

  DO.
    FETCH NEXT CURSOR l_cursor
          INTO TABLE li_vbak
          PACKAGE SIZE 50.

    IF sy-subrc <> 0.
      CLOSE CURSOR l_cursor. "There're no more records to be processed
      EXIT.
    ENDIF.

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

Regards,

Juan José

Read only

0 Likes
1,510

Juan - why do you use the cursor?

Rob

Read only

0 Likes
1,510

Rob, I gave the cursor example because it was mentioned before. Just to give a code example of how to use PACKAGE SIZE + CURSOR, but it's not mandatory.

Regards,

Juan José

Read only

0 Likes
1,510

OK - but you don't have to use the cursor when using package size.

Rob

Read only

0 Likes
1,510

You're right.

Juan José

Read only

Former Member
0 Likes
1,510

Krishna,

Suppose your database is having 100000.

While you are extracting the data from table after some time it will go for dump , because session time exceeded.In this situation

Go for PACKAZE SIZE.

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

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

Your functionality

ENDSELECT.

Each time it will take 10000 records and perform your functionality and go for next 10000 records.Here internal table will over write every time.

Read only

Former Member
0 Likes
1,510

Hi,

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.

Thanks,

Sriram Ponna.