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

Performance

Former Member
0 Likes
751

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'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
729

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

6 REPLIES 6
Read only

Former Member
0 Likes
729

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

Read only

Former Member
0 Likes
729

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

Read only

Former Member
0 Likes
729

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.

Read only

Former Member
0 Likes
729

Hi Raja,

You should use BSIK,BSAK tables instead of BSEG as you only need vendor data.

Regards,

Atish

Read only

Sathish
Product and Topic Expert
Product and Topic Expert
0 Likes
729

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.

Read only

Former Member
0 Likes
730

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