‎2008 Dec 10 6:30 PM
Hello SAPinas,
I am using the following lines of code in one of my program. Becuase of that code I am getting Performance issue.
Note : BSEG is Cluster Table.
Could you please help me how I will use in another way
loop at t_hdr.
select buzei buzid koart shkzg mwskz dmbtr hwbas sgtxt vbund kostl
aufnr anln1 anln2 hkont kunnr lifnr matnr werks ebeln ebelp
zekkn rewrt prctr txjcd projk
into (t_item-buzei, t_item-buzid, t_item-koart, t_item-shkzg,
t_item-mwskz, t_item-dmbtr, t_item-hwbas, t_item-sgtxt,
t_item-vbund, t_item-kostl, t_item-aufnr, t_item-anln1,
t_item-anln2, t_item-hkont, t_item-kunnr, t_item-lifnr,
t_item-matnr, t_item-werks, t_item-ebeln, t_item-ebelp,
t_item-zekkn, t_item-rewrt, t_item-prctr, t_item-txjcd,
t_item-projk)
from bseg
where bukrs = t_hdr-bukrs
and belnr = t_hdr-belnr
and gjahr = t_hdr-gjahr
and hkont in s_hkont
and mwskz in s_mwskz
and kostl in s_kostl
and prctr in s_prctr
and werks in s_werks.
Skip record if not in selection screen range for state
check t_item-txjcd(2) in s_state.
if t_item-shkzg = c_debit. "S
endif.
if t_item-shkzg = c_credit. "H
t_item-dmbtr = t_item-dmbtr * ( -1 ).
t_item-rewrt = t_item-rewrt * ( -1 ).
t_item-hwbas = t_item-hwbas * ( -1 ).
endif.
**&MWB 04/08/2005 ... add additional US Bayer Tax dept requested fields
clear: t_item-basetax, t_item-accrtax, t_item-vendtax,
t_item-taxrate, t_item-invbase, t_item-invtax.
**&MWB ... end insert 04/08/2005
clear t_item-hwbas.
*
move-corresponding t_hdr to t_item.
append t_item.
clear t_item.
endselect.
endloop.
Thank you very much Advance.............:-)
‎2008 Dec 10 6:33 PM
Hi,
try to use the secondary Indexes . I Think we dopnt have index s for Cluster table.
Try avoid the BSEG select stmt in the LOOP.
regards,
ram
Edited by: ram reddy on Dec 10, 2008 7:34 PM
Edited by: ram reddy on Dec 10, 2008 7:35 PM
‎2008 Dec 10 6:42 PM
As BSEG is in a cluster table RFBLG, the only index available is the primary one, so only BUKRS, BELNR and GJAHR keys are actually available. So for other criteria resolution, the program will read the whole cluster, unpacking the records and executing the selection. When most criteria come from BKPF header, you may select from BKPF and then from BSEG using the full key of the cluster, and using a [FOR ALL ENTRIES|http://help.sap.com/abapdocu/en/ABENOPEN_SQL_PERFO.htm] IN a table with the keys from BKPF.
Try to use one or more of the secondary indexes provide by SAP
- 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
These indexes are actual tables, so you may create/use indexes, they are also easily appended, as they are filled via move-corresponding statements.
Try a little search at sdn on keywords like [BSEG, cluster and performance|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=bsegclusterperformance&adv=false&sortby=cm_rnd_rankvalue].
Regards
‎2008 Dec 10 7:45 PM
Hi Kishore,
Try to select using for all entries, maybe you'll need to create an index on for fields BUKRS, BELNR, GJAHR.
After selection, create a routine to delete rows where t_item-txjcd(2) not in s_state
‎2008 Dec 12 6:42 PM
after following all the above suggestions, my tip is to change the below one,
move-corresponding t_hdr to t_item.
instead, u move explicitly for each field.....may be increase the performence a bit!!
‎2008 Dec 14 12:39 PM
Try also to use[ SE30|https://www.sdn.sap.com/irj/scn/advancedsearch?query=+se30&cat=sdn_all] (documentaion [Runtime Analysis|http://help.sap.com/erp2005_ehp_04/helpdata/EN/c6/617cafe68c11d2b2ab080009b43351/frameset.htm]) on your report to analyze the steps that are time consuming : database access or calculations.
Regards
‎2009 Jun 09 3:02 PM