Skip to Content
-2

Fetching from BSEG table without key fields

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Apr 23 at 10:51 AM

    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

    Add comment
    10|10000 characters needed 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.

  • Apr 22 at 12:32 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 23 at 07:15 AM
    • 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.)
    Add comment
    10|10000 characters needed characters exceeded