Skip to Content
0
Former Member
Nov 18, 2011 at 01:36 PM

how to improve this selects?

50 Views

Hi gurus, i need some help with some queries.

The actual situation is this:

SELECT objnr rec_objnr1

FROM cobrb

INTO TABLE gt_cobrb

FOR ALL ENTRIES IN gt_aufk_ob

WHERE objnr EQ gt_aufk_ob-objnr AND

aufnr NE ''.

DELETE ADJACENT DUPLICATES FROM gt_cobrb COMPARING rec_objnr1.

SELECT refbt refbn rfpos objnr gjahr sakto perio wkgbtr

FROM cooi

INTO TABLE gt_cooi

FOR ALL ENTRIES IN gt_cobrb

WHERE objnr EQ gt_cobrb-rec_objnr1 AND

gjahr IN s_gjahr AND

bldat IN s_bldat AND

bukrs EQ pa_bukrs.

The access to COOI is very time consuming so i think to use cursor as follows:

DATA: c1 TYPE cursor,

c2 TYPE cursor.

OPEN CURSOR WITH HOLD c1 FOR

SELECT objnr rec_objnr1

FROM cobrb

FOR ALL ENTRIES IN gt_aufk_ob

WHERE objnr EQ gt_aufk_ob-objnr AND

aufnr NE ''.

OPEN CURSOR WITH HOLD c2 FOR

SELECT refbt refbn rfpos objnr gjahr sakto perio wkgbtr

FROM cooi

FOR ALL ENTRIES IN gt_cobrb

WHERE objnr EQ gt_cobrb-rec_objnr1 AND

gjahr IN s_gjahr AND

bldat IN s_bldat AND

bukrs EQ pa_bukrs.

DO.

FETCH NEXT CURSOR c1 INTO TABLE gt_cobrb PACKAGE SIZE 500.

IF sy-subrc NE 0.

EXIT.

ENDIF.

DELETE ADJACENT DUPLICATES FROM gt_cobrb COMPARING rec_objnr1.

DO.

FETCH NEXT CURSOR c2 APPENDING TABLE gt_cooi PACKAGE SIZE 500

IF sy-subrc <> 0.

EXIT.

ENDIF.

ENDDO.

ENDDO.

CLOSE CURSOR: c1, c2.

but the result is not the same since the acces to COOI not respect the for all entries and read the ENTIRE TABLE!!!

What is going on here?! please help!

Edited by: dasdsadasd dasdsadsad on Nov 18, 2011 2:37 PM