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

Joining BKPF & BSEG

Former Member
0 Likes
19,238

Hi ,

In my requirement,

Select * from bkpf

into table t_bkpf

where bukrs in s_bukrs.

if not t_bkpf[] is initial.

select * from bseg

into table t_bseg

for all entries in t_bkpf

where bukrs = t_bkpf-bukrs.

endif.

My 2nd internal table is taking much duration for next step.....I know BSEG is a cluster table....huge amount of values have been fetched.

Kindly help me to overcome this issue

Hi ,

In my requirement,

Select * from bkpf

into table t_bkpf

where bukrs in s_bukrs.

if not t_bkpf[] is initial.

select * from bseg

into table t_bseg

for all entries in t_bkpf

where bukrs = t_bkpf-bukrs.

endif.

My 2nd internal table is taking much duration for next step.....I know BSEG is a cluster table....huge amount of values have been fetched.

Kindly help me to overcome this issue

13 REPLIES 13
Read only

ThomasZloch
Active Contributor
0 Likes
8,461

I'm sure you can solve this yourself.

Investigate which fields are common in the primary keys of both tables, then compare the result with your current where-condition for BSEG.

Do you really need all columns? Better use a field list and declare the internal tables accordingly.

Thomas

Read only

0 Likes
8,461

hi Thomas,

thanks for ur prompt response....as u told i have used BELNR BUKRS & GJAHR in where condition....but also time exceeds

Read only

VenkatRamesh_V
Active Contributor
0 Likes
8,461

Hi,

Based on you requirement thier are many alternate table for bseg.

Vendor    - BSIK & BSAK

Customer - BSID & BSAD

GL            - BSIS & BSAS.


You can use appending table in select query to join


Hope it helpful,

Regards,

Ramesh.V

Read only

0 Likes
8,461

it is Accounting document header

Read only

0 Likes
8,461

Hi,

Its not clear , you are going to develop a report for vendor or customer or  gl  details?.

BSEG =  tables entries will also  be available in the following tables.

Vendor    - BSIK & BSAK

Customer - BSID & BSAD

GL            - BSIS & BSAS.

Hope  it helpful,

Regards,

Venkat.

Read only

former_member197132
Participant
0 Likes
8,461

Hi Barani,

Use below Code.

Select * from bkpf

into table t_bkpf

where bukrs in s_bukrs.

if not t_bkpf[] is initial.

select * from bseg

into table t_bseg

for all entries in t_bkpf

where bukrs = t_bkpf-bukrs.

and belnr  = t_bkpf-belnr

and gjahr = t_bkpf-gjahr

endif.

Read only

0 Likes
8,461

i have tried this method.....but not wrking

Read only

0 Likes
8,461

Why are you doing a 'Select *'. Do you need all the fields from the BKPF and BSEG tables in your program?

Select only those fields which are required to reduce considerable amount of time. Also, try to use primary key fields in both select queries.

Read only

0 Likes
8,461

Barani G wrote:

i have tried this method.....but not wrking

That doesn't help much. Can you tell us what about it is not working? This is a pretty standard way of getting accounting documents.

Rob

Read only

Former Member
0 Likes
8,461

Which kind of category you need and use alternate table for your query.

BSID Accounting: Secondary Index for Customers(Open Items)

BSAD Accounting: Secondary Index for Customers(Cleared Items)

BSIM Secondary Index, Documents for Material

BSIS Accounting: Secondary Index for G/L Accounts

BSAS Accounting: Secondary Index for G/L Accounts(Cleared Items)

BSAK Accounting: Secondary Index for Vendors(Cleared Items)

BSIK Accounting: Secondary Index for Vendors

all data from above tables are stored inside BSEG table. with additional fields to make separation.

Read only

0 Likes
8,461

Hello,

Look always silly, but to my mind :

Select * from bkpf where bukrs in s_bukrs.

select * from bseg appending  table t_bseg

where bukrs =bkpf-bukrs.

and belnr  = bkpf-belnr

and gjahr = bkpf-gjahr

endselect.

Should Work better ( For all entries sometime give  a bad result).

Nevertheless, theses select should fill all memory of your application server. and you should expect  a nice memory dump.

And think to the huge amount of data your query should get.

Sincerely yours

Christophe Blineau

Read only

0 Likes
8,461

I really doubt if the problem has to do with the tables being used or the way the SELECT(s) is/are being constructed. The OP is retrieving all documents for a company code. If there are a large number of documents, it will take time.

There is no getting around that.

Rob

Read only

akshatrander1990
Explorer
0 Likes
8,461

This message was moderated.