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

selection from BSEG

Former Member
0 Likes
1,180

Hi,

Is there any way to improve the performance of the following query as I am selecting data from clustered table BSEG for all entries found in one another internal table.

select belnr WRBTR dmbtr from bseg

for all entries in t_cobrb

where bukrs =t_cobrb-bukrs and

hkont = t_cobrb-hkont

and zuonr = t_cobrb-zuonr.

please suggest

thanks

1 ACCEPTED SOLUTION
Read only

vinod_gunaware2
Active Contributor
0 Likes
975

Use following table instead of BSEG

BSEG Access

BSAD Accounting: Secondary index for customers (cleared items)

BSAK Accounting: Secondary index for vendors (cleared items)

BSAS Accounting: Secondary index for G/L accounts (cleared items)

BSID Accounting: Secondary index for customers

BSIK Accounting: Secondary index for vendors

BSIM Secondary Index, Documents for Material

BSIS Accounting: Secondary index for G/L accounts

regards

vinod

Hi,

Is there any way to improve the performance of the following query as I am selecting data from clustered table BSEG for all entries found in one another internal table.

select belnr WRBTR dmbtr from bseg

for all entries in t_cobrb

where bukrs =t_cobrb-bukrs and

hkont = t_cobrb-hkont

and zuonr = t_cobrb-zuonr.

please suggest

thanks

7 REPLIES 7
Read only

Former Member
0 Likes
975

when using FOR ALL ENTRIES , check if the table is not initial

<b>if t_cobrb[] is not initial.</b>
select belnr WRBTR dmbtr from bseg
for all entries in t_cobrb
where bukrs =t_cobrb-bukrs and
hkont = t_cobrb-hkont
and zuonr = t_cobrb-zuonr.
<b>endif.</b>

Read only

Former Member
0 Likes
975

Hai Bobby

write like this

first you will sort t_cobrb by Key field(bukrs)

if not t_cobrb[] is initial.

select belnr WRBTR dmbtr from bseg

for all entries in t_cobrb

where bukrs =t_cobrb-bukrs and

hkont = t_cobrb-hkont

and zuonr = t_cobrb-zuonr.

endif.

Thanks & regards

Sreenivasulu P

Read only

vinod_gunaware2
Active Contributor
0 Likes
976

Use following table instead of BSEG

BSEG Access

BSAD Accounting: Secondary index for customers (cleared items)

BSAK Accounting: Secondary index for vendors (cleared items)

BSAS Accounting: Secondary index for G/L accounts (cleared items)

BSID Accounting: Secondary index for customers

BSIK Accounting: Secondary index for vendors

BSIM Secondary Index, Documents for Material

BSIS Accounting: Secondary index for G/L accounts

regards

vinod

Read only

Former Member
0 Likes
975

hi Bobby,

sort t_cobrb by key fields. and also check if it is initial before selecting the data from bseg.

if t_cobrb is not initial.

select belnr WRBTR dmbtr from bseg

for all entries in t_cobrb

where bukrs =t_cobrb-bukrs and

hkont = t_cobrb-hkont

and zuonr = t_cobrb-zuonr.

endif.

into table is missing in the above query and also take care that the order of selection of fiels belnr,wrbtr,dmbtr matches the order in the datbase table bseg. this will improve the performance.

Award points if helpful.

regards,

keerthi.

Read only

Former Member
0 Likes
975

Select statement will work faster if we provide the fields in WHERE clause in the same order as they exists in the table.

in your case ZUONR appears before than HKONT.so give ZUONR first & then HKONT next.

select belnr WRBTR dmbtr from bseg

for all entries in t_cobrb

where bukrs =t_cobrb-bukrs

<b>and zuonr = t_cobrb-zuonr

and hkont = t_cobrb-hkont.</b>

and also if you are using FOR ALL ENTRIES its always suggestable to check the table is not initial.

In your case first check T_COBRB[] IS NOT INTIAL. THEN go for select. else all records from BSEG will come to your table.

& one more thing <b>where is your target internal table</b> ??

regards

srikanth

Message was edited by: Srikanth Kidambi

Read only

Former Member
0 Likes
975

Try to see the secondary index table BSIS , query on BSIS table,will solve problem. since BSEG is cluster.

if not t_cobrb[] is initial.
select belnr WRBTR dmbtr from<b> bsis</b>
for all entries in t_cobrb
where bukrs =t_cobrb-bukrs and
hkont = t_cobrb-hkont
and zuonr = t_cobrb-zuonr.
endif.

Regards

vijay

Read only

0 Likes
975

hi,

the reproof to tables BSIK, BSAK, etc. isn't correct in that requirement.

Its' only correct when Bobby is searching documents from vendors or customers only. If he's searching documents for G/L-accounts ( it seems so, because of his where clause with HKONT) there are many accounts (P&L) which have no open item-management. And so no BSIS / BSAS.

So try 1st to select table bkpf and than Bseg with key bukrs belnr gjahr.

Andreas