‎2008 Apr 14 2:47 PM
Hi
In my report I have as follow:
select * from bsid
into corresponding fields of table tt_bsid
where kunnr eq i_kunnr.
select * from bseg
into corresponding fields of table tt_bseg
for all entries in tt_bsid
where bukrs = tt_bsid-bukrs and
gjahr = tt_bsid-gjahr and
rebzg = tt_bsid-rebzg.
but the second select (select from bseg....) run some minutes.
Do you have any idea, in which way prepare correctly the select?
thx in advance and best regards
JS
‎2008 Apr 14 3:10 PM
hi,
hi Basically u should not use BSEG tables for selection utill u know the primary keys values .....
As bseg table stores all the information it takes several minitues to execute...
there are some views for bseg table
bsis,bsas,bsid,bsad,bsik,bask
find out which will be useful for u and use it.
ur program berformance will increase..
regards,
priya
‎2008 Apr 14 2:53 PM
Hi John,
There is no proble with the select statement ( from bseg ).
Normally for selecting data from tables like BSEG , MSEG etc will take so much time.
Regards,
Raja.K
‎2008 Apr 14 2:54 PM
hi,
Sort tt_bsid with primary keys before second select statement and select only required fields instead of "*'.
If you are selecting only few fields thn use select into table instead of into corresponding fields of table, but order of fields should be proper.
Hope it helps.
Regards,
Siddhesh S.Tawate
‎2008 Apr 14 2:56 PM
Try this way..
DATA: tt_bsid like bsid occurs 0 with header line,
tt_bseg like bseg occurs 0 with header line.
select * from bsid
into table tt_bsid
where kunnr eq i_kunnr.
SORT tt_bsid
by bukrs
gjahr
rebzg
buzei.
select * from bseg
into table tt_bseg
for all entries in tt_bsid
where bukrs = tt_bsid-bukrs and
gjahr = tt_bsid-gjahr and
rebzg = tt_bsid-rebzg AND
buzei = tt_bsid-buzei.
OR make a INNER JOIN... with the 2 tables
Edited by: heber rodarte on Apr 14, 2008 9:02 AM
‎2008 Apr 14 2:56 PM
While selecting from BSEG (Cluster tables) you need to use proper key for the select. If you check the BSEG primary keys BUKRS
BELNR GJAHR BUZEI. Here you not using full key for the selection,
There are several index tables - bsis,bsas,bsad,bsik,bsak. Each contains a different subset of columns from table bseg.
a®
‎2008 Apr 14 2:58 PM
Hi
Specify the field names from bseg table
and use below select
select BUKRS BELNR GJAHR BUZEI from BSEG
into table it_bseg
for all entries in tt_bsid
where BUKRS eq tt_bsid-bukrs
and BELNR eq tt_bsid-belnr
and GJAHR eq tt_bsid-gjahr
and BUZEI eq tt_bsid-BUZEI.
Use delete statement on it_bseg for unwanted records
‎2008 Apr 14 3:00 PM
Hi John,
please include BSID-BELNR in the BSEG Select. Check also that tt_bsid is not empty beforehand.
Cheers
Thomas
‎2008 Apr 14 3:10 PM
hi,
hi Basically u should not use BSEG tables for selection utill u know the primary keys values .....
As bseg table stores all the information it takes several minitues to execute...
there are some views for bseg table
bsis,bsas,bsid,bsad,bsik,bask
find out which will be useful for u and use it.
ur program berformance will increase..
regards,
priya
‎2008 Apr 14 3:16 PM
Hi,
BSEG is a cluster table, it will have huge data. You need to use all the key fields of BSEG table. Instead of selecting all the fields like * you have choose required fields only for both BSID and BSEG.
You change code as below for retrieving the data from BSEG table.
select <required fields> from bseg
into table tt_bseg
for all entries in tt_bsid
where bukrs = tt_bsid-bukrs and
belnr = tt_bsid-belnr and
gjahr = tt_bsid-gjahr and
buzei = tt_bsid-buzei and
rebzg = tt_bsid-rebzg.
Thanks,
Sriram Ponna.
‎2008 Apr 14 3:20 PM
thanx for your help
but kindly please note, I can't use belnr in the select because I need for one record form bsid some records from bseg with diferenses value in belnr. I can't use gjahr in the select too because one doc from bseg can be in 2007 and second document from bseg can be in 2008 year.
thx in advance
JS
‎2008 Apr 14 3:23 PM
strange, because one record from BSID points to exactly one record from BSEG. Sorry, I don't understand the underlying logic and thus cannot help further.
‎2008 Apr 14 3:37 PM
H Thomas
you are right
bsid-belnr = bseg-belnr results only one record from bseg
but bsid-rebzg = bseg-rebzg results some records from bseg.
thx
JS
‎2008 Apr 14 8:54 PM
So long as you are looking at customer and/or vendor invoices only, there is a secondary index on REBZG in BSID, BSAD, BSIK and BSAK. You should go against those tables instead. You should also add the company code to all of your SELECTs.
Rob
‎2008 Apr 14 9:02 PM
Take a look at this weblog...
[Quickly Retrieving FI document Data from BSEG|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7692] [original link is broken] [original link is broken] [original link is broken];
Greetings,
Blag.