CRM_ORDER_MAINTAIN - in order_save BADI

Hi Experts,
I want to update my order. I have to add the account assignment group to my service order when the order is saved. How do I pass this value in the badi order_save. I want to use the function module crm_order_maintain. Can anyone please suggest how do I go about it.
Warm Regards,
Abdullah

Hi Experts,
This is how I code after I use CRM_ORDER_READ in the badi method change_before_update.
  select single *
    from zco003
    into wa_zco003
    where service_org_shor = v_sorg and
          process_type     = v_process_type.
  if sy-subrc = 0.
    iw_ac_assign-ref_guid = iv_guid.
    iw_ac_assign-ref_kind = 'A'.
    iw_ac_assign-ac_object_type = '01'.
    iw_ac_assign-ac_assignment = wa_zco003-aufnr.
    iw_ac_assign-ac_percentage = '0.00'.
    iw_ac_assign-mode = 'C'.
    append iw_ac_assign to it_ac_assign.
    cw_orderadm_h-guid = iv_guid.
    append cw_orderadm_h to ct_orderadm_h.
    cw_input_fields-ref_guid = iv_guid.
    cw_input_fields-ref_kind = 'A'.
    cw_input_fields-objectname = 'AC_ASSIGN'.
    cw_field_name-fieldname = 'AC_ASSIGNMENT'.
    cw_field_name-changeable = 'X'.
    append cw_field_name to ct_field_name.
    cw_field_name-fieldname = 'AC_OBJECT_TYPE'.
    cw_field_name-changeable = 'X'.
    append cw_field_name to ct_field_name.
    cw_field_name-fieldname = 'AC_PERCENTAGE'.
    cw_field_name-changeable = 'X'.
    append cw_field_name to ct_field_name.
    cw_field_name-fieldname = 'AC_TYPE_T'.
    cw_field_name-changeable = 'X'.
    append cw_field_name to ct_field_name.
    cw_field_name-fieldname = 'MODE'.
    cw_field_name-changeable = 'X'.
    append cw_field_name to ct_field_name.
    cw_input_fields-field_names[] = ct_field_name[].
    append cw_input_fields to ct_input_fields.
    loop at et_orderadm_i into ew_orderadm_i.
      clear cw_input_fields.
      cw_input_fields-ref_guid = ew_orderadm_i-guid.
      cw_input_fields-ref_kind = 'B'.
      cw_input_fields-objectname = 'AC_ASSIGN'.
      append cw_input_fields to ct_input_fields.
    endloop.
    clear cw_input_fields.
    cw_input_fields-ref_guid = iv_guid.
    cw_input_fields-ref_kind = 'A'.
    cw_input_fields-objectname = 'ORDERADM_H'.
    append cw_input_fields to ct_input_fields.
    loop at et_orderadm_i into ew_orderadm_i.
      cw_orderadm_i-guid = ew_orderadm_i-guid.
      append cw_orderadm_i to ct_orderadm_i.
      clear cw_orderadm_i.
    endloop.
    loop at et_orderadm_i into ew_orderadm_i.
      clear cw_input_fields.
      cw_input_fields-ref_guid = ew_orderadm_i-guid.
      cw_input_fields-ref_kind = 'B'.
      cw_input_fields-objectname = 'ORDERADM_I'.
      append cw_input_fields to ct_input_fields.
    endloop.
    call function 'CRM_ORDER_MAINTAIN'
     exporting
       it_ac_assign                  = it_ac_assign
     importing
       et_exception                  =  et_exception
     changing
*       ct_orderadm_h                 = ct_orderadm_h
*       ct_orderadm_i                 = ct_orderadm_i
       ct_input_fields               = ct_input_fields
       cv_log_handle                 = cv_log_handle
*       ct_partner_attributes         =
*       ct_doc_flow                   =
     exceptions
       error_occurred                = 1
       document_locked               = 2
       no_change_allowed             = 3
       no_authority                  = 4
       others                        = 5
    if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
*         with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      message 'error in updating' type 'e'.
    endif.
Can anyone please suggest what am I doing wrong
Regards,
Abdullah

Similar Messages

  • How to update Sold-To Party (In ORDER_SAVE BADI)

    Hi,
    I have a requirement as follows:
    In for a Sales Order, In ORDER_SAVE BADI, I have to do validation for Sold-to Party. If validation fails, I need to display an error message and I need to clear the Sold-to Party field, hence user has to select another sold-to party.
    Could you please let me know, how can I clear the sold-to party, in ORDER_SAVE BadI. Any FM's to do that?
    Thanks,
    Sandeep

    Hello Sandeep,
    why you want to delete the sold-to ? I think its just easier to give a error message in the log, so the users  could enter a new sold-to. Within the badi order_save you can prvent saving with exception do_not_save  - see note 1519171 for detailed information.
    Best regards
    Rene

  • Error message problem in ORDER_SAVE badi.

    I have used a error message using MESSAGE statement in ORDER_SAVE badi. The problem is when I press the save button and if the condision fails it shows error message. After if you press enter it shows the order is saved.
    It is strange. Please help.

    Can you give some more information?
    1. Which method of the badi are you using?
    2. Do you raise the exception error_occured in this method?
    In general, if you use change_before_update method and raise the exception if you do not want to save the order, the order would not be saved. This exception should be raised every time the method is executed if you do not want to save the current order.
    See the standard implementation class CL_IM_CRM_BUS20001_UPLOAD.
    Hope this helps. If not, post the code, so that I can check.
    Prakash

  • Issue in ORDER_SAVE badi

    Hi All,
    Scenario:
    1. created new sales order in the CRM.
    2. I am replicating the sales order from CRM to ECC and created delivery for this order.
    When I see the sales order in CRM line item system status is updating based on the ECC delivery.
    3.Based on the line item system status I have to change the line item user status. I have written my code within the ORDER_SAVE BADI and it is not triggering.
      Will  ORDER_SAVE BADI  triggered for middleware ?
    I have to change the line item user status when the line item system is updated from ECC.Please help me where to write this code.
    Thanks,
    Venkat

    Hello ,
    Please check sap note 905430,where it explains there is no mapping between crm and r/3 for user status and you can check
    the details for the same.
    Also check the status profile.
    Regards,
    Deepa

  • Creating an Order from within the Order_Save badi

    Hi Experts,
    I'm creating trying to create a sales order with in the 'order_save' badi.
    I heard that this is not a recommended practice.
    Any inputs on why this has to be avoided?
    Regards,
    Kris.

    Hi kris,
    DOnt worry about creating a transaction while saving a Document. In my previous project I used save badi not only to create new but also to Create and then attach the same to the transaction which is saved and then update the same as well with product.
    You can use the save badi but only make sure that you Dont; use the COmmit work or any Commit bapi else you will get short dumps while saving "Express document terminated"(Dump type).
    Hope this Helps.

  • Invalid Business Partner Assignment via BAdI CRM_ORDER_MAINTAIN

    Hi all,
    I'm on Solution Manager 7.1 (SP3), and currently, I'm working on BAdI CRM_ORDER_MAINTAIN (method PREPARE) to populate business partner on WebUI (TCode CRM_UI). The Business Partner populated successfully on Parties Involved panel via the above mentioned BAdI.
    However, the only thing that puzzled me is; I encountered an error message, Business Partner 302 (Team Lead) is not a business partner, although Business Partner 302 is populated correctly in CRM_UI. Please note that Team Lead is customized Partner Function.
    I've checked the master data, and Business Partner 302 does exist. Does anyone knows why I would encounter the above error message eventhough Business Partner 302 has been maintained?
    Thanks in advance.
    Regards,
    Patrick

    Hi Patrick,
    can i know how to populate the busniess partner in webUI, i tried using CRM_ORDER_MAINTAIN in ORDER_SAVE BADI(method PREPARE), but is not getting populated in webUI.

  • How to Change Schedule line Quantity in BADI 'ORDER_SAVE'

    Hi,
    I need to change the Schedule line quantity While Order saving. I am writing the code in ORDER_SAVE BADI. Using the Header guid i am reading the details and changing the quantity in Schedule line structure. How can i pass those values in to Memory so that order quantity will change. I try to Use CRM_ORDER_MAINTAIN but not able to change the quantity. Can an

    Hi,
    You need the One Order Function Module - CRM_ORDER_MAINTAIN to update the Schedule line value. So, you need to have a look at all the fields that are necessary to fill using the Tables and Structures. If you have the header guid, then you can probably pass the guid to CRM_ORDER_READ to read the values and then fill in the entries necessary to make the changes.
    You can also debug the order code to get a feel of the necessary changes.
    Hope this helps.
    Thanks,
    Samantak.

  • CRM_ORDER_MAINTAIN not updating the item level field

    Hi All,
    My requirement is to update a field called "CSC Code" in line item of sales order. hence for this case i am using "CRM_ORDER_MAINTAIN" inside the "ORDER_SAVE" BADI. I am passing the ref guid, ref type, object name ,Logical Key and field name in the  CHANGING parametrs  CT_INPUT_FIELDS. I am passing the internal table containing the ref guid,ref type, partner fct ,partnerno to the internal table IT_PARTNER.
                                     The FM gets executed without any error and the internal table IT_PARTNER is filled with the new CSC code  but  on checking in the sales order after saving the field is blank.
      I have tried using wait up to 2 seconds. Even then it didn't work.
    Can some one help me?
    Thanks.

    Could you please let me know how was it fixed... I have a similar kind of requirement
    Edited by: rakesh chaitanya  makkapati on Apr 7, 2010 4:49 PM

  • Adding item data in Product tab for sales contract (crm_order_maintain)

    Hi, can I use crm_order_maintain to add line items under the product tab for a sales contract while creating or modifying an order. Is there any sample code to add the line items, I could look at.  I tried calling this FM from my custom tab and then called CRM_ORDER_SAVE but that did not add the line item. I guess I need to call it from the order_save badi and then call the crm_order_save FM as well from within the BADI. If someone could send me some sample code then I can double check if I am missing something.Am I on the right track to be using this FM for adding a line item under the product tab for the sales contract? Please help. thanks

    Hi, I've encountered the same problem while I was creating a Sub-Contract from a Master Contract.
    In my case the solution was:
    first create the Sub-Contract,
    CALL FUNCTION 'CRM_ORDER_MAINTAIN'
          CHANGING
            ct_orderadm_h     = i_ctorderadm_h
            ct_input_fields   = i_ctinput_fields
            ct_doc_flow       = i_ctdoc_flow
          EXCEPTIONS
            error_occurred    = 1
            document_locked   = 2
            no_change_allowed = 3
            no_authority      = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        READ TABLE i_ctorderadm_h INTO wa_ctorderadm_h INDEX 1.
        APPEND wa_ctorderadm_h-guid TO i_objects_to_save.
    in wa_ctorderadm_h-guid now we have the guid of the newly created Sub-Contract.
    SELECT SINGLE it_type_to
                 INTO  v_it_type_to    " --> target item type
                 FROM  crmc_it_copy_ma
                 WHERE it_type_from = wa_out_orderadm_i-itm_type.
         Prepare tables
            wa_ctorderadm_i-header =
            wa_out_orderadm_i-header.   "Retrieved from CRM_ORDER_READ
            wa_ctorderadm_i-handle = '0000000001'.
            wa_ctorderadm_i-number_int = '0000000001'.
            wa_ctorderadm_i-product = wa_out_orderadm_i-product.
            wa_ctorderadm_i-ordered_prod =
            wa_out_orderadm_i-ordered_prod.
            wa_ctorderadm_i-description = wa_out_orderadm_i-description.
            wa_ctorderadm_i-itm_type = v_it_type_to.
            wa_ctorderadm_i-order_date   = sy-datum.
            wa_ctorderadm_i-itm_language = sy-langu.
            wa_ctorderadm_i-mode = c_a.   "c_a = 'A'
            wa_ctorderadm_i-header = wa_ctorderadm_h-guid.
            APPEND wa_ctorderadm_i TO i_ctorderadm_i.
            wa_input_fields-ref_handle = '0000000001'.
            wa_input_fields-objectname = 'ORDERADM_I'.
            REFRESH i_input_field_names.
            wa_input_field_names-fieldname = 'DESCRIPTION'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'HEADER'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'ITM_TYPE'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'MODE'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'NUMBER_INT'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'ORDERED_PROD'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'ORDER_DATE'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_field_names-fieldname = 'PRODUCT'.
            APPEND wa_input_field_names TO i_input_field_names.
            wa_input_fields-field_names = i_input_field_names.
            APPEND wa_input_fields TO i_ctinput_fields.
    After that I've called function 'CRM_ORDER_MAINTAIN', to copy the Items from the Master Contract.
    CALL FUNCTION 'CRM_ORDER_MAINTAIN'
            EXPORTING
              it_sales          = i_sales
              it_schedlin_i     = i_schedlin_i
            CHANGING
              ct_orderadm_i     = i_ctorderadm_i
              ct_input_fields   = i_ctinput_fields
            EXCEPTIONS
              error_occurred    = 1
              document_locked   = 2
              no_change_allowed = 3
              no_authority      = 4
              OTHERS            = 5.
    Maybe if you're not working with Contracts, the procedure is not properly correct.
    I suggest to put a break-point into crm_order_maintain and try to add the Item manually.
    If you reproduce exactly the standard, I'm shure it will work.
    Lorenzo

  • Crm_order_maintain for opportunity

    Hi
    Using fm crm_order_maintain in badi order_save to populate organisational data.
    I am using bapi_transaction_commit and crm_order_save after crm_order_maintain but
    it is called recursively resulting in short dump.
    Can somebody share code for a similar situation so that i can check where m going wrong.
    Thanks in advance
    points will be rewarded:)
    Vidushi

    Hello Vidushi,
    Order_Save BADI is triggered for all types of ORDER.
    Please make sure that you have validation for order type before calling order_maintain.
    If you are changing the document in order_save, then you should check if the task = 2 (Change) and not 1 (Create).
    Regards,
    Kapil Patil

  • Changing Pricing COND in CRM_ORDER_MAINTAIN

    Hi All,
    i am creating an ORDER in CRM and have a pricing condition ZFRT with 0.00. I am changing the value to say $10.00 in ORDER_SAVE BADI i updated the appropriate structure LT_PRIDOC with KBERT with updated value and sent the strucure to CRM_ORDER_MAINTAIN. i see the value in the structure that i am sending to CRM_ORDER_MAINTAIN but i do not see on the ORDER.
    Am i misisng anything. I was under impression that if we send the changes to CRM_ORDER_MAINTAIN that will update the ORDER.
    Can anyone please help me with this?
    I appreciate all your help,
    Thanks,
    Karuna.

    I do not know what command you are using but I use the command INSERT. Below is my example, I am using CRM_PRIDOC_MAINTAIN_OW but it should be the same. It uses hashed table as well.
      DATA: it_cond_chg TYPE prct_cond_external_change_t,   <--This is a hashed table
            is_cond_chg TYPE prct_cond_external_change.
        is_pridoc-ref_guid = ls_orderadm_i_wrk-guid.
        is_pridoc-ref_kind = 'B'.
    is_cond_chg-kbetr = '1.00'.
    is_cond_chg-kpein = '1'.
    is_cond_chg-kmein = 'EA'.
    INSERT is_cond_chg INTO TABLE it_cond_chg.
    is_pridoc-cond_change[] = it_cond_chg[].
            CALL FUNCTION 'CRM_PRIDOC_MAINTAIN_OW'
              EXPORTING
                is_pridoc      = is_pridoc
              EXCEPTIONS
                error_occurred = 1
                OTHERS         = 2.

  • Creation of Popup in BADI

    Hi
    I need to throw a popup in Opportunity while saving with the text '........You cannot save' .It should have a  'OK' button.
    This way i should stop user from saving the application depends on a condition.
    I'm planning to use 'ORDER_SAVE' BADI to show this popup.Could you please tell me how to create this popup?
    Best Regards
    Anil

    Hi,
    To call a popup you need to have access to the window manager which is not available from BADI. So this is something you need to do from the BOL layer itself. EH_ONSAVE should get called.
    Anyway, to create popup you need to create a view in your component or if any of the standard desicion popups suit you, you can use that. You need to create a component usage for the view using a component (give the name of your component) and an interface view (basically a window, can be a new or old reusable window). In your runtime repository create an entry for the window and the custom view inside the window.
    Next design the htm page of the view, whichever way you want. And add a button. This completed the view development.
    Now to call the view as a popup, do like this:
    lv_popup = comp_controller->window_manager->create_popup(
             iv_interface_view_name = 'Windowname'        "#EC NOTEXT
             iv_usage_name          = lv_comp_usage
             iv_title               = lv_title ).
    duplicate_popup->set_on_close_event( iv_view       = view_controller
                                           iv_event_name = on_close_event ).
    Do remember to create an event on_close_event, that you help you navigate back to the main processing.
    Regards
    Prasenjit

  • Identify the Source System in CRM BADI

    Hi,
    I need to write the code in ORDER_SAVE BADI in CRM based on the source system. For example, When i create the quotation in PCUI i need to validate few fields. Suppose i have created quotaton in R/3 and it gets transfer to CRM and i need validate few more fields.
    How do i findout in BADI whether the source system is PCUI or R/3? I have checked the SYST table but no difference in both the case. Anyother way to findout this.
    Thanks in advance.
    Regards,
    Bala.c

    Hello Bala,
    In the ORDERADM_H structure of the CRM_ORDER_READ or in the CRMD_ORDERADM_H table you find a field called LOGICAL_SYSTEM. In that field the RFC destination of the source system (source system = where the order/transaction was created) will be stored.
    For PCUI this field will have the RFC destination of the CRM server itself.
    For R/3 it will have the RFC destination of the R/3 system.
    Hope this helps,
    Reward points if useful!
    Regards,
    Joost

  • Problem in BADI - CRM_ORDER_STATUS

    Hi,
    My requirement goes like this:
    When the Service Request status is set to "CLOSED", I have to do some validation. So, for this I have create BADI Implementation for CRM_ORDER_STATUS and using the method - BEFORE_CHANGE. with filter E0008ZSVR. (E0008 = Closed, ZSVR is status profile for service request).
    However, this method is getting triggered always which means that while displaying the service request, while clicking on the edit button etc. And in this method, I have structure IS_STATUS_WRK has always the status - CLOSED with active. it is not holding the current status. And as per the documentation, it should trigger only, when the status is changed. But, it is getting trigered always.
    Could you please provide me any inputs on this.
    Thanks,
    Sandeep

    you can do your validation in ORDER_SAVE Badi .
    you can read the current status ('CRM_ORDERADM_H_STATUS_READ_OW') value and based on this perform the final validation to allow or Not-allow saving of the document in this status.
    rgds,

  • Updating Item Description in Lead Change Badi(ORD..ADM_I  and ORDERSAVE)

    Hi
    I have to update Item(Product/Product category) Description in Lead duriing Creat/Change.
    1..I can't do same in CRM_ORDERADM_I_BADI as Ited Guid is geting created after coming out of this Badi...
    2..Also in ORDER_SAVE BadI~CHANGE_BEFORE_UPDATE does n't work as it has no export params...
    ALso tried CRM_INTLAY_put_DATA ,But this adding more lines..
    DO we have any way to update the Item(product) description in Memory....in CHANGE_BEFORE_UPDATE method..
    Thanks in Advance...

    Hi Frédéric,
    Finally I got it..ADM_I create is triggering for each line addition...
    But ADM_I change is not triggering on change of same line...
    But Item product obj - change event is triggering on change of item/product.
    Thank you for continous help..
    These 2 together ,I got the solution...
    Trans. Category BUS2000108   Lead
    Execution Time  10    End of Item Processing
    Priority        5
    Object Name     ORDERADM_I                       Administration item
    Event           AFTER_CREATE
    Attribute       <*>
    Function        ZGD_CRM_ON_CREATE_LEAD_I
    Trans. Category BUS20001     CRM Bus Transactions
    Execution Time  1     Immediately
    Priority        1
    Object Name     PRODUCT_I                        Item product data
    Event           AFTER_CHANGE
    Attribute       <*>
    Function        ZGD_CRM_ON_CHANGE_LEAD_I
    Cheers
    Prasad
    Message was edited by: Ranganatha Prasad Kurupati

Maybe you are looking for

  • Multiple crashes, mainly on start-up

    Hi, I have been getting kernel panics, mainly during or directly on completion of start-up but also occasionally a few minutes later. Although this has been going on for a very long time I always try restarting a few times until all appears well and

  • CREATION OF MULTIPLE PAGES IN SMART FORMS

    Hi, I have a smart form in which i need to create 2pages.First will be followed by next and next by next I created the first page and then i created the next page . when i created first page i got a default main window and when i created a second pag

  • 8 lpi in Dot Matrix printer

    Hi all, I have to created a Z format page for a Sapscript form. The format page was created with width 210 MM and heigth 306 MM. The format type was created with my format page as atribute and the device type is EPESCP9   EPSON ESC/P 9-pin printer .

  • Images not displaying in CFDOCUMENT PDF

    Hi there, Has anyone notice any problems with images in dynamic PDF using CFDOCUMENT? I have a site where I create several dynamic PDF document (with images) and all of a sudden, they stop displaying. The only new addition was a SSL for the site. Any

  • UTL_FILE works on Oracle 10 ?

    The following code works on Oracle 9.1.0.2. I would like to know if it will work on Oracle 10. vDiretorio_servidor_entrada varchar2(50):='c:\oracle_temp_dir\entrada'; vUTL_ARQUIVO:=UTL_FILE.fopen(vDiretorio_servidor_entrada,vArquivo,'r', 4000); utl_f