Skip to Content
0
Nov 26, 2012 at 12:34 PM

Performance in a select

24 Views

I have got the following code where:
pfechas -> Is a select options for dates
plifnr -> Is a select options for providers
r_docu -> Is a range in wich there are 4 document types


DATA: BEGIN OF ipart1 OCCURS 0. " Partidas abiertas
DATA: belnr LIKE bsik-belnr.
DATA: gjahr LIKE bsik-gjahr.
DATA: lifnr LIKE bsik-lifnr.
DATA: budat LIKE bsik-budat.
DATA: END OF ipart1.

DATA: BEGIN OF ipart2 OCCURS 0. " Partidas compensadas
INCLUDE STRUCTURE ipart1.
DATA: END OF ipart2.

DATA: BEGIN OF ipart OCCURS 0. " Partidas (tanto abiertas como compens.)
INCLUDE STRUCTURE ipart1.
DATA: END OF ipart.

DATA: BEGIN OF ibkpf OCCURS 0.
INCLUDE STRUCTURE bkpf.
DATA: END OF ibkpf.

*--------------------------------------------------------

SELECT DISTINCT belnr gjahr lifnr budat INTO TABLE ipart1
FROM bsik
WHERE bukrs = '1111' AND
budat IN pfechas AND
lifnr IN plifnr AND
blart IN r_docu.

SELECT DISTINCT belnr gjahr lifnr budat INTO TABLE ipart2
FROM bsak
WHERE bukrs = '1111' AND
budat IN pfechas AND
lifnr IN plifnr AND
blart IN r_docu.

sy-index = 0.
LOOP AT ipart1.
APPEND ipart1 TO ipart.
ENDLOOP.

sy-index = 0.
LOOP AT ipart2.
APPEND ipart2 TO ipart.
ENDLOOP.
" En ipart tenemos todos los documentos contables a analizar.
*--------------------------------------------------------------------------*

" Rellenamos la tabla interna ibkpf con los documentos recopilados en ipart.

SELECT * INTO CORRESPONDING FIELDS OF TABLE ibkpf
FROM bkpf
FOR ALL ENTRIES IN ipart
WHERE bukrs = '1111' AND
belnr = ipart-belnr AND
gjahr = ipart-gjahr.

Most of the times I get a dump when executing this last select.
Is there an possibility to avoid this dump ?
Perhaps I could create an index on table bppf but; is it recommended?

Thanks in advance.