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

Avoid querying BSEG

ricky_shaw
Contributor
0 Likes
2,643

Hello,

I want to avoid hitting the BSEG table.

My requirement is to get the individual sum of line items in a given PO.

Is there any way that i can avoid querying BSEG table?

My queries are like below :

EKBE -->BKPF(awkey = belnr+year)-->BSEG table

1) Getting BELNR from EKBE .

2) And then using BELNR+GJAHR from EKBE to query the BKPF tables and get the BKPF-BELNR

3) Hit BSEG-BELNR (using above BKPF-BELR) and sum up different items.

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
0 Likes
2,390

Hello ricky.shaw

Please check if you have an AWKEY index in the BKPF table. It's a standard one, so you should have it. This index contains 4 fields: MANDT, AWTYP, AWKEY and AWSYS. If you will query the BKPF table using these fields (MANDT - automatically added, AWTYP and AWKEY) then the selection should be quite fast (thanks to the DB index). Please make sure you have the AWTYP field in your conditions.

Then, query the BELNR using the PRIMARY KEY of the table, which is BUKRS, BELNR, GJAHR - and it should be fast too.

Kind regards,
Mateusz
9 REPLIES 9
Read only

MateuszAdamus
Active Contributor
2,390

Are you using the BSEG-BUKRS and BSEG-GJAHR key fields too?


Kind regards,
Mateusz
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,390

Why do you want to avoid BSEG? You don't run S/4HANA?

Read only

ricky_shaw
Contributor
0 Likes
2,390

Hi Sandra,

No, we are not using S/4 HANA. Will that make a difference?

Hi mateuszadamus Yes..i am mentioning all those fields in the query.

But getting data from BKPF is also taking more time.

Can you pls suggest.

Read only

0 Likes
2,390

Please use "Comment" feature when providing more information or commenting.


Kind regards,
Mateusz
Read only

2,390

Yes, that makes a difference because BSEG is a special type of table (clustered) in versions before S/4HANA and that makes a lot of differences (in performance, in ABAP, etc.) With S/4HANA, all clustered tables have been converted into normal tables (I don't talk about tables containing "data clusters", like STXL, INDX, etc.)

Yet, my first main question is still unanswered: Why do you want to avoid BSEG?

NB: please use "comment".

Read only

2,390

BSEG can be transparent, but it has to be converted during system upgrade. SAP OSS notes on the subject:

https://launchpad.support.sap.com/#/notes/1892354

https://launchpad.support.sap.com/#/notes/2227432


Kind regards,
Mateusz
Read only

2,390

Mateusz Adamus I wonder how much percentage of customers dared converting BSEG, I mean NOT under the direct advice of SAP 😉

Read only

MateuszAdamus
Active Contributor
0 Likes
2,391

Hello ricky.shaw

Please check if you have an AWKEY index in the BKPF table. It's a standard one, so you should have it. This index contains 4 fields: MANDT, AWTYP, AWKEY and AWSYS. If you will query the BKPF table using these fields (MANDT - automatically added, AWTYP and AWKEY) then the selection should be quite fast (thanks to the DB index). Please make sure you have the AWTYP field in your conditions.

Then, query the BELNR using the PRIMARY KEY of the table, which is BUKRS, BELNR, GJAHR - and it should be fast too.

Kind regards,
Mateusz
Read only

gasparerdelyi
Product and Topic Expert
Product and Topic Expert
0 Likes
2,390

Let me add for the sake of completeness: with the assumption that there is everything OK with the indices, there is no bad need for a reorg etc.