Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regarding select query affects performance

Former Member
0 Likes
387

Hi experts,

we have one select query in it we fetch data from BSEG table

1. as BSEG table is cluster table .

2.we fetch fields

belnr

bukrs

gjhar

hkont

now the problem is tht BSEG is cluster table

and HKONT is a field tht i fetch from BSEG table

This field is not availabale in BKPF table tht is Transparent Table

otherwise i can fetch whole data from BKPF

SO PLS PROVIDE ME THE CORRECT SOLUTION REGARDING FOLLOWING CODE:

FORM GET_DATA .

  • Selecting the Document number from BSEG table

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.

ASAP,

REGARDS

MAHAMMAD

2 REPLIES 2
Read only

JozsefSzikszai
Active Contributor
0 Likes
369

hi,

instead of BSEG select from BSIS (open items) and BSAS cleared items):

SELECT belnr bukrs FROM bsis INTO TABLEl_doc_no

WHERE bukrs IN s_bukrs

AND hkont IN s_saknr

AND gjahr = p_gjahr.

repeat it for BSAS as well

hope it helps

ec

Read only

Former Member
0 Likes
369

HI,

I didn't understand the useage of two select query for bseg table.

Just follow the sequence

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

WHERE

BUKRS IN S_BUKRS

AND GJAHR = P_GJAHR

AND HKONT IN S_SAKNR

AND BELNR = L_BKPF-BELNR

AND BUZEI BETWEEN '001' AND '999'.

then the other select query for bkpf.

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.

AWARD POINTS IF USEFUL