Skip to Content
0
Former Member
Apr 11, 2008 at 06:55 AM

Performance Issue with BSEG

74 Views

These are the queries i am using in my report to fetch the line item data from bseg.functional guys are very adamant and dont want to use any other tables than BSEG.Kindly suggest me what can be done to improve the performance as this report takes a lot of time to run.

Suggest me how can i optimize the queries involved for improved performance.

SELECT BELNR BUKRS FROM BSEG INTO TABLE L_DOC_NO

WHERE BUKRS IN S_BUKRS

AND GJAHR = P_GJAHR

AND HKONT IN S_SAKNR.

IF SY-SUBRC <> 0.

MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.

ENDIF.

CLEAR L_DOC_NO.

SORT L_DOC_NO BY BELNR.

  • Selecting the Document Number Based on the selection-screen.

SELECT BELNR BUKRS BUDAT CPUDT BLART MONAT FROM BKPF INTO TABLE L_BKPF

FOR ALL ENTRIES IN L_DOC_NO

WHERE BUKRS = L_DOC_NO-BUKRS AND

BELNR = L_DOC_NO-BELNR AND

GJAHR = P_GJAHR AND

BUDAT IN S_BUDAT AND

MONAT IN S_MONAT.

IF SY-SUBRC <> 0.

MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.

ENDIF.

*Fetch the Line Items

SORT L_BKPF BY BELNR.

SELECT BELNR BUKRS BUZEI HKONT SHKZG WRBTR FROM BSEG INTO TABLE L_BSEG

FOR ALL ENTRIES IN L_BKPF

WHERE BUKRS = L_BKPF-BUKRS

AND BELNR = L_BKPF-BELNR

AND GJAHR = P_GJAHR

AND BUZEI BETWEEN '001' AND '999'.

IF SY-SUBRC <> 0.

MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.

ENDIF.