Creating a Service Order automatically when saving a Sales Order

Hello SDN,
I'm trying to have SAP automatically create a Service Order when a Sales Order is created. To this end, I've tried implementing BADI workitem_template and have been using method before_update. I've been using BAPI BAPI_ALM_ORDER_MAINTAIN to create the service order.
The problem is that in order for the BAPI to save the service order, the sales order needs to be fully saved and operational. Otherwise it just keeps saying 'sales order does not exist'. So the problem is that the BADI is intervening too soon in the saving process. The temporary sales order numbers have been replaced with actual ones, but the records do not show in the database just yet. I think there's a commit that still needs to be done or something.
However, I cannot find a BADI or user exit that intervenes after the sales order is saved into the database, so this leaves me stranded.
Any suggestions would be heartily apprechiated.
Kind Regards,
Niels.
Edited by: Niels Ruelens on Feb 20, 2008 4:20 PM
Edited by: Niels Ruelens on Feb 20, 2008 4:22 PM

Following your suggestions, I've created an update function module and inserted it into the USEREXIT_SAVE_DOCUMENT. In this function module, I'm calling the BAPI.
Problem with this approach is that I cannot debug, nor is he actually doing anything. Here's the code that is put in the function. Is there anything wrong with the way I call the BAPI perhaps?
  DATA:
    lt_srule     TYPE TABLE OF bapi_alm_order_srule,
    lt_bheader   TYPE TABLE OF bapi_alm_order_headers_i,
    lt_srule_up  TYPE TABLE OF bapi_alm_order_srule_up,
    lt_methods   TYPE TABLE OF bapi_alm_order_method,
    lt_return    TYPE TABLE OF bapiret2,
    ls_vbak      TYPE vbak,
    ls_vbap      TYPE vbap,
    ls_bheader   TYPE bapi_alm_order_headers_i,
*    ls_header    TYPE cobai_s_header,
    ls_prps      TYPE prps,
    ls_srule     TYPE bapi_alm_order_srule,
    ls_srule_up  TYPE bapi_alm_order_srule_up,
    ls_methods   TYPE bapi_alm_order_method.
*    ls_item      TYPE cobai_s_item.
  SELECT SINGLE * INTO ls_vbak
  FROM vbak
  WHERE vbeln = vbeln.
  SELECT SINGLE * INTO ls_vbap
  FROM vbap
  WHERE vbeln = vbeln.
  FREE: lt_methods, lt_bheader, lt_srule.
* Fill methods
  CLEAR ls_methods.
  ls_methods-refnumber  = 1.
  ls_methods-objecttype = 'HEADER'.
  ls_methods-method     = 'CREATE'.
  ls_methods-objectkey  = '%00000000001'.
  APPEND ls_methods TO lt_methods.
*  CLEAR ls_methods.
*  ls_methods-refnumber  = 1.
*  ls_methods-objecttype = 'SRULE'.
*  ls_methods-method     = 'CREATE'.
*  ls_methods-objectkey  = '%00000000001'.
*  APPEND ls_methods TO lt_methods.
  CLEAR ls_methods.
  ls_methods-refnumber  = 1.
  ls_methods-objecttype = ''.
  ls_methods-method     = 'SAVE'.
  ls_methods-objectkey  = '%00000000001'.
  APPEND ls_methods TO lt_methods.
* Fill header
  CLEAR ls_bheader.
  ls_bheader-orderid    = '%00000000001'.
  ls_bheader-order_type = 'ZM02'.
  ls_bheader-funct_loc  = 'FERBL_TD5C_DER'.
  ls_bheader-planplant  = 'B006'.
  ls_bheader-sales_ord  = vbeln.
  ls_bheader-s_ord_item = '00010'.
  APPEND ls_bheader TO lt_bheader.
** Convert the internal WBS to an external WBS element
*  SELECT SINGLE * INTO ls_prps
*  FROM prps
*  WHERE pspnr = ls_vbap-ps_psp_pnr.
**   Fill settlement rules
*  ls_srule-objnr =   ls_item-aufnr.
****    ls_srule-sales_ord = caufvd_imp-kdauf_aufk.
****    ls_srule-s_ord_item = caufvd_imp-kdpos_aufk.
*  ls_srule-wbs_element = ls_item-projn.
*  ls_srule-settl_type = 'FUL'.
*  ls_srule-percentage = 100.
*  ls_srule-extnr = 1.
*  APPEND ls_srule TO lt_srule.
*  ls_srule_up-wbs_element = 'X'.
*  ls_srule_up-sales_ord = 'X'.
*  ls_srule_up-s_ord_item = 'X'.
*  ls_srule_up-orderid = 'X'.
*  ls_srule_up-settl_type = 'X'.
*  ls_srule_up-percentage = 'X'.
*  ls_srule_up-extnr = 'X'.
*  APPEND ls_srule_up TO lt_srule_up.
  CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
      it_methods              = lt_methods
      it_header               = lt_bheader
*          IT_HEADER_UP            =
*          IT_HEADER_SRV           =
*          IT_HEADER_SRV_UP        =
*          IT_USERSTATUS           =
*          IT_PARTNER              =
*          IT_PARTNER_UP           =
*          IT_OPERATION            =
*          IT_OPERATION_UP         =
*          IT_RELATION             =
*          IT_RELATION_UP          =
*          IT_COMPONENT            =
*          IT_COMPONENT_UP         =
*          IT_OBJECTLIST           =
*          IT_OBJECTLIST_UP        =
*          IT_OLIST_RELATION       =
*          IT_TEXT                 =
*          IT_TEXT_LINES           =
*     it_srule                = lt_srule
*     it_srule_up             = lt_srule_up
*          IT_TASKLISTS            =
*          EXTENSION_IN            =
         return                  = lt_return.
*          ET_NUMBERS              =.
  IF sy-subrc = 0.
  ENDIF.
Edited by: Niels Ruelens on Feb 20, 2008 4:58 PM

Similar Messages

  • Inserting Pricing condition in Sales order when saving the sales order

    Dear ABAPers,
           My customers requirement is when saving the sales order new pricing condition has to be updated in the line item.for this i am using the User Exit 'USEREXIT_SAVE_DOCUMENT_PREPARE' ( MV45AFZZ).While saving the Sales order i am calculating the Price and updating in the Pricing conditions.
    In XKOMV internal table i am appending the pricing condition.But the problem is ,it is not calculating the taxes and it is Updating in VBAK and VBAP.
    How to do this.
    Thanks & Regards,
    Ashok.

    Dear ABAPers,
    I have Solved this Problem.
    Thanks & Regards,
    Ashok.

  • Ps assembly processing:WBS have not be created when saving the sales order

    In the ps assembly processing, I want to generate a network when I create a sales order.  So I did the following steps:
    1-Use the TCODE cj91 to create a standard WBS "E-000007.1".
    2-Use the TCODE cn01 to create a standard network "10000000" and assign the standard WBS "E-000007.1" to it.
    3-Use the TCODE cn08 to config the Network Parameters from Sales Order like below:
    Material number : 600000-000000-0009
    Order Type      : Z301
    Std network     : 10000000
    Class Type      : 020
    Network Profile : Z0001
    MRP Controller  : 001
    Std WBS element : E-000007.1
    4-Use the TCODE va01 to create a sales order and add an item with the material "600000-000000-0009" and save.
        When the SAP R/3 System is saving the sales order, a WBS ought to be created u2013 based on the assignment of the standard network to the standard project.But I could not found the WBS.I thought I have do all of steps and could not found the reason.
       So I need the experts give me some useful advice and reference to resolve the problem.Thank you.
    Regards
    Yoda

    Hi,
    Maintain strategy group in material master MRP tab....
    If problem still persist then check is there any credit block to that customer...if it is release it in VKM3....
    Once you release it will create automatically.
    Regards

  • Idoc not gettind created when saving a sales order

    Hello,
    In my system a sales orders has been created using ORDERS05 Idoc. We wanted a confirmation Idoc to be created automatically by this sales order but it didn't. The output type for EDI processing is in yellow for this sales order. I checked 'Dispatch time' in further data and it was 'Send immediately'.
    When I click on save again on the 'output types' screen I get an update error in my inbox saying that "AM 117: Form of address key & is not defined".
    Can anyone tell me where I am going wrong?
    Kind Regards,
    Priyanka Gupta.

    Hi,
    Try this.
    In some cases, even after setting the trigger immediately in the partner profile, the idoc status will be in yellow color. For this add the below code and trigger it.
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
          EXPORTING
            master_idoc_control            = wa_ctrl
          TABLES
            communication_idoc_control     = i_comm
            master_idoc_data               = i_edidd
          EXCEPTIONS
            error_in_idoc_control          = 1
            error_writing_idoc_status      = 2
            error_in_idoc_data             = 3
            sending_logical_system_unknown = 4
            OTHERS                         = 5.
        IF sy-subrc EQ 0.
          READ TABLE i_comm INTO wa_comm INDEX 1.
    *Unlock table created by master data
          CALL FUNCTION 'EDI_DOCUMENT_DEQUEUE_LATER'
            EXPORTING
              docnum = wa_comm-docnum
            EXCEPTIONS
              OTHERS = 1.
          REFRESH it_idoc_range.
          lwa_idoc_range-sign   = 'I'.
          lwa_idoc_range-option = 'EQ'.
          lwa_idoc_range-low    =  wa_comm-docnum.
          APPEND lwa_idoc_range TO it_idoc_range.
    Send the idoc
          CALL FUNCTION 'ISU_EDATEX_IDOC_SEND' IN BACKGROUND TASK
            EXPORTING
              xt_idoc = it_idoc_range.
          GET TIME.
    Ensure background task is called immediately
          CALL FUNCTION 'START_OF_BACKGROUNDTASK'
            EXPORTING
              startdate = sy-datum
              starttime = sy-uzeit.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
       ENDIF.
    Regards,
    Sharin.

  • Billing Plan Billing Block Change when saving the sales order

    Dear Gurus,
    We have SD Integrated with PS. We create the sales orders and pull the billing plans milestones from WBS.
    Once we generate the billing plans, system will propose the billing block for all the line items of the milestones which normally comes from the billing plan configuration/item category.
    Would like to know the appropriate userexit to change the Billing block to "XX" if some of the requirements are not met when we create or change the sales document.
    Below is what i am able to see but seems to be not helpfull.. please guide..
    User exits in program RV60FUS1
        BILLING_SCHEDULE_DELTA
        For milestone billing a percentage value is fully invoiced for each billing deadline. In the case of deviations between the original item value and any later changes, you can use the user exit to determine whether the difference should be stored in the final invoice or sent to the next deadline.
        USEREXIT_MOVE_FIELD_TO_FPLT
        This user exit allows you to create your own fields in table FPLT.
        USEREXIT_MOVE_FIELD_TO_FPLA
        This user exit allows you to create your own fields in table FPLA.
    Reward points for the right answers..
    Regards
    Ram

    Dear Friend,
    I hope you can make it with the above user exits.Consult your abaper and try it.
    Thank you,

  • BADI when Saving a Sales Order CRMD_ORDER

    Which all BADIs are trigrred while saving salesorder using CRMD_ORDER transaction. Basically i need to get Sales order in a variable when sales order is saved and pass it to Ztable.
    Thanks in advance.
    Kartavya

    HI,
    the best fit badi for your requirement is ORDER_SAVE.
    You can implement the method CHANGE_BEFORE_UPDATE.
    This method is specially designed for the requirement like yours...
    Kindly reward with points in case helpful...
    Sharif

  • User exit for saving a sales order

    hi
    wats the user exit when saving a sales order?

    Hi,
    SDTRM001            Reschedule schedule lines without a new ATP check
    V45A0001            Determine alternative materials for product selection
    V45A0002            Predefine sold-to party in sales document
    V45A0003            Collector for customer function modulpool MV45A
    V45A0004            Copy packing proposal
    V45E0001            Update the purchase order from the sales order
    V45E0002            Data transfer in procurement elements (PRreq., assembly)
    V45L0001            SD component supplier processing (customer enhancements)
    V45P0001            SD customer function for cross-company code sales
    V45S0001            Update sales document from configuration
    V45S0003            MRP-relevance for incomplete configuration
    V45S0004            Effectivity type in sales order
    V45W0001            SD Service Management: Forward Contract Data to Item
    V46H0001            SD Customer functions for resource-related billing
    V60F0001            SD Billing plan (customer enhancement) diff. to billing plan
    tables : modsap
    tcode : cmod,smod
    Reward if usefull

  • Different message in va01: Defect in ECC6 server while saving the sales order .

    Hi ABAP gurus,
    I am in to upgrade Project In ECC6 server I am getting the different message when saving the sales order in va01 compare to  old sever(4.7) .
    I have to make it to the same message as it is in the 4.7 server.
    plz help me .
    Regards,
    vanamaala kashavena

    Hi,
    IF xvbap-uepos IS INITIAL AND
            xvbap-zzhrs_conf <> 'X'.
            MESSAGE ID 'ZOTC' TYPE 'E' NUMBER '067' WITH
            'Please select Hours Confirmed in Additional data B'(302) 'for item'(303) xvbap-posnr.
          ENDIF.
    this is the code in the  PARTICULAR INCLUDE PROGRAM .
    this is same in both the system ,but in ecc6 server,in message
    popup it is not giving 'Please select Hours Confirmed in Additional data B' .
    it is giving ORDER QTY FORMAT PERIOD (ITEM NUMBER(0010))
    Regards,
    vanamaala k

  • In Sales Order form populate charges field after saving the Sales Order

    Can we populate Charges field in Sales Order form after saving the sales Order automatically.
    The charges to be calculated based on the amount entered and the item selected in Sales Order.
    In the Manual process it is done by hitting the Actions Button and then select the Charges.
    The charge type would be "Freight Costs"

    by using process_order API, I am able to update the charges field.

  • Error getting when saving the sales document in third party sales order

    in third party sales order,when i am saving the sales order i am gettingthe following error
    subsequent function 'purchase requistion from sales document' not possible due to credit block.earlier i have maintained credit checks for some customers,but for this customer i have not maintained any credit check. i dont know why system is blocking for this customer also.pls help me where i went wrong.
    highly rewarded if help full.
    thank you

    Please go to FD32, check any default risk category and credit limit is maintained for the customer.
    Also check OB45, any default risk category & credit limit is maintained for the credit control area.
    Also, which order type u r creating sales order? for that order type, Goto VOV8, remove the credit grp and credit check settings.
    Also goto XD02, check in sales area data, billing tab, credit control area field, please remove that also.
    Hope it Helpful.
    Reward points if useful..

  • CM25 : adjust setup time automatically when i dispatch production orders

    Dear guru ,
    I dispatch the production orders according to a specific sequence.
    After the dispatching I can adjust setup time automatically using setup matrix.
    Does exist a chance to adjust setup time automatically when i dispatch production orders ?
    Thanks.

    no replies

  • Send Mail to Customer while saving the Sales Order

    Dear Friends,
    My Requirment is to send the mail to Customer automaticaly when create any Sales Order.
    While sending the mail given three points reqired.
    1.     Send the attachment of Order Conformation along with the mail.
    2.     There must be The title text as "Order Confirmation refrence of your PO <Customer PO No> <PO Date>"
    3.     There must be some body text like some terms and conditions with variables of Order data.
    Can any body help me one this step by step.
    Kindly suggest me how to do this.
    Thanks in Advance.
    D Tarun Kumar
    Moderator message : Spec dumping not allowed, duplicate post. Thread locked.
    Edited by: Vinod Kumar on Jul 12, 2011 11:30 AM

    While saving the sales order through Va01 and Va02 and email has to send

  • When is a Sales Order considered closed on the system

    Hi,
    At which point does the system consider the Sale orders are closed:
    1. When the delivery document is created?
    2. When the billing document is created?
    3. When the customer's account uis posted to the Account Receivables?
    If you were to check for open or closed Sales Orders, would you check the line item status or any of the specified 'When' stated?
    Is this SAP standard configuration or it depends on the SAP clients' requirements?
    Thanks

    Dear Yosemite Sam,
    At which point does the system consider the Sale orders are closed:
    sales order is considered to be closed, when the total order qty is completely referenced
    i.e,completely delivered if there is delivery
    or
    completely invoiced if its a service order
    If you were to check for open or closed Sales Orders, would you check the line item status or any of the specified 'When' stated?
    if a line item is completely referenced, it does not mean that the order is completed.
    The sales order is complete, if all the line items are completely referenced.
    Hence you may take the header status for completion.
    TABLE : VBUK
    Is this SAP standard configuration or it depends on the SAP clients' requirements?
    It is SAP Standard.
    NOTE:There will be threads on this, hence please search the forum before posting your queries.
    Thanks & Regards,
    Hegal K Charles

  • Create multiple single unit wip jobs for total sales order line qty

    Hi all,
    I want to know if there's a standard way to create multiple single unit wip jobs from a sales order line which has 2 or more units, i mean...
    I have a sales order line with item A with 3 units. If I progress the sales order, a single job is automatically created in WIP with 3 units to be created. What i want is to create 3 jobs with one unit each, all of them linked to the sales line order...
    Thanks in advance!
    Regards!
    Answered.........
    Edited by: user604737 on Nov 10, 2010 3:51 PM

    Hi Sandeep
    We have similar requirement (SO qty = 3 then 3 WIP jobs should be created). However when planning releases WIP jobs it does not tie back(reserve) the jobs to sales order.
    Are you aware of any standard way to do the same??
    Regards
    Mudit Gupta

  • RunTime Error while saving a Sales Order

    Hi All,
    When i am saving a Sales Order, the system is throwing a Runtime Error.
    The ABAP Code in the Runtime Error screen as follows.
              select * from (t681-kotab) appending table <cond_tab>
                     up to 1 rows
                     where kappl  = se_kappl
                     and   kschl  = se_kschl
                     and   datbi >= se_date
                     and   datab <= se_date
                     and   (coding_tab).
    Till these days, there was no such error while saving a Sales Order.
    How to resolve this issue?
    Regards
    Pavan

    Hi,
    The below piece of code is trying to get the contents of the table mentioned in T681-KOTAB.
    select * from (t681-kotab) appending table <cond_tab>
    up to 1 rows
    where kappl = se_kappl
    and kschl = se_kschl
    and datbi >= se_date
    and datab <= se_date
    and (coding_tab).
    The reason could be is someone has screwed up the entries in T681 table. Check that out.
    Try to put a break point on this SELECT query and see what the value of T681-KOTAB holds before the SELECT query. Check whether such a table entry exists in DB.
    Let me know if you are still stuck up.
    If you can send me the ST22 dump of the run time error, i might be able to help you more  on this.
    Hope this helps.
    Thanks,
    Balaji

Maybe you are looking for

  • How can I display multiple column results of a sql query?

    I'm wanting to display the results of a query selecting from multiple columns, but I can't seem to find an item type that will allow this. I've tried LOV, multiselect, display as text and others. Any ideas on how to do this. Here is my basic query: S

  • Dynamic database connection using JNDI

    How to pass the userid and password in get the database connection in weblogic 8.1 app server? The following method throws exception while getting the database connection from oracle. DataSource.getConnection(String username,String password) Please a

  • Cluster and Xserve g5

    Hello, Can somebody tell me what's the difference between cluster nodes and the Xserve g5's. I was looking at the Apple store at the dual 2.3ghz processors and the difference that I see is that the xserve g5 has a combo drive and an unlimited client

  • IPhoto '11 Crashes on Startup due to Quicktime/AviImporter-r7

    Sitting on a MBP 15" from last year, snowleopard, all updated. The other day I ran the 4.2 iPhone and iPad installs and had to upgrade my iTunes to a beta release, I assume this has caused issues with my iPhoto. When I click on the icon it bounces a

  • Another delivery/installation disaster!

    Incident: Dec. 10-23, 2013 We had picked out a dishwasher  - an LG LDS 5040ST - that would fit the slightly too small space in our kitchen and found that Best Buy online had a great sale price. But because we wanted their installation service as well