Enter Document Number in "BAPI_SALESORDER_CHANGE".

Hi All,
I am facing some problem with BAPI_SALESORDER_CHANGE.
I am trying to update the Sales Order header with the BAPI BAPI_SALESORDER_CHANGE.
However, I am facing the below error though I pass the Sales document number correctly with all leading zeroes.
"Enter Document Number".
When I debugged, I found that it hits a function module SD_SALESDOCUMENT_CHANGE which inturn calls the FM
SD_SALES_DOCUMENT_READ. Inside the FM SD_SALES_DOCUMENT_READ, I could see that the value is being assigned to
VBAK-VBELN. But, there is a subroutine which gets executed after that. As soon as it enters in to the subroutine, the value of VBAK-VBELN gets vanished.
VBAK-VBELN = DOCUMENT_NUMBER.
  PERFORM BELEG_LESEN(SAPMV45A).    "Once it enters inside this subroutine, the value of VBAK-VBELN gets cleared.
  PERFORM KONV_SELECT(SAPFV45P).
Any pointers on this would be highly appreciated. I have gone through various posts of SDN. But, none of them could help me.
Note:  When I execute the above FM from SE37, it works fine and the VBAK-VBELN value doesnt get vanish even after entering the above mentioned Subroutine.
Thanks,
Babu KIilari

Hi Babu,
Just replying to update this thread in case it can help others in the future, as I had a similar issue (at our same client ).  To paraphrase/quote your reply to my mail on similar error " the solution for the same is not the implicit enhancement that we have created there. It was just a temporary solution and as you have highlighted that transport never moved into any other system across the landscape. The actual issue that caused the error was due to a conflict between the subroutine pool and the program SAPMV45A.  Someone had defined a subroutines in SAPMV45A and they were calling the same in the USEREXIT_SAVE_DOCUMENT_PREPARE which I think belongs to the same program. Don’t recall the actual glitch at the variable level, however VBAK-VBELN was being reset by the subroutine pool. Instead of calling the external subroutines from the parent program SAPMV45A, I had created one Subroutine pool and consolidated all the 6 subroutines into it and then I am calling these 6 subroutines from the FM." 
So your issue was within a sales order change being saved, in the save user-exit, someone was again referring to SAPMV45A which was blanking out VBAK-VBELN as you showed above.
In my issue, same issue was happening that VBAK-VBELN was disappearing.  The scenario for us was as follows.  We have an interface from a TMS system which can update STOs or Sales Orders (1 doc per IDOC).  We saw the Sales Order IDOCs were sometimes getting a 51 status if the BAPI call failed with V1045 Enter the Document Number.  By the hints above, we suspected somehow SAPMV45A was being called.  By analysis, we realized that the issue happened when an IDOC to do a BAPI_PO_CHANGE preceded the BAPI call for the sales order.  And then debugging showed us that someone had put a user-exit in a gATP exit which was performing a subroutine in SAPMV45A for  an STO (which the logic was only pertinent to SOs).  By going into the SAPMV45A routine, the (SAPMV45A)VBAK-VBELN work area was created albeit empty.  Then, when the Sales Order BAPI gets called (his IDOC was next in line of the IDOC processing program) that blank work area overlaid VBAK-VBELN when code entered into BELEG_LESEN.  Our solution will be to prevent the gATP exit from calling a perform into SAPMV45A when its working with STOs.

Similar Messages

  • "Enter the document number" in BAPI_SALESORDER_CHANGE.

    Hi,
    I've got the following error:
    Call of BAPI_SALESORDER_CHANGE gives us an error V1 045 "Enter the document number". We are sure the call is proper (document number is send). The errors occurs in function module SD_SALES_DOCUMENT_READ in lines 60 and 61:
    60    VBAK-VBELN = DOCUMENT_NUMBER.
    61   PERFORM BELEG_LESEN(SAPMV45A).
    In line 60 field VBAK-VBELN is set  but in form BELEG_LESEN(SAPMV45) is initial. The value of field is checked in MV45AF0B_BELEG_LESEN line 53.
    53    if vbak-vbeln is initial.
    54    message e045.
    55   endif.
    The error occurs only when we have mass changing of sales order and posting deliveries in reference to sales order. Single operation doesn't make any problem.
    Our system:
       SAP_APPL 470 with  SAPKH47026
       SAP_BASIS 620 with SAPKB62059
    Anyone met it before? I'm quite confused.
    Best regards:
    Lukasz Tylutki

    Hi Lukasz,
    If I understand correctly the problem occurs with multiple calls of the BAPI within the same program call. As a general rule of thumb, this could be due to parts of the program not properly initialized. Don't try to correct the BAPI - it's hopeless.
    I suggest you make use of the suggestion in note 760068 to start a new task.
    This can be achieved as follows:
    Call function 'XXXXXX' starting new task 'BLABLA'
    performing yyyyy on end of task
    ...rest of function interface (only export and tables)...
    wait until semaphore = 'X'.
    form yyyyy
    receive results from function 'XXXXXX'
    importing...
    tables...
    exceptions....
    semaphore = 'X'.
    endform.
    This way all data are initalized in a different LUW, thus not influencing the next function executions. An alternative would be to submit programs for each function call, passing the interface through export-import parameters, but it doesn't look as nice.
    Best regards,
    Stratis

  • "Enter document number error" in BAPI_SALESORDER_CHANGE

    Hi,
    I am trying to change the sales order thorugh BAPI_SALEORDER_CHANGE as follows,
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = <fs_order_alv_aux>-vbeln
    order_header_in = e_bapisdh1
    order_header_inx = e_bapisdh1x
    simulation = p_consol
    TABLES
    return = t_bapi_return
    extensionin = t_bapiparex.
    I am changing only KVGR5 through this BAPI, and I am passing sales documetn number through <fs_order_alv_aux>-vbeln.
    When I check inside BAPI I am able to see SALESDOCUMENT : 0021033932, while debugging further I came to know about following.
    Inside the Function SD_SALES_DOCUMENT_READ. following 2 lines gets executed.
    VBAK-VBELN = DOCUMENT_NUMBER.
    PERFORM BELEG_LESEN(SAPMV45A).
    Here, VBAK-VBELN has a value, but as soon as it goes inside PERFORM BELEG_LESEN(SAPMV45A). VBAK-VBELN value gets cleared and following error has been set inside the perform.
    if vbak-vbeln is initial.
    message e045.
    endif.
    If I manually fill VBAK-VBELN inside this perform then everything works fine.
    I even tried same thing through SE37 by executing this BAPI but in this case it doesnot clear the VBAK-VBELN inside this PERFROM.
    Can anyone help?
    Thank you.

    Hi Pramod,
    it does not look like a conversion error.
    You may try again with SE37, enter debugger at start and set a watchpoint at VBAK-VBELN in function SD_SALES_DOCUMENT_READ, i.e. program SAPLV45A.
    When VBAK-VBELN is set, it will stop at the watchpoint. Check the call stack at this point to find out how the value gets here. Then start your misbehaving program and (I hope so) find out ehere it is going wrong.
    The SD process is heavily penetrated with enhancements for a couple of industry solutions. I do not know your environment so it is hard to say how the document number is passed to function group V45A.
    Regards,
    Clemens

  • F-32, clear customer - document number

    Hi,
    My client is using F-32 to clear customer items, it selects document no. as selction crieteria. it enters document number wrongly and press enters, system stores document no. user get back by pressing F3 once and select choose open items whr he again follow the same process as mentioned above and execute process open items. line items appears with current as well as last document selectin. now user says i want only current selectiion without getting out of Tcode, he doesnt want the system store the doc no.
    on this i replied it is std functionality/feature given by sap whr if user misses or want to use diff diff selction crieteria this feature is useful. But client is not ready to accept it as a feature. he is sayin it is system bug.
    Please advise.
    Thanks
    Homi.

    Hi,
    Better You can post a query to Service.SAP.com with your SID (S000xxxxxxx) . So that they will guide your client properly. If it is a bug they will send a patch file. and they will issue SNote for this.
    Thanks
    Chandra

  • No document number in Approval Workflow

    Hi!
    I have crated a work flow where I check if the status is FA for docType 900. If this is true then I send a mail to the person responsible for the approval. Everything works exept that I don't get the document number for the document that I change. I use the &document.documentnumber& command in the mail but the system don't get the docNr.
    //Krip

    Hi,
    by using standard document distribution, whenver you send an mail along with object (document), reciepient recieves the mail with object(document) which is indicated by its description.
    once you click on the object(attached document) in mail, you wil be redirected to SAP screen.
    In order to identify the document in terms of document number then you may manually enter document number in description field.
    Thank You,
    Manoj
    if useful pls consider points..!

  • Enter the document number error in BAPI_SALESORDER_CHANGE

    Hi,
    please help me on the below error:
    Call of BAPI_SALESORDER_CHANGE gives us an error V1 045 "Enter the document number". We are sure the call is proper (document number is send). The errors occurs in function module SD_SALES_DOCUMENT_READ in lines 60 and 61:
    60 VBAK-VBELN = DOCUMENT_NUMBER.
    61 PERFORM BELEG_LESEN(SAPMV45A).
    In line 60 field VBAK-VBELN is set but in form BELEG_LESEN(SAPMV45) is initial. The value of field is checked in MV45AF0B_BELEG_LESEN line 53.
    53 if vbak-vbeln is initial.
    54 message e045.
    55 endif.
    kindly help me on this error,
    Thanks in advance friends,
    Naidu

    LOOP AT IT_ZVCONTRACT_SUSP_SAVE INTO WA_ZVCONTRACT_SUSP_SAVE.
    *Assign values to required fields for for updation
        SALESDOCUMENT = WA_ZVCONTRACT_SUSP_SAVE-VBELN.
        ORDER_HEADER_IN-SALES_ORG = WA_ZVCONTRACT_SUSP_SAVE-VKORG.
        ORDER_HEADER_IN-PURCH_DATE = '00000000'.
        ORDER_HEADER_INX-SALES_ORG = 'X'.
        ORDER_HEADER_INX-PURCH_DATE = 'X'.
        ORDER_HEADER_INX-UPDATEFLAG = 'U'.
        WA_ORDER_ITEM_IN-ITM_NUMBER = WA_ZVCONTRACT_SUSP_SAVE-POSNR.
        IF WA_ZVCONTRACT_SUSP_SAVE-CFLAG EQ 'P'.      "flag for permanent suspension
          WA_ORDER_ITEM_IN-REASON_REJ = WA_ZVCONTRACT_SUSP_SAVE-ABGRU.
        ELSEIF WA_ZVCONTRACT_SUSP_SAVE-CFLAG EQ 'T'.  "flag for temporary suspension
          WA_ORDER_ITEM_IN-REASON_REJ = ''.
        ENDIF.
        APPEND WA_ORDER_ITEM_IN TO ORDER_ITEM_IN.
        WA_ORDER_ITEM_INX-ITM_NUMBER = WA_ZVCONTRACT_SUSP_SAVE-POSNR.
        WA_ORDER_ITEM_INX-UPDATEFLAG = 'U'.
        WA_ORDER_ITEM_INX-REASON_REJ = 'X'.
        APPEND WA_ORDER_ITEM_INX TO ORDER_ITEM_INX.
    *update contract for reason code
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            SALESDOCUMENT    = SALESDOCUMENT
            ORDER_HEADER_IN  = ORDER_HEADER_IN
            ORDER_HEADER_INX = ORDER_HEADER_INX
          TABLES
            RETURN           = RETURN
            ORDER_ITEM_IN    = ORDER_ITEM_IN
            ORDER_ITEM_INX   = ORDER_ITEM_INX.
    ENDLOOP.
    We are using it the above given way and it is working fine.
    Regards,
    Abhijit G. Borkar

  • FB01 and entering billing document number

    Hi,
    We're trying to create an LSMW for FB01 - but would want to but in a billing document transfer.
    Is this possible to be done in LSMW or must it be done in BAPI ?

    HI,
    At the moment doing we do not have a choice on running on LSMW and BAPI - we are not familiar running it. The key question can FB01 in LSMW accept posting on billing document number (VBELN) field ? I recall that this field is not editable once the document is created. So if we post via FB01 can we enter this field ?

  • IDOC error status 'Enter the Document Number'

    Hi PI or SD masters,
    I have a status 51 in my IDOC. The reason was 'Enter the Document Number'. Has anyone encountered this before?

    Sold To Party Account number was changed

  • Cannot change the print margins when printing out my spreadsheet.  Tried clicking on format and then Document but when I enter a number I always get " invalid number".

         I cannot change the margins when printing out my spreadsheet.  I clicked on the format then on document and got a entry box.  But everytime I try entering a number to change the left margin ( tried .5 ) I get an " invalid number " response.  I can print out the spreadsheet but always get a message telling me the margins may be too small and data may be clipped.  Data doesn't get clipped but left part of the spreadsheet is right at the left side of the paper.  Want to change the margin so I don't get that message.

    Naming the spreadsheet app would do wonders for getting an answer.

  • Enter manually reference document number in Invoice Header

    Hi gurus,
    In order to keep a proper numerical sequence of invoices issued in the Company ( between those that are printed in excel and in SAP), we need to set manually a number in the SAP invoice document that we will use to print the form, and that is independent from the one assigned internally.
    What would be the best field to set this number?
    Reference number (in Header - Accounting data) would be a good choice, but seems like it is managed through copy control and can only be assigned automatically to: Customer PO #, Sales order #, Delivery #, External delivery # and current invoice #. Would it be possible to assigned it manually?
    thanks for your always valuable ideas,
    VL

    Thank you Ken for your answer,
    The thing is that we need to transfer this field to accounting, this is why t¡he best choice would be the reference document number.
    External range number is not a feasible option because it is required an internal number assignment but the one to be painted in the form and transferred to accounting has to be entered manually in the invoice header.
    It is not so easy to enter reference document number manually as it has a copy control assignment as commented in my first note.
    Any help would be very appreciated.
    Thanks,
    VL

  • 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

  • P.O number for a billing document number

    Hi Experts,
    From  which table we can find a PO number for corresponding billing document number(VF03)?

    hi RAVI,
    Go to T.code SE16
      enter table name VBRK-->enter
       billing doc type,billing doc no,s.org,d.channel
      execute
    waiting for reward points
    mcm

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

  • 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

  • Cancelled Accounting Document Number(belnr)

    Hello Experts,
    I m developing a report in which i have to capture accounting document number which has been generated against the cancelled A/c document number.
    Is any field populated when the a/c doc num has been canceeled so that we can make out that this particular a/c doc num is for this particular cancelled a/c doc number..
    Thanks in advance.
    Ravi

    Hello all,
    In my report i want to fetch accounting document number as per date(posting date) entered by user.
    If suppose posting of particular doc(200000001) has been done on date 22.10.2008 and it is reversed(200000002) on 29.10.2008 and if user enter date in selection criteria 22.10.2008 200000001 document number should occur and if user enter 29.10.2008 200000002 document number should occur.
    Ravi

Maybe you are looking for

  • Part payment against Downpayment Request

    Dear Friends, Even a part payment received against Downpayment Request (Vendor) clears the Request with the entire amount. In other words, it does not keep the Request open though no full payment is received against this Request. Pl. suggest suitable

  • Failing by duplicate database from active database

    Hallo, i'm working with 11g on one server and want to duplicate a database in active mode. what i do: i create a new password-file using orapwd - orapwNEW i create a new entry for ORANEW in tnsnames.ora and listener.ora then i execute rman TARGET sys

  • Problem in reading a serial port

    Hi, I am working on a program about serial communication, my problem is when reading the response of the other serial port, my program always throws the "PortInUseException" and prints the error "Unknown Application". Yes, the port was use by that ap

  • Problem with Time Capsule WIFI Network

    Here's what happened to me suddenly at 15. I have 1 TB Time Capsule connected to DLINK adsl modem. Time Capsule is connected by Ethernet to a PC, by wireless an iMac, MacBook, PC Notebook, 2iPhones, 1 iPad. Password-protected network. Start the iPhon

  • Universe on BEx

    An optional prompt was created on BEx which is passed to report through universe. Can I change it to 'Mandatory' in universe ? Here is the code: <OPTIONAL><FILTER KEY="[!V000001]"><CONDITION OPERATORCONDITION="Between"><CONSTANT TECH_NAME="@Prompt('S