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 problem with table BSEG

Former Member
0 Likes
1,635

Hi Guru's

this is the select Query which is taking much time in Production. so please help me to improve the preformance with BSEG.

this is my select query:

select bukrs

belnr

gjahr

bschl

koart

umskz

shkzg

dmbtr

ktosl

zuonr

sgtxt

kunnr

from bseg

into table gt_bseg1

for all entries in gt_bkpf

where bukrs eq p_bukrs

and belnr eq gt_bkpf-belnr

and gjahr eq p_gjahr

and buzei in gr_buzei

and bschl eq '40'

and ktosl ne 'BSP'.

UR's

GSANA

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
1,264

You are using the primary key, so not much you can do, other than making sure that gt_bkpf is not empty, is sorted by belnr and contains no duplicate belnr.

BSEG is usually a large table, so if you have many entries in gt_bkpf going into the select, it will take time.

BS* tables will not help here, I cannot see any customer, vendor or g/l account in the selection criteria.

Thomas

9 REPLIES 9
Read only

Former Member
0 Likes
1,264

Hi gsana sana,

Use other tables then BSEG

BSAD                           Accounting: Secondary Index for Customers Cleared Items
BSAK                           Accounting: Secondary Index for Vendors Cleared Items

BSID                           Accounting: Secondary Index for Customers
BSIK                           Accounting: Secondary Index for Vendors

Also have a look on other BS* tables

it will be good for performace..

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,264

Delete the FAE clause and use the in clause in the where condition.

Read only

ThomasZloch
Active Contributor
0 Likes
1,265

You are using the primary key, so not much you can do, other than making sure that gt_bkpf is not empty, is sorted by belnr and contains no duplicate belnr.

BSEG is usually a large table, so if you have many entries in gt_bkpf going into the select, it will take time.

BS* tables will not help here, I cannot see any customer, vendor or g/l account in the selection criteria.

Thomas

Read only

0 Likes
1,264

>

> BS* tables will not help here, I cannot see any customer, vendor or g/l account in the selection criteria.

in the original code: and bschl eq '40' (read: posting key = 40 ==> G/L debit entries)

this clearly indicates that we search for G/L postings, so BSIS/BSAS could be alternatives

Read only

0 Likes
1,264

OK, but which ones? If you don't have any account numbers to narrow down the selection, then BSIS/BSAS are pretty much useless. It seems that OP is coming from a BKPF selection, probably using BUDAT, CPUDT, BLART or the likes, and now is looking up the corresponding BSEG entries.

We will not know until he publishes more of his code.

Thomas

Read only

Former Member
0 Likes
1,264

hi,

Better u can use the table bsik,bsak,bsad,bsid,bsas.

if u want to use the bseg table means just include the KOART field also.

regards

sathis

Read only

Former Member
0 Likes
1,264

Hi Sana,

How many entries are present in gt_bkpf ?

All other things seems fine. But if you can give logic to fetch data in gt_bkpf - it might be possible to combine bseg and bkpf query and use Join instead.

Regards,

Mohaiyuddin

Read only

Former Member
0 Likes
1,264

>

> Hi Guru's

>

> this is the select Query which is taking much time in Production. so please help me to improve the preformance with BSEG.

>

> this is my select query:

>

> select bukrs

> belnr

> gjahr

> bschl

> koart

> umskz

> shkzg

> dmbtr

> ktosl

> zuonr

> sgtxt

> kunnr

> from bseg

> into table gt_bseg1

> for all entries in gt_bkpf

> where bukrs eq p_bukrs

> and belnr eq gt_bkpf-belnr

> and gjahr eq p_gjahr

> and buzei in gr_buzei

> and bschl eq '40'

> and ktosl ne 'BSP'.

>

> UR's

> GSANA

Hi,

This is what I know and please if any expert think its incorrect, please do correct me.

BSEG is a cluster table with BUKRS, BELNR, GJAHR and BUZEI as the key whereas other key will be stored in database as raw data thus SAP apps will need to convert that raw data first if we are using other keys in where condition. Hence, I suggest to use up to buzei in the where condition and filter other condition in internal table level like using Delete statement. Hope its help.

Regards,

Abraham

Read only

Former Member
0 Likes
1,264

Hi,

The same fields can be found in the index tables

BSID

BSAD

BSIK

BSAK

BSIS

BSAS

for customers, vendors and G/L accounts seperately. Please select the data from these 6 tables or from customer and vendor related tables using appending in the select query.

eg:

select * from bsad into table i_bseg where <conditions>.

select * from bsid appending table i_bseg where <conditions>.

Try using these tables as surely there will be remarkable improvement in the performance.

Regards

Thabitha.