Skip to Content
-2

Fetching from BSEG table without key fields

Apr 22 at 10:57 AM

112

avatar image

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??

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Gustavo Vazquez Apr 23 at 10:51 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
Domi Bigl Apr 22 at 12:32 PM
0

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

Show 5 Share
10 |10000 characters needed characters left characters exceeded

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
Matthew Billingham

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

0

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

0

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

0

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

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

1
Raymond Giuseppi Apr 23 at 07:15 AM
0
  • 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.)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
0