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

Poor performance select from bsak

Former Member
0 Likes
780

Hello,

i need to select data first from BSAS this is processed quickly but the second select statement is very poor. But I dont know why because number of records are cca the same and indexes are on the same fields. Should I have remove "corresponding" statement?

  • SELECT bsasbukrs bsashkont bsasaugbl bsaszuonr bsas~gjahr

  • bsasbelnr bsasbuzei bsasblart bsasshkzg bsas~dmbtr

  • bsaswrbtr bsassgtxt bsaskostl bsaspswsl bsas~pswbt

  • FROM bsas INNER JOIN bkpf

  • ON bsasbukrs = bkpfbukrs

  • AND bsasaugbl = bkpfbelnr

  • AND bsasaugdt = bkpfbudat

  • INTO CORRESPONDING FIELDS OF TABLE i_bseg

  • WHERE bkpf~bukrs = p_bukrs

  • AND ( bkpfblart = c_ab OR bkpfblart = c_sa )

  • AND bkpf~cpudt IN r_date

  • AND bkpf~cputm >= w_utime

  • AND bkpf~cputm <= w_utime1.

  • SELECT bsakbukrs bsaklifnr bsakaugbl bsakzuonr

  • bsakgjahr bsakbelnr bsakbuzei bsakblart

  • bsakshkzg bsakdmbtr bsakwrbtr bsaksgtxt bsak~hkont

  • bsakkostl bsakxref2 bsakpswbt bsakpswsl

  • FROM bsak INNER JOIN bkpf

  • ON bsakbukrs = bkpfbukrs

  • AND bsakaugbl = bkpfbelnr

  • AND bsakaugdt = bkpfbudat

  • APPENDING corresponding fields of table i_bseg

  • WHERE bkpf~bukrs = p_bukrs

  • AND ( bkpfblart = c_ab OR bkpfblart = c_sa )

  • AND bkpf~cpudt IN r_date

  • AND bkpf~cputm >= w_utime

  • AND bkpf~cputm <= w_utime1.

4 REPLIES 4
Read only

rahulkavuri
Active Contributor
0 Likes
589

hi is ur internal table structure exactly same as ur selection fields, in that case u remove the corresponding addition there

Suppose there is an internal table like this

data: begin of itab,

matnr like mara-matnr,

mtart like mara-mtart,

end of itab.

now if use

select * from mara into corresponding fields of itab.

This will search all the field names in MARA to match strcture of itab. this detiorates performance

reward points if found helpful

Read only

Former Member
0 Likes
589

Hi,

IF internal table structure is not exactly same as your selection fields then make it according to selection fields as written in select statement & replace INTO CORRESPONDING FIELDS OF TABLE i_bseg

with INTO TABLE i_bseg.

Ashven

Read only

Former Member
0 Likes
589

the secondary index tables (BSAS and BSAK) are really only meant to be used when you know the GL account or vendor, which in this case you don't know.

I would re-write the SELECTS to first go against BKPF and then use FOR ALL ENTRIES to go against BSEG.

Yout SELECT against BKPF doesn't use the index very well, but if you check out this, it will show you how to speed that up as well:

/people/rob.burbank/blog/2006/09/13/using-an-index-when-you-dont-have-all-of-the-fields

Rob

Read only

Former Member
0 Likes
589

Hi Triska,

Since you have BUKRS and BLART (C_ab, c_sa....) along with all other possible parameters,

Write a query seperately on BKPF,

and after that use BSAS & BSAK seperately, for all entries in t_bkpf..

Hope this will help

Regards,

Message was edited by:

MANJUNATHA KS