Skip to Content
0
Former Member
Jun 25, 2010 at 12:42 PM

Surprising results on BSEG

33 Views

I read that instead of using BSEG, using index tables BSIS & BSA, we can improve performance. We have a old code in our system and I tried to modify using BSIS & BSAS... but my changes are taking more time than the old code.

Old:

loop at TEMPBKPF.

  • Keep index

tmpidx = sy-tabix.

  • Transfering Sy-MANDT value.

TEMPBKPF-MANDT = SY-MANDT.

select BUKRS "Company Code

BELNR "Accounting document number

GJAHR "Fiscal year

BUZEI "Number of Line Item Within Accounting

"Document

SHKZG "Debit/credit indicator

DMBTR "Amount in local currency

SGTXT "Item Text

KOSTL "Cost Center

HKONT "General ledger account

PRCTR "Profit Center

into (tempbseg-bukrs,

tempbseg-belnr,

tempbseg-gjahr,

tempbseg-buzei,

tempbseg-shkzg,

tempbseg-dmbtr,

tempbseg-sgtxt,

tempbseg-kostl,

tempbseg-hkont,

tempbseg-prctr)

from BSEG "[Accounting Document Segment]

where BUKRS = tempbkpf-bukrs "Company Code

and GJAHR = tempbkpf-gjahr "Fiscal year

and BELNR = tempbkpf-belnr. "Accounting document Number.

TEMPBSEG-MANDT = SY-MANDT.

append TEMPBSEG.

  • Updating TEMPBKPF internal table.

endselect.

modify tempbkpf index tmpidx.

endloop.

My Code:

I replaced the loop with FOR ALL ENTRIES & used BSIS & BSAS

  • access the index tables, for each record in bseg

SELECT bukrs

hkont

gjahr

belnr

buzei

shkzg

dmbtr

sgtxt

kostl

prctr

INTO TABLE i_bsis

FROM bsis

FOR ALL ENTRIES IN i_bkpf[]

WHERE bukrs EQ i_bkpf-bukrs " Company Code

AND gjahr EQ i_bkpf-gjahr " Fiscal year

AND belnr EQ i_bkpf-belnr. " Accounting document Number.

IF sy-subrc EQ 0.

SORT i_bsis.

ENDIF.

SELECT bukrs

hkont

gjahr

belnr

buzei

shkzg

dmbtr

sgtxt

kostl

prctr

INTO TABLE i_bsas

FROM bsas

FOR ALL ENTRIES IN i_bkpf[]

WHERE bukrs EQ i_bkpf-bukrs " Company Code

AND gjahr EQ i_bkpf-gjahr " Fiscal year

AND belnr EQ i_bkpf-belnr. " Accounting document Number.

IF sy-subrc EQ 0.

SORT i_bsas.

ENDIF.

Finally, I will loop through both these itabs and build my final itab.

Any thoughts please.

Thanks,

Kiran