Update sales order through workflow

Hi,
   i developed one workflow for sales order.  after all aprovals the sales order is updating upto 2nd change. but 3rd change is not updating sales order.
For updating sales order i am using BAPI_SALES ORDER_CHANGE function module.
Thanks.

Hi  Abdullah Azzouni         
my scenario is when sales order is created or changed my workflow should trigger and make sales order as incomplete with  (Z field)  by using incompletion Procedure.
Also some other custom fields there for other workflows in salesorder.
In METHOD
   select single zfield1
                       zfield2
                       zfield3
                      Zfield4      <- for my workflow
                       INTO wa_ext_hdr
                      FROM vbak
                      WHERE vbeln = object-key-salesdocument.
       wa_ext_hdr-zfield ='X'.
   wa_ext_hdrx = 'XXXX'.
   MOVE 'U' TO wa_headerx-updateflag.
   MOVE: BAPE_VBAK  TO wa_extflds-structure.
   CONCATENATE object-key-salesdocument
               wa_ext_hdr INTO
               wa_extflds-valuepart1.
   APPEND wa_extflds TO i_extflds.
   MOVE: BAPE_VBAKX  TO wa_extflds-structure.
   CONCATENATE object-key-salesdocument
               wa_ext_hdrx INTO
               wa_extflds-valuepart1.
   APPEND wa_extflds TO i_extflds.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
   salesdocument     = object-key-salesdocument
   order_header_in   = wa_header
   order_header_inx  = wa_headerx
   behave_when_error = 'P'
TABLES
   return            = i_return
     extensionin       = i_extflds.
READ TABLE i_return INTO wa_return WITH KEY type = 'E'.
iF sy-subrc EQ 0.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
Can you help on this.
Please suggest me where i am wrong or if you know any other way to achieve this functionality guide me.
Thanks in Advance.
Raj

Similar Messages

  • Removing of billing block in Sale Order through workflow

    Hi all,
    I want to remove  the billing block in sale order when the person approves suing user decision step  in workflow .
    ANy idea would be great ...
    Regards,
    Venki

    Hi Surjith,
    task is not for the billing process ....
    and here my big problem is that i was unable to call the custom method in worklofw ....
    So attachment is not working in workflow only it works while testing if i pas the key value .
    Here my requirment is to remove  the billing block if the person approve in decision step ...
    Deepa,
    Can u tell me how to call a custom method here i am using standard BUS2032 in my task.
    already i  have BO with custom method but i dont know how to call it when the transaction get executed ....
    Thank u for ur reples...
    Regards,
    venki

  • How to update sales orders using B1WS in SAP 8.8 PL18

    Hello all.
    We are having a problem updating sales orders using Sap Business One Web Service ( B1WS ).
    We are running SBO 8.8 PL18, MS-SQL 2008, and all is fine when using the SBO client.
    But when it comes to updating sales orders through B1WS we just cannot get it to work.
    We can add new orders easily without problems. Updating orders always gives this error:
    \[ORDR.PayDuMonth\]\[line: 0\] , 'Field cannot be updated (ODBC -1029)'
    We have checked and verified multiple times that our setup is correct.
    Also the WDSL files are verified.
    We can update orders just fine using the sboclient.
    And using B1WS we can basically do everything, besides updating.
    We have also tried this on different company db's, so we are quite sure this is not
    something related to some general setting we missed, but who knows?
    We have tried different ways to "assemble" the order before updating, but it always
    ends with the above error.
    Here is an example of one of the tests, where we load an order by docentry,
    increment the quantity of all open lines by '1', and then try to update it.
            protected void Page_Load(object sender, EventArgs e)
                // First we login
                string sessionId = "";
                LoginService.LoginService l_login = new LoginService.LoginService();
                LoginService.LoginDatabaseType l_dbtype = LoginService.LoginDatabaseType.dst_MSSQL2008;
                LoginService.LoginLanguage _lang = LoginService.LoginLanguage.ln_English;
                string _server = "SAP-8_8PL18";
                string _licserver = "SAP-8_8PL18:30000";
                string _db = "my_test_company";
                string _user = "manager";
                string _pass = "********";
                try
                    sessionId = l_login.Login(_server, _db, l_dbtype, true, _user, _pass,
                               _lang, true, _licserver);
                catch (Exception ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                if (sessionId == "")
                    Response.Clear();
                    Response.Write("No sessionId");
                    Response.End();
                // We are logged in and have a sessionId
                // Now load a valid open order by docentry
                try
                    OrdersServiceRef.OrdersService orderService = new OrdersServiceRef.OrdersService();
                    orderService.MsgHeaderValue = new OrdersServiceRef.MsgHeader();
                    orderService.MsgHeaderValue.SessionID = sessionId;
                    orderService.MsgHeaderValue.ServiceName = OrdersServiceRef.MsgHeaderServiceName.OrdersService;
                    orderService.MsgHeaderValue.ServiceNameSpecified = true;
                    OrdersServiceRef.DocumentParams docParams = new OrdersServiceRef.DocumentParams();
                    docParams.DocEntry = 31; // Docentry of a known open order
                    docParams.DocEntrySpecified = true;
                    OrdersServiceRef.Document order = orderService.GetByParams(docParams);
                    OrdersServiceRef.DocumentDocumentLine line = null;
                    for (int i = 0; i < order.DocumentLines.Length; i++)
                        line = order.DocumentLines<i>;
                        if (line.LineStatus == OrdersServiceRef.DocumentDocumentLineLineStatus.bost_Open)
                            line.Quantity += 1;
                    orderService.Update(order);
                catch (System.Web.Services.Protocols.SoapException ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                catch (Exception ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                Response.Clear();
                Response.Write("All OK");
                Response.End();
    I hope that someone has an idea as to why this happens.
    The customer often changes quantity or adds lines on their orders,
    and the only way to solve it so far has been to make a new order and
    close the old one.
    Thanks in advance
    J. Thomsen

    Hi,
    Welcome you post on the forum.
    Have you checked if you only update a specific line instead of a loop?
    Thanks,
    Gordon

  • Update Sale Order Header Text through Enhancement

    Hi Experts,
             I Have a requirement to update the sale order Header Text , when the sale order is opened in VA02 and saved.
    Here in I tried using edit_text, it updates sale order header text  directly in DB during run time even before the save action is completed.
    But I need to just fill the header text and that has to be saved during the save action only.
    I tried coding the same in the user exit (userexit_save_document) but this user exit gets triggered only when there is some changes made to the document when opened in VA02 & Saved.
    Is there any  user exist to pass sale Order Header text and save when save button is clicked irrespective of the document been changed or not.
    Thanks in advance
    Sathish

    Hi Brad Bohn,
        My actual requirement is to trigger an Idoc when the user goes to VA02 transaction and clicks save.
    IDoc gets triggered only when there is some changes to that document, that is through NAST table entry based on the output configurations in NACE transaction.
    Now that the user wants to trigger an IDoc even if there is no change (ie. to reprocess the IDoc) when he just opens a sale order in VA02 and click save.
    It is not possible to trigger an IDoc through configurations when there is no actual change in VA02 and saved.
    So it has to be forcefully sent by making some additions to the Order through coding, so I choose that Text box to fill some additional data and save .
    Kindly Let me Know any thing could be done for this scenario.
    Thanks in advance
    Sathish

  • Update sales order qty through BAPI_SALESORDER_CREATEFROMDAT2

    HI
    Can anybody help me out.  I have the requirement for creating sales order through BAPI_SALESORDER_CREATEFROMDAT2. The sales order is created but with 0 quantity.
    I am using fields RNDDLV_QTY and TARGET_QTY and REQ_QTY in schedule lines & also setting the update indicator to 'X'  in the corresponding itemx structures.
    In fact it used to work earlier and has stopped now. I am also checking if there could be any change in configuration but don't think this should be the reason.
    Can someone guide me as to which quantity fields of the BAPI are the right ones to update sales order qty?
    thanks

    Hi,
    You are using the correct fields i.e. TARGET_QTY and REQ_QTY. Just check if you are passing the same Item Number in both the tables.
    Hope it helps...
    Lokesh

  • Updating a sales order through DI API

    Hi All,
         I have an issue regarding updating a sales order.
    The problem is:
      If there r 2 items(A00001&A00002) existed in the sales order and if I am adding two more items(A00003 & 4)the sales order is updated in a fashion that first item is replaced with third item and forth item is added as last record.The items to that particular sales order after updating will be like this(A00003,A00002,A00004).My doubt is why the 3rd item is replaced with first record.I am sending the code also i have written.
    objRecordSet = SBOCOMUtil.newRecordset(company);
                          IDocuments  oOrder =SBOCOMUtil.newDocuments(company,SBOCOMConstants.BoObjectTypes_Document_oOrders);
                                  objRecordSet.doQuery("select DocEntry from ORDR where DocNum=" + 1111);
                                  DocEntryL =objRecordSet.getFields().item(new String("DocEntry")).getValueInteger().intValue();
                          str += DocEntryL;
                          System.out.println(DocEntryL);
                          if (oOrder.getByKey(new Integer(DocEntryL))) {
                                  //objRecordSet2.doQuery("delete  from rdr1 where DocEntry="+DocEntryL);
                                  str += "2";
                                  System.out.println(str);
                                  //oOrder.remove();
                                  oOrder.setDiscountPercent(new Double(5));
                                  oOrder.setComments("success");
                                  System.out.println(str);
                                  IDocument_Lines oOrderLines = oOrder.getLines();
                                  str += "3";
                                  String[] item={"A00005","A00006"};
                                  for (int counter = 0; counter < item.length; counter++) {
                                       //  oOrderLines.setCurrentLine(new Integer(counter));
                                         if (counter > 0)
                                                 oOrder.getLines().add();
                                         str += "4";
                                  oOrderLines.setItemCode(item[counter]);
                                  System.out.println(item[counter]);
                                     //oOrderLines.setBaseType(new Integer(-1));
                                     //oOrderLines.setBaseEntry(new Integer(0));
                                   //oOrder.getLines().setCurrentLine(new Integer(counter));
                               //oOrderLines.setQuantity(new Double(1));
                                         //oOrderLines.setPrice(new Double(1500));
                                         //oOrderLines.setCurrency(strCurrency[counter]);
                                         //oOrderLines.setLineTotal(new Double(dblLineTotal[counter]));
                                  str += "5";
                                  //oOrder.getLines().getUserFields().getFields().item("Quantity").setValue(new Integer(2));
                                  System.out.println(str);
                                  int result = oOrder.update();
                                  str += "6" + result;
                                  if (result == 0) {
                                         System.out.println("successfully updated");
                                         company.disconnect();
                                  } else {
                                         company.getLastErrorDescription();
                                         System.out.println(
                                                 "Error :" + company.getLastErrorDescription());
                                         company.disconnect();

    If you are using SBP 2004 there are many threads on this forum talking about bugs when updating sales order lines through DI API. This issue was supposed to be fixed with patch level 45 for 2004 which was recently released.
    If u are using 2005 or SP1 I think you may have found a new bug.

  • Dates fields issue in the sales orders through IDOC

    Hi all,
    I'm trying to create a sales order through Inbound IDOC using IDOC_INPUT_ORDERS.
    I have 2 custom fields in the sales order which are date fields.
    I'm populating them from the IDOC segments(using E1EDKT1-tdid, E1EDKT2-tdline) in the user-exit just before the call trasacation statement. These dates are not coming for a few orders... but are getting populated normally for few of them.
    But the tricky part is that... if I process the same IDOC for the second time.. the order created is having the dates.
    My issue is that.. i need all the orders to be populated with the dates which IDOC have.
    Could anyone please help me with this issue.
    All the answers/replies are highly appreciated!!
    Thanks for you help!

    hi,
    the following may be of help
    There are 2 major exceptions to the batch input internal table. All text data from the segments E1EDKT1/2 and E1EDPT1/2 are not part of the batch input session. Text elements from these segments are posted directly to the data base AFTER the sales order has been created (please note: in order that item texts are posted correctly to the sales order the field POSEX from segment E1EDP01 MUST be transmitted). Also, configurable material information from the IDOC is exported to a global memory and therefore will not be part of the batch input session. Configurable material data is performed in Form CHECK_CONFIGURATION and the data is exported to global memory in the following code:
    Exportiert IDOC Daten ins globale Memory     
    export IDOC data to global memory            
      call function 'CUXC_IDOC_TO_MEMORY'          
           tables                                  
                cfg_instref = xe1curef             
                cfg_ref     = xe1cucfg             
                inst        = xe1cuins             
                part_of     = xe1cuprt             
                value       = xe1cuval             
           exceptions                              
                error       = 1                    
                others      = 2.                   
    One extra piece of useful infomartion if you wish to debug the process is to set your breakpoints at the following points
    for Function module IDOC_INPUT_ORDERS
    include LVEDAF0F..
      CALL TRANSACTION 'VA01' USING bdcdata
                                MODE  input_method
                                UPDATE 'S'
                                MESSAGES INTO xbdcmsgcoll.
    Now input_method is A foreground process and N for background processing but try changing it to P (pass through mode)
    If you have breakpoints in va01, e.g. MV45AF0B_BELEG_SICHERN,(the part where the sales document is saved)
    they will be hit, e.g
    perform userexit_save_document_prepare.
    perform userexit_save_document.
    Lastly, don't forget using program SDJEDI , see note 380603 for more information on this
    Hope this is useful
    Paul Quinn

  • Error while updating Sales Order : Another user Modified Table (RDR1 )

    Hi All,
    I am getting an error message while running the following steps.
    Steps
    1)     Pull an entry from sales order.
    2)     Add new data to line.
    3)     Update the sales order.
    a)     Sap updated the data.
    b)     Through code using DI API we updated some UDF.
    4)     With out closing / Pressing OK button…
    5)     We added new data to line.
    6)     Then Press update.
    An Error will through by B1 as “Another user modified the table(RDR1 ).” Before going to the code where we are handling the update of UDF.
    But after the 3rd step above when we do
    4) Close the window or pressed ok
    5)  take the sales order window again pull the data
    6) Add new Data to line.
    7) Update sales order then it will go smoothly.(Updating by B1 and from code )
    Can anybody tell me why this happens?And any workarounds to solve this?
    Deepesh

    are u adding a matrix row thru the code? I get this error when I am adding rows and I get the rownumber out of sync.
    if so get the max (lineid) from rdr1 and then check against the matrix.rowcount before adding a row. if lineid is greater that matrix.rowcount take lineid + 1 and assign it to the matrix.row, else take the rowcount + 1
    if not, and as a workaround, then you can try using the SBO_SP_transactionnotification stored procedure.

  • When I create Return Sales Order through BDC sales order doesnu2019t create.

    Deal Guru,
    When I create Return Sales Order through BDC sales order doesnu2019t create.
    It shows created sales document number but when I display this document I am getting message Document is not in database.
    After executing my BDC, message received in SAP in box : SAPSQL_ARRAY_INSERT_DUPREC
    I am receiving following message in SAP inbox for following issue.
    But when I create Return Sales Order through VA01, it is working. Please give me some idea.
    Detail Message
    Update was terminated
    System ID....   PRO
    Client.......   900
    User.....   DEVELOPER2
    Transaction..   VA01
    Update key...   4961DBF46A6B09D2E10080020A02281C
    Generated....   05.01.2009, 16:03:40
    Completed....   05.01.2009, 16:03:40
    Error Info...   00 671: ABAP/4 processor: SAPSQL_ARRAY_INSERT_DUPREC
    Regards
    Makarand

    Hi Rory
      Try this link:
       BAPI can't to create SO,But used bapi data with manual can?
    Regards
    Neha

  • Disallow changes in Sales Order through T-Code VA02

    Dear Gurus,
    We create the Sales Order and with reference to that the User wants to change few fields (Account Assignment Group, Pricing Date, Invoice Date, INCO terms, Payment Terms etc.) which are not supposed to be edited by him through T-Code VA02. Changes should also not to be made with regard to Material Line Item Material like Description & Quantity in Sales Order. We have tried to do the same through Transaction Variant (T-Code SHD0 & User Exit). Unfortunately it is not working. We are not able to assign the Transaction Varient for T-Code VA02 in sales document type through VOV8.
    System Audit has raised these points and needs to be done at the earliest.

    Hello Aaheli,
    I think your requirement of restricting the modification of Sales Order through VA02 can be meet using the following approach:
    Seek out the help of BASIS to restrict the Sales order modification role for that specific User ID.
    If you wanna restrict the modification of Sales order through VA02 for amny User ID then please use User exit.
    Do inform us about the latest updates on this issue.
    Regards,
    Sarthak

  • Adding Sales BOM to Sales Order through SDK

    Hello Experts,
    We're encountering an issue with adding Sales BOM items to the Sales Order through the SDK. When we add the parent, the object automatically adds the children as lines after all other lines. This causes issues with our batch delivery creation. When the Sales Order is created inside SBO Client, it always adds the child items right under the parent. We have a work around where we change the LineNum through SQL, but that seems like a sketchy method - what's the proper way of adding Sales BOM items to a Sales Order?
    Here is the code we're using to add the Sales Order lines
    olOrders.Lines.ItemCode = sItemCode
    olOrders.Lines.ItemDescription = aRecSet.Fields.Item("name").Value
    olOrders.Lines.UnitPrice = aRecSet.Fields.Item("cartprice").Value
    olOrders.Lines.Quantity = aRecSet.Fields.Item("qty").Value
    Thanks for the help!

    Hi Rob,
    I certainly wouldn't recommend you use a direct SQL command to update the LineNum on the sales order rows. This will invalidate your support agreement with SAP.
    One way you can deal with this would be to add your Sales BOM header item to a draft document (of type sales order) and add this first. You can then retrieve it in the DI API and add the other Items before adding the document as a proper sales order (and removing the draft). You can do this using the Draft and Documents objects either by coding each property or by exporting the Draft to XML and using XLST to convert it to a Sales Order and reimporting it. It does require a fair bit of coding but it will achieve what you need.
    Kind Regards,
    Owen

  • Sales order approval workflow

    Hi,
    I am new to workflow. I have to implement sales order approval process in sap.
    Below are my queries:
    1) Can anyone tell me that is there any standard method for "approval" available in BOR.
    2) Organization level should be derived from the custom table in sap depending on the input coming to workflow.
    So how i can implement this process?
    3) Is there any possibility to approve the sales order through e-mail. If yes then how to do that.
    Can anyone suggest any example for this.
    Thanks in Advance.
    Sumit

    Hi Sumit,
    There are standard Objects available in BOR for sales order  you can extend that object type and use a
    new method for Approval process check object BUS2032.
    You can forward your workitem through email maintain settings in SCOT and SOST.
    Thanks & Regards
    Hari Sankar M

  • SAP Query: Sales Order to Workflow Join

    I'm trying to create a report in Query that joins VBAK to workflow.  The idea is to select a date range, a sales org, a customer, or any number of parameters, and bring in work items related to those Sales orders .
    The trouble I'm having though is finding the key field to join sales orders to workflow.  I've been through what I think is nearly every workflow table, but I can't find a compatible field.
    Any help is greatly appreciated, and of course points awarded.
    Thank you.

    Hi Naval
    Can you provide a bit more detail. It is difficult to try and think what the problem could be without sufficient information
    Regards
    Brian Maunde

  • Import of Sales Order through DTW

    Dear All
    I am having problems in importing Sales Orders through DTW. I have used the template 'oOrders' and enter the required data in the 'Document' and 'Document-Lines' files.
    When, I run the DTW and uploaded the Sales Orders, it was imported successfully. But when I search in SBO, no Sales Order was created.
    I have also, unchecked the box 'Test Run', but still it doesnot posted any Sales Order.
    Kindly, help me in this regards
    Thanks and Best Regards
    Nabeel

    Dear Gordon
    Thanks for your prompt response.
    In the 'Documents' template, I filled the following columns:
    RecordKey   CardCode            DocDate       DocDueDate  
    1                  AAJ-KAC-6         20081203      20081203
    In the 'Documents-Lines' template, I filled following columns:
    RecordKey    ItemCode                 DocDate       DocDueDate     Price   Quantity   Tax Code
    1                  701-0020-0000         20081203      20081203         10        10            X0
    I, also tried to post the Sales Order manually by entering the above data and SO was posted. But it is not posting through DTW.
    Thanks and Best Regards
    Nabeel

  • Creation of Sales orders through EDI

    Hello,
    We have a problem when creating sales orders through EDI.
    We are getting IDOCs with a delay of 1 second.Before  
    creating sales orders through the posting function
    module IDOC_INPUT_ORDERS, we need to validate for
    reference Purchase order number in the IDOC. If there is
    any sales order in the database with the Purchase order
    number in the current IDOC that sales order should be 
    blocked.
    We already put a validation in the User-Exit of the
    posting function module. Because of the frequency of
    IDOCs we receive, this validation is getting failed.
    Can anybody tell me, how to process only 1 IDOC at any
    given point of time before the Posting process.
    Thanks,
    Madhusudan.

    Hi Sanjeev,
      Thank you very much for helping me out in this problem.Still I haven't got the solution.
    I tested the above mentioned configuration option by putting the Check Purchase Order Number field to 'A' in the transaction VOV8. But while creating sales orders, it is giving only information message. Is there any other way, to restrict the Duplicate PO value through configuration setup.
      can you also explain how to use Enqueue and Dequeue FMs in the inbound posting function module.
    Regards,
    Madhusudan.
    Message was edited by: Madhusudan Budati
    Message was edited by: Madhusudan Budati

Maybe you are looking for

  • 4.6c to ECC 6.0 upgrade

    My client is looking to move from 4.6C to ECC 6.0. Now, it is using BAs as the legal entities instead of compay codes, its also using Internal Orders to capture all the revenue and cost centers for expenses as well as balance sheet items (changing th

  • Bought QuickTimePro 7 Registration Key Doesn't Work non Retrievable

    I bought Q.TimePro 7 an hour back, I thought I copied the key correctly but it says invalid upon registration. I followed the link to retrieve it from my orders page and it doesn't list my product key where it says I ordered Q.TimePro 7. The link in

  • Regarding FATCA- International Vendors Tax withhold

    Hi Experts, We have this requirement to implement / start withholding tax (some %) from the payments made to International vendors if they don't supply proper documentation (Like W8s). this is new regulation that will be in effect from July 1 2014. c

  • +5 Voltage alert

    Hi, When I'm playing a game it will stop and PC Alert will have +5 V in red flashing. It is running at 4.65 right now.  I also will have the pc shut down on my once in awhile.   I think my power supply is 250 watts.  Is this the problem?

  • Using INVOIC01, IDOC posts invoices against POs that weren't sent to vendor

    Does anyone have any suggestions on how to prevent the IDOC INVOIC01 invoices from posting against POs that were not originally sent to the vendor??  (BSART = INVO) For example, vendor (1521) sends an electronic invoice file processed as an IDOC.  Ve