Retrieving Accounting Document number based on PO numbers

Hey All,
        I have a list of PO numbers(EBELN) for which I am trying to get all Accounting information from BSIS. But before going to BSIS I am trying to determine the Accounting document number(BELNR) from some other table so that my select on BSIS will be efficient.
What I have tried uptill now is to go to EKBE with the PO numbers and get the Material document numbers. For some cases the material document number is the accounting document number and for others I have to go to BKPF with this material document number to get the accounting document number.
Is there any other easier and efficeint way of doing this?
Any input is highly appreciated.
Thanks

I am retrieving Large amounts of data, around 1.5 million from BSIS.
The code related to our discussion looks like this:
"First I get all related PO's for the last three years and determine the no of packets.
DO v_no_of_packets TIMES.
      IF v_end_indx GT v_total.
        v_end_indx = v_total.
      ENDIF.
      REFRESH i_ebeln_range[].
      APPEND LINES OF t_ebeln_range FROM v_start_indx TO v_end_indx TO i_ebeln_range.
      v_start_indx = v_end_indx + 1.
      v_end_indx   = v_end_indx + p_pkjsiz.
IF NOT i_ebeln[] IS INITIAL.
  CLEAR l_bkpf.
  REFRESH l_bkpf[].
  SELECT ebeln ebelp zekkn vgabe gjahr belnr buzei FROM EKBE INTO TABLE t_belnr
                     WHERE ebeln IN i_ebeln_range
                      AND vgabe IN ('1' ,'2').
  IF sy-subrc EQ 0.
    LOOP AT t_belnr.
    l_awkey+0(10) = t_belnr-belnr.
    l_awkey+10(10) = t_belnr-gjahr.
    IF t_belnr-vgabe = '1'.
      l_awtyp = 'MKPF'.
    ELSE.
      l_awtyp = 'RMRP'.
    ENDIF.
    SELECT SINGLE bukrs belnr gjahr blart budat
      FROM bkpf INTO l_bkpf
        WHERE awtyp = l_awtyp
        AND   awkey = l_awkey.
      IF sy-subrc EQ 0.
         APPEND l_bkpf.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDIF.
"Then
  SELECT zuonr hkont gjahr belnr buzei budat blart wrbtr shkzg xblnr
waers bukrs
   INTO TABLE i_bsis
   FROM bsis
   FOR ALL ENTRIES IN l_bkpf
    WHERE bukrs = l_bkpf-bukrs
                      AND  hkont IN r_hkont   "Contains all Accounts
                      AND  budat = l_bkpf-budat
                      AND  augdt = 0
                      AND  augbl = space
                      AND  gjahr = l_bkpf-gjahr
                      AND  belnr = l_bkpf-belnr
                      AND  blart = l_bkpf-blart
                      AND  gsber = c_zrl1.
  SELECT zuonr hkont gjahr belnr buzei budat blart wrbtr shkzg xblnr
waers bukrs
   APPENDING TABLE i_bsis
   FROM bsas
    FOR ALL ENTRIES IN l_bkpf
    WHERE bukrs = l_bkpf-bukrs
                      AND  hkont IN r_hkont
                      AND  budat = l_bkpf-budat
                      AND  augdt = 0
                      AND  augbl = space
                      AND  gjahr = l_bkpf-gjahr
                      AND  belnr = l_bkpf-belnr
                      AND  blart = l_bkpf-blart
                      AND  gsber = c_zrl1.
"Then process this data

Similar Messages

  • Retreiving accounting Doc number based on PO number

    Hi,
    In my abaprogram I need to retrieve the accounting document number for a given PO number which has been GR'd.
    I need to know the table which stores there details.
    I need acounting document number because I need to read the BKPF table for getting exchange rate for a PO.
    If I read the BKPF table based on Object key which I can retrieve from PO, the select query takes a long time  hence I think I need to read bkpf based on primary key ?
    Please advice,
    Regards,
    Shital

    Hi,
    Refer to these links...
    For BSID- Accounting Document Number corresponding PO Number is required
    Retrieving Accounting Document number based on PO numbers

  • How to findout the clearning document number based on the reference

    Hi all
    we  need to findout the clearning document number based on the reference number in financial transaction code.
    basically we know how to retrieve the data from table level using BKPF without non primary key as XBLNR but
    we  want to know is this any function module to retrieve the document number based on the reference number like XBLNR.
    Please confirm.
    Thanks
    K.Gunasekar

    you can get it from BSAD too. but again its not a primary key

  • How to find Invoice number linked to FI accounting document number ??

    Hello All,
    I have been looking around for all possible combinations to find the link between FI accounting document number (BSEG-BELNR) and Intercompany Invoice number (for which billing corr. to STOs' or POs' is done).
    The requirement is that during ERS posting, we have accounting document numbers (BSEG-BELNR) and associated STOs' for this (BSEG-EBELN), but we are unable to map the Intercompany Billing Invoice number(s) (where the billing corr. to STOs' obtained from BSEG-EBELN) to this accounting document number (BSEG-BELNR).
    Any pointers or detailed view solution would be of great help.
    Thanks,
    Ansh

    Hello DPM,
    Thank you for the descriptive help. But my requirement is to look for Intercomapny Billing number (VBRK-VBELN) linked to an accounting document number (BSEG-BELNR) and not Invoice Receipt Number.
    The steps that I am following are:
    From BSEG, found EBELN (Stock Transfer Order) and XREF3 (Reference Key, combination of fiscal yr., some ref. number, maybe GR no. and ref item no.), based on BELNR (Accounting document number).
    From EKBE, found XBLNR (Reference Delivery Number or Direct Intercompany Billing Number on which GR is done) based on
    EKBE - EBELN = BSEG - EBELN
    EKBE - BELNR = BSEG - XREF3 (only ref and item no., considering it to be a GR no.)
    EKBE - VGABE = '1' and EKBE - BEWTP = 'E'.
    From VBRP, found VBELN (Intercompany Billing No., which is a desired number) based on
    VBRP - AUBEL = EKBE -EBELN (Stock Transfer Order)
    VBRP - VGBEL = EKBE - XBLNR (Delivery number)
    Here, I am not sure about 2 things:
    Whether the reference no in BSEG-XREF3 will always be Goods Receipt number for Stock Transfer Order or not. If not, then what it can be and how I will have to proceed further then.
    Secondly, If in case for an accounting document number, I have 2 Stock Transfer orders (BSEG - EBELN) and same reference number (BSEG-XREF3), then from History table (EKBE) I get only single delivery based on which GR was doen for both STOs', then I shall be getting single Intercompany Billing Invoice from VBRP or different ?
    Kindly provide your inputs.
    Thanks,
    Ansh

  • Report with Invoice and Accounting Document Number

    Dear Experts,
    Here i have a requirement.
    I wanna a report which gives a Invoice (MIRO) and its accounting documents (Follow on document) in one page. Because If I view a MIRO document, for checking the accounting document, I need to click on Follow on doc, then I'll get.
    But If wanna see for 1000 MIRO documents with accounting document number, then I don't want to click 1000 times to see the account doc for respective Invoice number.
    The approximate format is,
    Column 1                              Column 2     Column 3        .......................              Column n
    MIRO  (Invoice number)                             Accountting Doc Number
    5100000099                                              5100000011
    Which tcode will give the both in one screen?
    Thanks in advance
    Regards,
    navahsek

    Hi,
    Enter Sork Key 002 for Vendor Master Record.
    and also you can check the Report in ECC 6.0
    MIR5 - Display List of Invoice Documents
    There you select Export Mode --> Display Accounting Document Number.
    You can get Report FI and MM Document Numbers.
    Hope It will Clear.
    Regards,
    Kishore

  • Invoice & Accounting Document Number

    Dear Experts,
    We are facing number range problem. When we are saveing an invoice then Invoice number and accounting document number showing different. It should come same number. Can you pls advice why this is happening and how I can resolve this issue.
    Thanks in advance for your kind support.
    Best Regards.
    Ripon Kumar Paul

    Dear Ripon,
    Please check the below which will help you achieve same document number:
    SAP gives you customizing options to make both document numbers the same. The solution lies in the number range assignment of the MM and FI document. You need to configure the MM document number assignment as internal and external for the FI documents. (FI documents are set up with external-assigned numbering, while the MM document has internal, or system-generated, numbering.) In this case, the MM document number is passed on to the FI document, which means that the number of the FI document is identical to the MM document.
    Because the document number assignment in MM is not company code-specific, in contrast to the FI document, you need to take the following points into consideration before using external document number assignments for FI documents. They have the following effects on your system:
    Continuous number assignments for FI documents are not guaranteed, especially if you have more than one company code.
    The document number ranges in MM and FI have to be the same for all company codes.
    In Release 4.6C, you need to use internal number assignments for revaluation documents, invoice reduction documents, Evaluated Receipt Settlement (ERS) postings, or reversal documents. There are no restrictions as of SAP Enterprise 4.70.
    Use a different number range assignment for FI invoice posting (FB60), because FI invoice postings usually use internal number range assignments and the postings originate in FI, not MM.
    If you use document parking and the number range intervals are fiscal year-dependent, you cannot change the posting date of the document if the fiscal year is different to that determined for the previous posting date. In this case you have to delete the document and re-enter it. There are no restrictions for fiscal year-independent number ranges.
    What do you do if you have already posted thousands of invoices in your system and the numbers are already different? In this case, you need to find unused number range intervals in MM and FI. Since most companies do not change the SAP standard delivered number ranges during the original implementation, number range interval 52 is usually available in MM and FI.
    Now let's look at the detailed customizing steps. With the following customizing steps, you can align the MM and FI document numbers going forward only. No fix is available for invoices already posted in your system, since SAP does not allow the change of document numbers.
    Step 1. Maintain FI document number range. Use transaction OMR4 and go to Number range for document types in FI. Select the company code for which you want to create the new number range interval and click on the change interval button. Insert a new document number range by clicking on the insert interval button on top of the screen. In this example, I created number range interval 52 with the document numbers 5200000000 u2013 5299999999. Don't forget to set the external number range check box (Ext).
    Step 2. Assign FI number range to FI document types. The second step is to assign the number range created in step 1 to the FI document type for invoices. Again use transaction OMR4 and go to Document type. Double-click on the document type, which you are using for LIV invoices. In my example, I used the SAP standard document type RE. In the number range field, assign the new number range interval 52.
    Thanks!!!
    Murlidhar Khatri

  • How to retrieve material document no. based on production confirmation no.

    Hi Friends,
    I am retreiving the production confirmation number(PRTNR) thru bapi BAPI_REPMANCONF_CREATE_MTS. Based on that confirmation number I need to retrieve material document number (MBLNR)
    Because multiple users can post finished goods from different locations at same time, I have to complusory retrieve the material document number based on confirmation number only. Tables MKPF and MSEG doesn't have confirmation number fields in them.
    I would appreciate if anyone could suggest me good ideas.
    Thanks in Advance.

    Hi Melih,
    Thank you for your valuable response.
    My BLPP table gets updated with material document as well as confirmation number.
    When I test my FM directly, I get a confirmation number in my export. I don't get a material document number in my export parameter. But, BLPP gets updated with material document number as well as confirmation number.
    But, if I debugg the FM with the same data I get the material document number as well as conf. no. populated in my export parameters.
    This is what I have done:
    Export parameters
    MAT_DOC type BELNR_D
    CONF type PRTNR
    DATA: GS_BLPP               LIKE BLPP,
                          GV_MAT_DOC      TYPE BELNR_D.
    CLEAR: GV_MAT_DOC, GS_BLPP.
        SELECT SINGLE *  INTO GS_BLPP
                         FROM BLPP
                        WHERE PRTNR = CONF
                          AND PRTPS = '0001'.
        GV_MAT_DOC = L_BLPP-BELNR.
        MAT_DOC              = GV_MAT_DOC.
    Please let me know if I have done something wrong.
    Thanks.

  • How to find the invoice number from accounting document number?

    Hi
    I am using the bapi BAPI_AP_ACC_GETSTATEMENT and trying to get the invoice numbers of all the payments.
    but i am unable to find the link between the accounting document number from the bapi and the vendor invoice number.
    i have tried the tables BSE_CLR, BSEG and BKPF. the field AWKEY in BKPF has the combination of BELNR & BUKRS & GJAHR when the document type is anything other than RE.
    How can i get the invoice numbers from the accounting doc. numbers?
    Regards
    Sujai

    I am unable to find the link between BKPF-BELNR and RBKP-BELNR from the bapi return values.
    XBLNR is blank when i check the table.
    the output of the bapi is something like this                                                                               
    COMP VENDOR   CLEAR_DATE CLR_DOC_NO ALLOC_NMBR   FISC   DOC_NO     ITE
                                                                                    1000    1100 ........ .........................................  20020123           2002 1900000202   002
    1000    1100 ........ .........................................20020123           2002 1900000203   002
    1000    1100........ .........................................20020123           2002 1900000204   002
    1000    1100........ .........................................20020123           2002 1900000205   002
    now i try passing the doc_no (1900000XXX) and the fiscal year (2002) and company code to BKPF
    the XBLNR field is blank. This document number sequence doesn't seem to be the accounting document number of the invoice coz that starts with 51XXXXXXXXX.
    If i try passing the number with sequence 51XXX... to BKPF i get the invoice number there in the AWKEY field.
    I am not sure what this sequence (19___) represents.
    Sujai
    Edited by: Sujai S on Nov 5, 2008 7:22 PM
    Edited by: Sujai S on Nov 5, 2008 7:22 PM

  • Link between inv. number and accounting document number

    Hi Frnds,
    When i receive  a partial receipt (of an invoice) from a customer, i am getting the link between invoice number and accounting document number from a table (BSEG), but when i am receiving the final settlement amount from the customer, i m not getting the link between the inv. no. and accounting document number. Can anyone tell me how can i get the same?

    Hello,
    Try to prepare query based on tables BSIK, BSAK and BSEG. (Transaction code SQVI)
    Regards,
    Ravi

  • Link between Invoice verifycation number and Accounting Document number

    Dear All
                   I want the Link between invoice verifycation number (MIRO) an accounting document number the same MIRO. in which table the both two numbers avilable.
    How can identify. can any one tell me the table name for this
    Regards
    Kumar.

    Hi..
    What is the link or join condition for these two tables
    BKPF and RBKP. and RSEG and BSEG.
    In this i want to Accounting document number and invoice verifycation number in a single report.
    Regards
    Kumar

  • How to get Accounting document number from billing document number

    Hi,
    How to get Accounting document number from billing document number i.e. from VBAK- VBELN.
    Cheta Pant

    Hi,
    VBAK is the Sale Order header table, Billing document table is VBRK.
    Sales tables (VBAK,VBAP,VBRP,VBRK) do not store accounting document numbers.
    You do other way around. Just go to SE16 and enter the Billing document number in field Billing document VBELN in BSEG or BSID or BSAD table and execute, you will find the accounting document number.
    If you just want collect this information once then you can use table BSEG, but if you think to develope a report then use table BSID and BSAD.
    Regards,
    Chintan Joshi

  • For BSID- Accounting Document Number corresponding PO Number is required

    Hi Gurus,
                 I have got a requirement to develop a report similiar to 'FBL5N' . I am getting the details of open and cleared items of a customer from BSID and BSAD tables respectively. My requirement is also to fetch the corresponding PO number of the LINE items displayed in the report.
                Can any one suggest how can I fetch PO number with Accounting document number(BSID-BELNR)  or (BSAD-BELNR).
               Your efforts in this matter are deeply appreciated and <<removed_by_moderator>>.
    Thanking You,
    ZIa.
    Edited by: Vijay Babu Dudla on Jan 28, 2009 11:07 PM

    If you have fields BSID-VBEL2 and BSID-VPOS2 are populated with the sales order, than access VBKD with the Sales Order to get the Customer PO (VBKD-BSTKD)
    Or
    First, You need to get the Billing document. Access BKPF with the BSID-BELNR to get the AWKEY where AWTYP = 'VBRK'
    Now, you can go to SD document flow with the billing document to find out the Sales Document. Access VBKD with the Sales document to get the Customer PO
    Regards,
    Naimesh Patel

  • Link between Material Document number & Accounting document number

    Hi All,
    For material document there is a corresponding accounting document number generated.However this is not the rule in all cases.
    Where is the link between the two(Material Document & Accounting Document) ?
    In other words i want to list those material documents only, for which accounting documents are generated.
    Regards
    Piyush Kothari

    STEP 1
    SAP query way to extract your information.
    Create an infoset SQ02 with a single table MKPF. (include key fields in the field group)
    Step 2
    From Extras
    Create an additional field called zawkey (like bkpf-belnr) which will concatenate the MM document number MKPF-MBLNR and MKPF_MJAHR. The sequencing shall be number 1.
    You may use this code below and paste also (this needs authorization as well)
    data: zzawkey like bkpf-awkey.
    clear: zawkey, zzawkey.
    concatenate mkpf-mblnr mkpf-mjahr into zzawkey.
    zawkey = zzawkey.
    Add another field called ACCDOCNO (accounting documnet number) with sequencing number 2 with following code.
    data: zaccdocno like bkpf-belnr..
    clear: zaccdocno, accdocno.
    select belnr from bkpf into zaccdocno where
      bukrs = ccode and
      GJAHR = MKPF-MJAHR and
      awkey = zawkey.
    endselect.
    accdocno = zaccdocno.
    Step 3
    Include the additional fields  into the field group.
    Step 4
    Click on the selection tab and create a parameter called ccode with a description Company Code and  against
    LIKE    BKPF-BUKRS 
    Extras  OBLIGATORY 
    Step 5
    Click on the selection tab and create a seelction criteria pdate with a description Posting Date for the field MKPF-BUDAT
    Extras  OBLIGATORY 
    Step 6
    Save, Generate and assign the infoset to a user group.
    Step 6
    Create a SQ01 query under the usergroup with all the fields in the infoset. and Execute. Enter a company code and one date of a working day where you expect material transactions.
    The result will be all the material documents and their corresponding accounting documents, if available. If you want to see only those material document that do not have corrsponding accounting documnet, then while you are in the selection screen say accounting document number is not equal to blank.

  • How to get an accounting document number from an Invoice number

    Dear All,
    I have a requirement where I need to know which accounting document is created against a  particular invoice. As we know that in the document flow of invoice we can see the Accounting document also. But to develop the report I need to pick the accounting document by the invoice document. Please suggest me a table where this value is getting stored. I already tried VBFA and VBKD but nowhere I am getting such information from which I can pick a accounting document number for a particular invoice.
    Please give me your suggestions.
    Regards,
    Sanju

    Dear,
    For Billing document create no. range by Tcode-VN01 and assign it to in Tcode-VOFA
    For Accounting document create no. range by Tcode-FBN1 and activate the External Field and assing it to in Tcode- OBA7
    but Assign the same no. range to both Document types for exp 1000000 to 1999999.
    Regards
    AJIT K SINGH
    HAPPY TO HELP U

  • Excise No. using  Accounting Document Number and the P.O. number

    Hi All ! In my GL report, I'm displaying the Accounting Document Number and the P.O. number.
    Now, the requirement is to display the excise no..
    Tried different tables in SE11 using J_1EXC for excise detials, but to no avail.
    And last which vendor to pick, Because vendors in P.O and BSEG differs.
    If I use the BSEG-BELNR I get a different vendor & If I use the P.O. no. in EKKO then also I get a different vendor.
    Please suggest.

    Hi,
    Actually the vendor in the accounting document and PO should match. If not look in table EKBE, It will have the accounting document or at least the invoice receipt against which accounting document would have been created. Check if the vendor number matches with the invoice receipt.
    Regarding the excise number I'm not sure what you mean, If you mean excise invoice number, you can look at the J_1IEXCDTL
    J_1IEXCHDR tables. You could check with FC on what basis the document is getting created to make out the relation ship. If it is vendor excise no etc. you can hit F1 help to find out the table etc.
    Hope it helps.
    Sujay

Maybe you are looking for

  • How to use the build-in Java parser

    Hi All, I want do use the build-in Java parser. Is this possible? For example I have the following code: package ch.fhnw; import javax.tools.*; public class JavacExample {      * @param args     public static void main(String[] args) {      JavaCompi

  • My macbook is suddenly getting MUCH hotter.

    I purchased my RMBP July 14, and in the past week it has been getting MUCH hotter. When I first got it, the enclosure was cool to the touch even while watching 1080p youtube videos or ripped blu-rays. The only time it actually was extremely hot was w

  • GridBagLayout problems

    Hi everyone... i m having some problems with GridBagLayout() manager... Basically my code concerning GBL manager is: JPanel mainPanel=new JPanel(); GridBagLayout grid=new GridBagLayout(); mainPanel.setLayout(grid); Now i want to add 2 more panels to

  • Procedure is exeuted but in package it is failed

    HI frnz, i was created one procedure,but it is exuted fine and once i call the same procedure in execute sql task in ssis it shoul fail the task,and it will show the follwing error msg [Execute SQL Task] Error: Executing the query "EXEC [dbo].RegionS

  • Where can I find example LabVIEW VIs for the NI-USRP?

    There are several sources of example LabVIEW VIs for the NI USRP: We have established a NI Community "NI USRP Example LabVIEW VIs" where you can find example VIs from us (NI) and the community. The NI-USRP driver installs a variety of example VIs to