‎2007 Oct 25 6:09 AM
Hi Experts
I am supposed to use this query, but it affects the performance, please suggest me how to improve performance.
Thanks in advance.
Regards
Rajaram
SELECT shkzg
skfbt
dmbtr
wskto
belnr
gjahr
bukrs
qbshb
lifnr
bschl
nebtr
rebzg
FROM bseg
INTO corresponding fields of TABLE ibseg
WHERE bukrs = p_bukrs
AND belnr NE p_vblnr
AND augbl = p_vblnr
AND auggj = p_gjahr
AND koart = 'K'.
‎2007 Oct 25 6:27 AM
Most of the data u need is available in BSIK,BSAK tables.. if any additional if u need from BSEG,
try for all entries with the data u fetch from BSIK and BSAK and fetch these values passing all key fields to BSEG
‎2007 Oct 25 6:12 AM
Hi,
BSEG is a cluster table and populating data from BSEG without passing primary keys extracting data will take a long time.
You can first get data from BSAK / BSAD, then populate data from BSEG using key values of BSAD / BSAK.
This will definitely improve your performance.
ashish
‎2007 Oct 25 6:12 AM
Hi
Take one doc number and search in the tables
BSIK,BSAK for vendor related
BSIS and BSAS fofr GL related
BSID and BSAD for Customer related data
and use the respective tables instead of BSEG
first check physically in those tables and then write a querry
Regards
Anji
‎2007 Oct 25 6:19 AM
HI Ram,
Also, You can do this,
Use 'INTO table' instead of into corresponding fields of table.
For this you have to have the fields in the same order as they are in the database table.
Regards,
PRitha.
Reward if helpful.
‎2007 Oct 25 6:21 AM
Hi Raja,
You should use BSIK,BSAK tables instead of BSEG as you only need vendor data.
Regards,
Atish
‎2007 Oct 25 6:27 AM
Use OPEN CURSOR & FETCH instead of just a SELECT.
Using OPEN CURSOR & FETCH you can limit selections to 1000 records at a time. Also, try using all the keys to improve the performance of selection.
Example:
OPEN CURSOR WITH HOLD db_cursor FOR
SELECT (g_field_list) FROM bseg
UP TO g_max_docs ROWS
WHERE bukrs IN r_bukrs
AND gjahr = g_fiscal_year.
DO.
FETCH NEXT CURSOR db_cursor
INTO CORRESPONDING FIELDS OF TABLE ibseg
PACKAGE SIZE g_package_size.
IF sy-subrc NE 0.
CLOSE CURSOR db_cursor.
EXIT.
ENDIF.
ENDDO.
‎2007 Oct 25 6:27 AM
Most of the data u need is available in BSIK,BSAK tables.. if any additional if u need from BSEG,
try for all entries with the data u fetch from BSIK and BSAK and fetch these values passing all key fields to BSEG