Sales Document from billing document

Dear all,
How can i get the corresponding sales document number form a billing document number?
Plz let me know.
Rahul.

Please look at the below code.. It will give you the sales document no corresponding to the billing document no:
DATA: wa_comwa TYPE vbco6,
      i_vbfa TYPE STANDARD TABLE OF vbfa INITIAL SIZE 0,
      wa_vbfa TYPE vbfa,
      l_vbeln TYPE vbeln.
*billing document no
l_vbeln = '90000049'.
*Padding leading zeros
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input  = l_vbeln
  IMPORTING
    output = wa_comwa-vbeln.
*Get the order info
CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
  EXPORTING
    belegtyp      = 'M'                      "Billing docu
    comwa         = wa_comwa
  TABLES
    vbfa_tab      = i_vbfa
  EXCEPTIONS
    no_vbfa       = 1
    no_vbuk_found = 2
    OTHERS        = 3.
IF sy-subrc = 0.
  READ TABLE i_vbfa INTO wa_vbfa
    WITH KEY vbtyp_n = 'J'                   "Shipment
    vbtyp_v = 'C'.                           "Order
  IF sy-subrc = 0.
  Display order
    WRITE wa_vbfa-vbelv.
  ENDIF.
ENDIF.
Please reward if useful
-Tushar

Similar Messages

  • Get Sales order from Billing document number

    Given Billing document number from VBRK-VBELN, how to get the Sales order number VBAK-VBELN?

    Please check table VBFA.
    Below code might give you some idea:
    PARAMETERS: P_VBELN TYPE VBELN OBLIGATORY.
    DATA: COMWA TYPE VBCO6.
    DATA: IT_VBFA TYPE TABLE OF VBFA,
          WA_VBFA TYPE VBFA.
    COMWA-VBELN = P_VBELN.
    CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
      EXPORTING
       BELEGTYP            = 'M'
       COMWA               = COMWA
      TABLES
        VBFA_TAB            = IT_VBFA
    EXCEPTIONS
       NO_VBFA             = 1
       NO_VBUK_FOUND       = 2
       OTHERS              = 3.
    LOOP AT IT_VBFA INTO WA_VBFA WHERE VBTYP_N = 'C'.
       WRITE:/ WA_VBFA-VBELN.
    ENDLOOP.
    Kind Regards
    Eswar

  • Creation of sales document (DMR, CMR) from the archived billing document

    Hi all
    I read somewhere that one of the functionality in EHP3 is we can create sales document like debit memo request and credit memo request from the archived billing document. I am working on EHP3 system only but i am not able to create the sales document. the system throws an error that billing document doesnt exist
    If any one of you have worked on such functionality kindly suggest me why its not happening here also let me know Is ther any customization required for the execution of this functionality in spro.

    hi,
    the help says:
    You can use this business function to further optimize your electronic Sales and Billing Processes.
    Electronic data archiving regulations result in a high volume of data for sales documents and require invoices to be archived at an early stage. You can integrate archived billing documents in your business processes more easily. Since you still have electronic access to archived invoices during the sales process, you can manage archiving without delay and execute further sales processes electronically.
    You can more efficiently use the rebate agreements from SAP ERP for your marketing activities. In particular, customers who use SAP CRM (Trade Promotion Management) with a large volume of data for campaigns, target groups, and product segments can define a custom-made logic for their rebate determination and thus avoid potential database problems.
    Integration
    To implement the logic for rebate processing in SAP ERP, you use the Enhancements for Rebate Processing Business Add-In (BAdI). For more information, see the Implementation Guide (IMG) under  Sales and Distribution  Billing  Rebate Processing  Business Add-Ins (BAdIs)  Enhancements for Rebate Processing .
    Prerequisites
    You have activated the Logistics: S&D Simplification (SD_01) business function.
    Features
    You can integrate archived billing documents in your business processes as follows:
    Create sales documents with reference to archived billing documents, such as credit memo and debit memo requests.
    Display archived billing documents.
    When you do either of these steps, the system first looks for the invoice in the database and then in the archive.
    For the sales employee, the processing steps are identical, regardless of where the sales document is stored. As soon as the sales employee processes an archived billing document, they see the relevant information in the message line as well as in the title of the function.
    For rebate processing, you can store your company's check logic in the interface of the Business Add-In (BAdI) Enhancements for Rebate Processing.
    So check if you have activated the business function.
    I hope this helps.
    Balazs

  • Swap items from Sales Document to Billing Document

    Hello, I am facing with the following issue.
    We had customizing a Billing plan, that means that the information to make the billing document comes from the sales order. The sales document have 2 materials for sale, the first one must be delivered (item number 10) and the second one it is a service material (item number 20), and the customer wants that sequence. Then when I make the billing document, the system swap the sequence of the materials, put in first the service material and then the deliver material.
    Then I went to check in the in copy requirements the check mark "Copy Item number", the consecuence if I check or if I uncheck, its the system put all the time as second the delivered material, only changing the item number.
    There is a way to keep the same order?
    Thanks in advance for the comments.
    Regards,
    JCR

    I have found the solution of the issue; the problem was in the item category of the service material. The delivery material, has the item cathegory with the customizing for Billing plan, thats mean the letter " I " in the box of Billing reference; but the service material had the customizing for "relevant for order related billing", thats means the letter " B " in the box of Billing reference.
    The solution  was change the letter "B" for the letter "I"; and then choose the same Billing Plan Type for both items categorys. And also I have put the check mark in the copy requirements.
    Thanks all for your comments,
    Regards,
    JCR

  • User exit to copy the data from sales order to billing document

    hi everyone,
    Is there an user exit to copy the data from sales order to billing document?
    Regards
    Prabudh

    hi
    copy control would be the better option to choose.. but still u can a give a search in list below and opt for the right one..Refer to the link below..
    http://www.planetsap.com/Userexit_List.htm
    User exits for Sales order
    1•USEREXIT_DELETE_DOCUMENT
    2•USEREXIT_FIELD_MODIFICATION
    3.•USEREXIT_MOVE_FIELD_TO_VBAK
    4.•USEREXIT_NUMBER_RANGE
    5.•USEREXIT_SAVE_DOCUMENT
    User exits for billing
    1.•USEREXIT_ACCOUNT_PREP_KOMKCV (Module pool SAPLV60A, program RV60AFZZ)
    2.•USEREXIT_ACCOUNT_PREP_KOMPCV
    3•USEREXIT_NUMBER_RANGE_INV_DATE (Module pool SAPLV60A, program RV60AFZC)
    4•USEREXIT_PRINT_ITEM (Module pool SAPLV61A, program RV61AFZB
    5.USEREXIT_PRINT_HEAD (Modulpool SAPLV61A, Programm RV61AFZB)
    Reward if Useful
    Thanx & Regards..
    Naren..

  • Copy billing plan lines from one sales document to another

    HI,
    we want to copy the open billing plan lines from one sales document to another, which routine should we use in the copy control in configuration?
    we tried to use,401 and 402 but with no success..
    it's should'nt be a standard process with out any development?
    Best Regards
    Yehudit

    Hi,
    Check where you entering this routine
    If your billing plan at header then enter it at header in copy control, if billing plan is item level then maintain at Item level in copy control
    Kapil

  • Standard COGS cannot be Transferred from Sales Order to Billing Document

    I did a test in current client with the following steps:
    Create Sales Order for Configurable Material -> Execute Sales Order Costing Run, marked and Saved the result via CK51 -> Create Prodcution Order for such Sales Order -> Confirm Prod Order -> Conduct GR per the Prod Order -> Conduct Goods Delivery for the Sales Order-> Create Billing.
    (There is not any costing value during the whole process)
    There are many Value Fields in the CO-PA document regarding to this billing, the value of standard COGS items(including Material Cost, Period Machine, Variable Labor etc) are also included and their value are expected to be transferred from Sales Order. However,  in my testing, those COGS value failed to be transferred to Billing document. I am not sure whether there is any config related. (KEPC hs already been done in such case). Would any expert can help on that?

    en, It is solved now. Untick "Transfer aux. CC Split" in KE40, then the value can transported to billing.
    Edited by: Ying Zhu on Nov 18, 2008 1:10 PM

  • Copying Text From Sales order to Billing Document

    Hi all,
    I have searched all posts for my issue but found nothing so that i am posting this issue.
    I want to copy the Some text form sales order to billing document is there any cnfig to do this
    order is there any exit for billing in which i can write code to copy text from sales order to billing document.
    please provide me a solution.
    Thanks in adavnce.
    Vinod.

    Hi,
    Use the same t-code VOTXN to do access sequence assignment.
    When you choose text object Billing Doc (header/item), there is 3 folders in dialog structure:
    - Text procedure
    - Access sequence
    - text procedure assignment
    In the text procedure folder, select related text procedure, then assign the created access sequence to respective text id.
    Hope this help.
    Cheers,

  • Problem with copy control from sales document to billing document

    Hi,
    I have a copy control from a sales document to a billing document,
    which is copying everything from the sales document, except the
    conditoin values. Any ideas on why will a copy routine won't copy the
    condition values from a source document? I don't even have a document
    pricing procedure assigned to my billing document. Any setting, that
    we can do to for the conditions to get copied from the sales document
    to the billing document...just as they are in the sales document?
    Thanks for the help in advance.
    Regards,
    Vijay

    In IMG,
    Implementation Guide for R/3 Customizing (IMG)
    -->Sales and Distribution
       -->Billing
          -->Billing Documents
             -->Maintain Copying Control For Billing Documents
                -->Copying control: Sales document to billing document
    What setting do you have for your source sales document type to target billing document type? Select the row that shows the document type you are interested in and double click on item(on the left pane). Select the item category and do display. What value do you see under the 'Pricing Type' and 'Price Source'?
    May be that is where some config setting is missing.
    Srinivas

  • Cannot create billing document from sales document

    Hi,
    i am trying to create billing document from the created sales document.
    But the billing document is not generated. I was getting  the error - ' Document is blocked from billing'.
    SO, i changed the billing block and left it blank, and when  I tried to create the document again, I got another error " Create billing document" not allowed (uSER STATUS   ST01, Object VB006000071200000).
    Please help me out,

    Dear Priyam,
    Attached are the screen shots, go through them.
    I believe you need to change the status in the Sales order status(Object status).
    click on Object status
    Regards
    Shaik

  • FM to create Sales Order from reference billing document

    Hi,
    I need to create a sales order from a reference billing document. Please tell me if there is any function module/BAPI to do that.
    Thanks in advance for the help
    Regards,
    Varun

    Hi
    <b>SD_SALES_DOCUMENT_COPY</b> copy Sales Doc into new one with the required Sales Doc Type (VBAK-AUART) for further creating.
    <b>SD_SALES_DOCUMENT_SAVE</b> create Sales Doc from the copied document
    create subsequent document
    REPORT Z.
      data: w_auart like vbak-auart,  "current SalesDoc type
            w_auara like tvak-auara,  "Subsequent SalesDoc type
            w_vbak  like vbak.
      parameter p_vbeln like vbak-vbeln.
    at selection-screen on p_vbeln.
      SELECT SINGLE auart FROM vbak into w_auart
        WHERE vbeln = p_vbeln.
      if sy-subrc <> 0.
        message e398(00) with 'Sales Doc' p_vbeln 'not found'.
      endif.
    start-of-selection.
      SELECT SINGLE auara FROM tvak into w_auara
        WHERE auart = w_auart.
      if sy-subrc <> 0 or w_auara is initial.
        message e398(00) with 'Subsequent type not defined for' w_auart.
      else.
      1. copy
        CALL FUNCTION 'SD_SALES_DOCUMENT_COPY'
             EXPORTING
                  i_auarn       = w_auara
                  i_vbeln       = p_vbeln.
      2. paste
        CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
             IMPORTING
                  evbak         = w_vbak.
      3. commit
        COMMIT WORK.
      4. report
        write: / 'Sales Doc', w_vbak-vbeln, 'created.'.
      endif.
    regards
    vinod

  • Sales Document Number from billing document

    Dear all,
    How can i get the corresponding sales document number form a billing document number?
    I currently have data from VBRK and VBAK tables.
    so is it possible to get the corresponding sales order number for that billing doc no?
    Plz let me know.
    Regards
    Rahul.

    Dear Rahul
    If you want to see for a particular billing document the corresponding sale order reference, go to VF03, input the billing document and click on Document Flow
    If you want to see sale order references for multiple billing documents, go to SE16, input table VBFA, paste the billing document references in [Follow on doc] and C in [Prec doc categ] and execute.
    thanks
    G. Lakshmipathi

  • Billing Currency Differs from Sales Document

    Hi all
    I have a scenario where in the Sales document is having currency USD. At the time of creating the sales order the document currency is changed to EUR. Header condition is entered manually (FREIGHT) for which the currency is entered as EUR. Created the susequent documents delivery & billing. In billing the currency of the FREIGHT is coming in USD, other condition types are coming in EUR. Can anyone please help me in knowing why it is coming like this.
    Thanks & Regards
    Tarun

    Hi,
    Please check the currency maintained in the CONDITION RECORDS ofo FREIGHT in VK12
    May be the currency maintained was USD.
    Please check and return.
    regards,
    santosh

  • Sales documents missing from data base

    Hi
    Their is this unique problem, we have created sales order 'OR'  and saved it, system has generate some document no xxxx
    as soon as we go for billing, system message is
    SD document xxxxxx is not in the database or has been archived
    Message no. V1302
    Diagnosis
    This message is issued if no document header (VBAK) can be found
    (discrepancies in R/3) for a sales requirement single record.
    System Response
    In the initial sales order supply, the following error message appears
    'Document xxxxxx not available'  V1 302.
    Procedure
    If an error occurs in initial data supply in APO, discrepancies have
    occurred between the requirements and sales documents in R/3. This
    discrepance can be corrected in R/3 using report SDRQCR21.
    we have checked after running the report as well, we have chaged the material ans sold and ship to part as well, noting is happening, advice what can be done
    regards
    Niti Narayan

    hi,
    this is to inform you that,
    please check MRP config settigns for the same.
    please check if there is any discrepencies in MRP views of MMR.
    please check from sales order requriment is getting generated in MD04.
    and finally
    run the report to check and correct the discrepencies in SE38,SDRQCR21.
    regards,
    balajia.

  • Billing problem for cash sales document

    Hi all ,
    Greetings
    we are customizing for cash sales. Required Three configuration setting are done for sales document i.e
    1. Shipping condition Immediatly
    2. Lead Time 0
    3. Immediate delivery must be switch on
    and order and delivery is done at the same time while creating the order. But while creating the billing for that order through vf01(billing type BV),  We are getting an error "DOCUMENT DOES NOT CONTAINS ANY ITEM WITH OPEN QUANTITIES".
    For the order, Output Type is RD03
    can any one help on this?
    Regards,
    Pramod

    Hello Pramod,
    In the copy controls from order to billing VTFA - check for the item category BVN - the billing quantity should be marked sa "A".
    Also check in the VOV7 for item category BVN - the illing relevance should be "B".
    Let me know if it works.
    Thanks
    Shobhit

Maybe you are looking for

  • Multiple MIDI takes on the same track - can only find one in the editor?

    After making several passes on an instrument track w/drum sampler on it I opened the piano roll editor to edit the data only to find only one of the passes represented there. I could only find the other passes when I moved the current one out of the

  • How to setup error message in JSP if no data or page found

    I want to show users some error message after user clicks on a link and no page or data is found. How do I show users to a valid error message if there is no data exists after they click on a link?

  • Is there an SDK to read/import *.ai files?

    I would like to read/import the vector graphics from an *.ai file into my own 2D drawing package. Is there an SDK to do this? thanks. -bill

  • Problems with the bluetooth in Lenovo S650

    Hi All, I'me facing a problem in sending files with my new Lenovo S650 by bluetooth. I can't send any file with my mobile to a Laptop. I already have my mobile and Laptop connected with each other... I can send from the Laptop to the mobile but in re

  • Distribution by ref... Pls solve

    Dear Experts, I have a similar req like below. 0fiscyear      0version      customerGRP         rev 2007              v1                  G01                  100 2007              v1                  G02                  200 2007              v1