Sometimes when we perform lot of data selection, usually time out error or ABAP Dump will be happened, there some techniques in Selection process to select large amount of data and prevent time out, below is the code snippet.
data : ta_vbakuk like vbakuk occurs 0 with header line,
ta_vbakuk_2 like vbakuk occurs 0 with header line,
l_max_fetch(4) type p,
l_cursor type cursor.
if so_vbeln[] is initial.
so_vbeln-sign = 'I'.
so_vbeln-option = 'BT'.
so_vbeln-low = '0000000001'.
so_vbeln-high = '9999999999'.
append so_vbeln.
clear so_vbeln.
endif.
l_max_fetch = '1000'.
open cursor with hold l_cursor for
select * from vbakuk
where vbeln in so_vbeln
and erdat in so_date
and ( auart eq cn_auart_zor or auart eq cn_auart_zfc )
and kunnr in so_camp
and vbtyp eq cn_vbtyp_c
and lfstk eq cn_lfstk_a. "delivery status "Not processed"
do.
fetch next cursor l_cursor into table ta_vbakuk
package size l_max_fetch.
if sy-subrc <> 0.
close cursor l_cursor.
exit.
endif.
if not ta_vbakuk[] is initial.
select vbeln werks from vbap
appending corresponding fields of table ta_vbap_t2
for all entries in ta_vbakuk
where vbeln = ta_vbakuk-vbeln and
werks = pa_plant .
select * from vbfa appending table ta_vbfa_2
for all entries in ta_vbakuk
where vbelv = ta_vbakuk-vbeln
and vbtyp_n = cn_vbtyp_n_h. "Returns
select * from vbpa appending table ta_vbpa_2
for all entries in ta_vbakuk
where vbeln = ta_vbakuk-vbeln
and parvw = cn_parvw_we. "Ship-to-party
endif.
if ta_vbakuk_2[] is initial.
ta_vbakuk_2[] = ta_vbakuk[].
else.
loop at ta_vbakuk into ta_vbakuk_2.
append ta_vbakuk_2.
endloop.
endif.
free: ta_vbakuk.
enddo.
This comment has been removed by the author.
ReplyDelete