Application Development 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: 

Fetching from BSEG table without key fields

0 Kudos

Hi Experts,

I need to get BELNR from bseg table, all i have is Company Code, Year, PO number.

The following is my query,

SELECT BUKRS BELNR GJAHR BUZEI EBELN XREF3 FROM BSEG INTO TABLE IT_BELNR FOR ALL ENTRIES IN IT_BSEG_TEMP WHERE BUKRS = IT_BSEG_TEMP-BUKRS AND GJAHR = IT_BSEG_TEMP-GJAHR AND EBELN = IT_BSEG_TEMP-EBELN AND XREF3 = IT_BSEG_TEMP-XREF3.

My requirement is to get Goods Receipt Accounting document number from Invoice Accounting Document details. So in IT_BSEG_TEMP I have Invoice Accounting details.

Even though I'm getting only 1 or 2 documents with the above query, it takes more than 15 seconds to fetch data.. some times it will end in runtime error.

So how can i solve this issue??

1 ACCEPTED SOLUTION

Gustavo_Vazquez
Active Contributor
0 Kudos

Hi Nidhi,

As you have PO Order, Year, Company Code, you could go to EKBE table (PO history) and then go to MKPF, RBKP and BSEG document.

Are you on ERP 6 or S/4 HANA ?

Kind Regards

10 REPLIES 10

Domi
Contributor
0 Kudos

Hi

Since BSEG seems to be still (see Matthees comment) a cluster table, no index is possible but you can use BSIK (maybe there is also some other Index table?) with a Z-index to fetch the BELNR and read BSEG with full key.

Do you check if IT_BSEG_TEMP is empty befor the SELECT? - otherwise it will try to fetch all the data, which can cause the dump!

regards

Domi

matt
Active Contributor
0 Kudos

BSEG is a transparent table on systems using HANA. It's also been possible to convert it to a transparent table (though not recommended) for quite a while. The reason cluster tables exist at all is that some databases, at least historically, had a limitation on the number of fields a table could have.

0 Kudos

Thats absolutely right, but if this would be the case, I think - at least, hope - they would have tried an Z index!

0 Kudos

I am planning to try Index.. but I am not sure it will work.

0 Kudos

@ dominik.. thank you for replying..

I already checked IT_BSEG_TEMP is initial before fetching. I tried BSIK but most of the records I couldnt find there.

SimoneMilesi
Active Contributor

You have different index tables for BSEG: BSIK, BSAK, BSID, BSAD.

Based on your scenario, choose the ones fitting more your needs

raymond_giuseppi
Active Contributor
0 Kudos
  • If you only look for receipt/invoice from MM and not manually input document in FI, you could use table EKBE.
  • Else you could try to use table BSIS and BSAS and not BSIK and BSAK as some documents can not contain a vendor line, but some GR/IR clearing account. (Insure that EBELN is part of those tables, else adding it in an append so it will be filled, as SAP use some corresponding statements, you would be required to create some data transfer one-shot report for legacy purpose.)

0 Kudos

Gustavo_Vazquez
Active Contributor
0 Kudos

Hi Nidhi,

As you have PO Order, Year, Company Code, you could go to EKBE table (PO history) and then go to MKPF, RBKP and BSEG document.

Are you on ERP 6 or S/4 HANA ?

Kind Regards

0 Kudos

Thank you all for the response.

@Gustavo Vazquez I already did like that and it's working now.

with bseg-ebeln and ebelp of invoice accounting document, fetch from ekbe (po history table) from there we will get invoice document number (ekbe-belnr).. we concatenate ekbe-belnr+gjahr and pass to awkey field in bkpf.. there we will GR accounting Document numbers.