‎2007 Feb 08 1:33 PM
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.
‎2007 Feb 08 1:36 PM
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
‎2007 Feb 08 1:39 PM
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
‎2007 Feb 08 2:37 PM
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
‎2007 Feb 08 3:11 PM
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