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

Select stmt

Former Member
0 Likes
574

Hi All,

I am having a small doubt -


How to use PACKAGE SIZE in Select stmt....What are the things needed to be considered or maintained at the time of using this.

It will be a gr8 advantage if solution is with a small example....

Its urgent

Thanks.

4 REPLIES 4
Read only

Former Member
0 Likes
545

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.

*-- End of Program

Read only

0 Likes
545

Hi Jagadish,

INITIALIZE the internal table means .........I used REFRESH stmt after processing the data to the final internal table....but error coming like...table cant be initialized in the loop....

what can be done......

thanks.

Read only

former_member673464
Active Contributor
0 Likes
545

hi,

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.

Example:

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
545

HI,

data: w_packsize TYPE i,

w_count_mast TYPE i,

parametres: p_pproc TYPE int2 OBLIGATORY,

Start-of-selection.

SELECT COUNT( DISTINCT matnr ) INTO w_count_mast

FROM w_mast.

w_packsize = CEIL( w_count_mast / p_pproc ).

SELECT matnr

werks

stlan

stlnr

stlal

aedat

FROM mast

INTO TABLE i_mast

PACKAGE SIZE w_packsize

WHERE scope = c_unipro

ORDER BY matnr.

*****************************

code as per the requirement

**************************

ENDSELECT.