Change item condition in BADI order save with crm_order_maintain

Hi all,
   i could update conditions in report but not successful in BADI order save, below is my code in BADI...
   what is the problem maybe ?  Ths
* Get order info.
  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      it_header_guid       = lt_header_guid
      it_requested_objects = lt_requested_objects
    IMPORTING
      et_ORDERADM_I        = lt_ORDERADM_I
      ET_TEXT              = lt_text
      ET_STATUS            = lt_status
      et_pridoc            = et_pridoc
    EXCEPTIONS
      DOCUMENT_NOT_FOUND   = 1
      ERROR_OCCURRED       = 2
      DOCUMENT_LOCKED      = 3
      NO_CHANGE_AUTHORITY  = 4
      NO_DISPLAY_AUTHORITY = 5
      NO_CHANGE_ALLOWED    = 6
      OTHERS               = 7.
read table lt_ORDERADM_I into ls_ORDERADM_I with key ITM_TYPE = 'YTS1'.
  if sy-subrc = 0.
    read table et_pridoc INTO es_pridoc index 1.
    LOOP AT es_pridoc-pric_cond into es_pric_cond where kposn = ls_ORDERADM_I-guid.
      clear is_cond_chg.
      move-corresponding es_pric_cond to is_cond_chg.
      clear is_cond_chg-kbetr.   "  clear the amount
      INSERT is_cond_chg INTO TABLE is_pridoc-cond_change.
    endloop.
    CLEAR: lt_input_field_names.
    ls_input_field_names-fieldname = 'COND_CHANGE'.
    INSERT ls_input_field_names INTO TABLE lt_input_field_names.
    CLEAR: cs_input_fields, ct_input_fields.
    cs_input_fields-ref_guid = ls_ORDERADM_I-guid.
    cs_input_fields-ref_kind = 'B'.
    cs_input_fields-objectname = 'PRIDOC'.
    cs_input_fields-field_names = lt_input_field_names.
    INSERT cs_input_fields INTO table ct_input_fields.
    is_pridoc-ref_guid = ls_ORDERADM_I-guid.
    is_pridoc-ref_kind = 'B'.
    INSERT is_pridoc INTO it_pridoc INDEX 1.
  endif.
  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
      it_pridoc         = it_pridoc
    CHANGING
      ct_input_fields   = ct_input_fields
    EXCEPTIONS
      error_occurred    = 1
      document_locked   = 2
      no_change_allowed = 3
      no_authority      = 4
      OTHERS            = 5.

Try this Function Modul after Order_Maintain
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   =
      IMPORTING
        return = .
Edited by: Richard Brünning on Nov 12, 2009 1:55 PM

Similar Messages

  • How to change pricing Conditions in Sales order in change sales order bapi

    Hi Experts,
    How to change pricing Conditions in Sales order in change sales order bapi.
    I have used the 2 function modules bapi-changesalesorder and sd salesdocument change, But it is creating the new record , instead of changing the existing one, Could please assist regarding the same
    Thanks in Advance .
    NLN

    HI NLN
      I have just tried on my system and managed to overwrite the existing price by passing the following parameters.
      <b>Import Paramters:</b>
         SALESDOCUMENT - Sales Document Number
         ORDER_HEADER_INX - UPDATEFLAG as <b>'U'</b>.
         LOGIC_SWITCH - Import Structure - Pass 'X' to LOGIC_SWITCH-COND_HANDL.
      <b>Tables:</b>
         CONDITIONS_IN - ITM_NUMBER,
                         COND_COUNT, -> Condition counter same as KONV-ZAEHK generally it is <b>'01'</b>
                         COND_TYPE,
                         COND_VALUE,
                         CURRENCY.
         CONDITIONS_INX - ITM_NUMBER,
                          COND_COUNT,
                          COND_TYPE,
                          UPDATEFLAG as <b>'U'</b>,
                          CURRENCY.
       Hope i have clarified your query.
    Kind Regards
    Eswar

  • Change item category in delivery order

    Hi everyone
    Issue: Can not change item category in delivery order.
    Phenomenon:
    1:Create purchase order and receive item based on it. complete invoice verification.
    2:Use MIGO to create return delivery based on material document that is created during above process.
    3:Based on system settings, (Sales org, ship-to party etc), outbound delivery is automatically created in background.
    4:Try to change item category which is already determined during delivery order creation, but it is grayed out.
    Can we change item category in this situation?
    I have checked thread "Number of attempts to change Item Category
    This looks same issue but I still do not know how to control item category in delivery order.
    In material type, is there any place I can configure to allow user to change item category
    in delivery order?
    Please advise.
    Satoru

    Hi,
    Check whether this link would help you,
    [Change item category in delivery|Change item category in delivery]
    It looks you need to use user exit: MV50AFZ1 to acheive your requirement.
    Regards,

  • Change Item Category in Sales Order for KMAT materials

    Hi,
    How can I change item category in sales order/quote for KMAT materials?
    Currently in the sales order/quote, the item category field is grayed out for KMAT/configurable materials and I can change the item category.
    Please help me.
    Sincerely.
    Ketan

    Dear Ketan,
    I hav exactly the same problem.
    Did you finally succeed?
    Thanks.
    Ben.

  • HT5071 I am putting together a book with iBooks Author and all of my pages are numbered (3) how can I change them to an acceding order starting with page one?

    I am putting together a book with iBooks Author and all of my pages are numbered (3) how can I change them to an acceding order starting with page one?

    Sorry I didn't get the tip link right: Change page number style

  • How to Change Item catgegory in sales Order

    Hi all,
    I am creating sales order with reference to sales contract but at the time of sales order we don't have en off stock to deliver to customer , so we have deiced to go for Third party sales process
    But the problem is while creating a sales order with reference to Sales contract the line item of the sales order line item in grad Mode ( Not changeable mode )
    Finally i find out why sales order line item in gray mode Due to Structure Scope Using in item category TAS as D to Explore the BOM In Contract and Sales order  that a reason system gray out sales order line item
    Can any one guide me how sales order line item should be in active mode so i can change the Item category as a TAS third party item category
    Help me regards this
    Thanks
    Rajesh

    Hi all,
    Thanks for replay
    all ready i maintain manual item category in VOV4 the movement i am creating sales order with reference to contract the sales order line item showing in GRAY  mode i cant choose manual item category while i choosing F4 its showing TAS but i cant select that item category because sales order line in gray mode
    and Find out the reason why sales order line item coming in Gray Mode because i am Using Structure Scope D  In Item Category
    to Explore Variant config 
    can any one suggest me how to change the item category
    Thanks
    Ram

  • Unable to Change Item Category in Sales order

    Hi all,
    I am creating sales order with reference to sales contract but at the time of sales order we don't have en off stock to deliver to customer , so we have deiced to Third party sales process
    But the problem is while creating a sales order with reference to Sales contract the line item of the sales order in grad Mode ( Not changeable mode )
    Can any one guide me how sales order line item should be in active mode so i can change the Item category as a TAS third party item category
    Help me regards this
    Thanks
    Rajesh

    hi,
    You can  the item category field (VBAP-PSTYV)  editable , if item is configurable (item category TAC), then change item category to TAS.
    by using include  MV45AFZZ -  FORM USEREXIT_FIELD_MODIFICATION.
    when screen 4001 or 4003.
       IF VBAP-PSTYV = 'TAC'.
               SCREEN-INPUT = 0.
              MODIFY SCREEN.
            ENDIF.

  • Report to list manual changes to conditions in sales orders and invoices

    Hi experts,
    Is there a Standard Report to list the manual changes of pricing conditions in sales orders and invoices?
    Should be a selection on the field KONV-KMPRS.
    Please advice.
    Rgds,
    Pri

    Hi priya,
    In the Sales Order,Select Environment and then Changes to See all Changes made.
    Follow the Same procdure for Invoice also.
    There is no Standard report as such to see the changes.
    Thanks,
    Neelima.

  • Issue while changing Item Category during Sales Order Creation

    Hi,
    Requirement:
    Requirement is to change the item category of Sales Order item while creating the sales order.
    Rule is: If item category is IRAT then it should be changed to IRLN.
    For this, I am using the user exit "USEREXIT_SAVE_DOCUMENT_PREPARE" available in the include MV45AFZZ.
    Issue:
    Using the above mentioned exit, Item category is getting changed to the desired value in the created sales order BUT value of Billing Status (VBUP-FKSAA) which is supposed to get changed is blank.
    For example, Sales order is created from VA01 and item category is changed manually to the value mentioned above, then for the sales order created we have VBUP-FKSAA = 'A'. But when value of Item category is not changed manually and it is changed from the exit, then value of VBUP-FKSAA is blank.
    I have to find a solution which would change the value of Billing Status according to the change in the value of Item Category.
    Please suggest a relevant solution.
    Thanks a lot for responding.
    Abhinav.
    Edited by: Abhinav Jain on Apr 9, 2010 6:47 PM

    Hi Abhinav,
    I have a simmilar problem. In my case I am changing Reason of Rejection in the user-exit, but net value is not getting updated. Did you solve your problem? Any other way to change a field of a sales order item?
    Thanking you in advance,
    Nisha

  • Changing item category in sales order

    Hi,
    For some of the materials in the sales order, the item category is grayed out and I cannot change it.
    I can access the drop down menu and see the various item categories assigned to the item category group.
    How can I change the item category for these materials in the sales order?
    Sincerely,
    Ketan

    hi.
    Ketan
    As u r saying that you can take drop down of the assign item catagory there then only one possibility is left that u have deliver some of the qty from the order. So system is not allowing u to change item catagory.
    Please check have u made any delivery from that sales order.
    if yes then u can not change item catagory.
    Hope this will help you.
    Thx.

  • Condition to calculate order quantity with previous 3 months history of act

    Hi,
    We have a requirement of the report is i need to calculate order quantity (SD) with condition that it should have been produced with previous 3 months with finished goods sales quantity (MM), please suggest suitable formula so that order quantity should be calculated only if it was produced with previos 3 months of finished goods quqntity. Thank you
    Regards,
    Manju

    Hi Geeta,
    Would really appreciate if you can send me sample of condition which we can restrict with order quantity which is produced with 3 months of history of finished goods production. Thank you
    Regrads,
    Manju

  • Changing Price Conditions in Sales Order with SD_SALESDOCUMENT_CHANGE

    Hello there!
    I need to change the value of a price condition in a sale order ;I'm using the f.m.  SD_SALESDOCUMENT_CHANGE.
    It doesnt' work as I want, 'cause it creates an other price conditions instead of just changing the price value of the actual one.
    Waiting for your tips,
    thanks.
    This is how my code looks like:
    PARAMETER: p_vbeln LIKE vbak-vbeln.
    data: st_order_header_inx   TYPE  bapisdhd1x,
            st_conditions LIKE bapicond,
            st_conditionsx LIKE bapicondx,
            tb_conditions TYPE TABLE OF bapicond,
            tb_conditionsx TYPE TABLE OF bapicondx,
            tb_return TYPE TABLE  OF  bapiret2.
    st_order_header_inx-updateflag = 'U'.
      st_conditions-itm_number = '0010'.
      st_conditions-cond_type = 'PR00'.
      st_conditions-cond_updat = 'X'.
      st_conditions-cond_value = '100'. "Value I want to enter
      APPEND st_conditions TO tb_conditions.
    st_conditionsx-itm_number = '0010'.
      st_conditionsx-cond_type = 'PR00'.
      st_conditionsx-updateflag = 'U'.
      st_conditionsx-cond_value = 'X'.
      APPEND ls_conditionsx TO tb_conditionsx.
    CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'
        EXPORTING
        salesdocument                = p_vbeln
          order_header_inx          = st_order_header_inx
        TABLES
          return                           = tb_return
          conditions_in               = tb_conditions
          conditions_inx              = tb_conditionsx  .

    Get the conditions records first from the Sales Order with BAPI BAPISDORDER_GETDETAILEDLIST
    CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
      EXPORTING
        i_bapi_view          = lw_bapi_view
      TABLES
        sales_documents      = lt_order
        order_conditions_out = lt_conditions_out.
    Then populate the conditions internal table with the data that you get from the previous code
    move-corresponding lw_conditions_out to lw_order_conditions_in.
    lw_order_conditions_in-cond_value = '100'   " the value that you want to modify
    APPEND lw_order_conditions_in TO lt_order_conditions_in.
    CLEAR lw_order_conditions_inx.
    lw_order_conditions_inx-itm_number = lv_kposn.
    lw_order_conditions_inx-cond_st_no = lw_conditions_out-cond_st_no.
    lw_order_conditions_inx-cond_count = lw_conditions_out-cond_count.
    lw_order_conditions_inx-cond_type  = lw_conditions_out-cond_type.
    lw_order_conditions_inx-updateflag = 'U'.
    lw_order_conditions_inx-cond_value = lc_x.
    APPEND lw_order_conditions_inx TO lt_order_conditions_inx.
    You didn't populate the fields cond_st_no and -cond_count. Then just call BAPI SD_SALESDOCUMENT_CHANGE to change the Sales order.
    Hope that helps.
    Erwin

  • Change item text in purchase order

    Hi folks,
    I'm trying to change some item text in the purchase order through the BAPI_PO_CHANGE
    with the following test code:
    REPORT zprueba_bapi_po_change.
    DATA:
      itab_text LIKE TABLE OF bapiekpotx,
      wa_text   LIKE bapiekpotx,
      itab_lines LIKE TABLE OF tline,
      wa_lines   LIKE tline,
      itab_items LIKE TABLE OF BAPIEKPO,
      wa_items   LIKE BAPIEKPO.
    DATA: name LIKE thead-tdname,
          id   LIKE thead-tdid,
          object LIKE thead-tdobject,
          v_result LIKE itcer.
    DATA: itab_return LIKE TABLE OF BAPIRET2.
    data: poorder like BAPIEKKO-PO_NUMBER.
    poorder = '4500058923'.
    CALL FUNCTION 'BAPI_PO_GETDETAIL'
      EXPORTING
        purchaseorder                    = poorder
       ITEMS                            = 'X'
    *   ACCOUNT_ASSIGNMENT               = ' '
    *   SCHEDULES                        = ' '
    *   HISTORY                          = ' '
       item_texts                       = 'X'
    *   HEADER_TEXTS                     = ' '
    *   SERVICES                         = ' '
    *   CONFIRMATIONS                    = ' '
    *   SERVICE_TEXTS                    = ' '
    *   EXTENSIONS                       = ' '
    * IMPORTING
    *   PO_HEADER                        =
    *   PO_ADDRESS                       =
    TABLES
    *   PO_HEADER_TEXTS                  =
       PO_ITEMS                         = itab_items
    *   PO_ITEM_ACCOUNT_ASSIGNMENT       =
    *   PO_ITEM_SCHEDULES                =
    *   PO_ITEM_CONFIRMATIONS            =
       po_item_texts                    = itab_text
    *   PO_ITEM_HISTORY                  =
    *   PO_ITEM_HISTORY_TOTALS           =
    *   PO_ITEM_LIMITS                   =
    *   PO_ITEM_CONTRACT_LIMITS          =
    *   PO_ITEM_SERVICES                 =
    *   PO_ITEM_SRV_ACCASS_VALUES        =
    *   RETURN                           =
    *   PO_SERVICES_TEXTS                =
    *   EXTENSIONOUT                     =
    COMMIT WORK AND WAIT.
    name = '600007545900001'.
    id = 'A01'.
    object = 'EKPO'.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
    *   CLIENT                        = SY-MANDT
        id                            = id
        language                      = sy-langu
        name                          = name
        object                        = object
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        =
      TABLES
        lines                         = itab_lines
    * EXCEPTIONS
    *   ID                            = 1
    *   LANGUAGE                      = 2
    *   NAME                          = 3
    *   NOT_FOUND                     = 4
    *   OBJECT                        = 5
    *   REFERENCE_CHECK               = 6
    *   WRONG_ACCESS_TO_ARCHIVE       = 7
    *   OTHERS                        = 8
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT itab_lines INTO wa_lines.
      CLEAR wa_text.
      wa_text-po_number = poorder.
      wa_text-po_item = '00001'.
      wa_text-text_form = wa_lines-tdformat.
      wa_text-text_line = wa_lines-tdline.
      wa_text-text_id = 'F03'.
      APPEND wa_text TO itab_text.
    ENDLOOP.
    SORT itab_text BY po_item text_id.
    CALL FUNCTION 'BAPI_PO_CHANGE'
      EXPORTING
        purchaseorder                = poorder
    *   POHEADER                     =
    *   POHEADERX                    =
    *   POADDRVENDOR                 =
    *   TESTRUN                      =
    *   MEMORY_UNCOMPLETE            =
    *   MEMORY_COMPLETE              =
    *   NO_MESSAGING                 =
    *   NO_MESSAGE_REQ               =
    *   NO_AUTHORITY                 =
    *   NO_PRICE_FROM_PO             =
    * IMPORTING
    *   EXPHEADER                    =
    TABLES
       RETURN                       = itab_return
    *   POITEM                       =
    *   POITEMX                      =
    *   POADDRDELIVERY               =
    *   POSCHEDULE                   =
    *   POSCHEDULEX                  =
    *   POACCOUNT                    =
    *   POACCOUNTPROFITSEGMENT       =
    *   POACCOUNTX                   =
    *   POCONDHEADER                 =
    *   POCONDHEADERX                =
    *   POCOND                       =
    *   POCONDX                      =
    *   POLIMITS                     =
    *   POCONTRACTLIMITS             =
    *   POSERVICES                   =
    *   POSRVACCESSVALUES            =
    *   POSERVICESTEXT               =
    *   EXTENSIONIN                  =
    *   EXTENSIONOUT                 =
    *   POTEXTHEADER                 =
       POTEXTITEM                   = itab_text
    *   POPARTNER                    =
    COMMIT WORK AND WAIT.
    However this code isn't updating the text. Does anyone could tell me what i'm missing?
    Thanks for your help.
    Kind Regards,
    Gilberto Li

    Hi,
    Please check this code..It worked for me..Instead of 00001 try giving 00010
    PARAMETERS: p_ebeln TYPE ebeln OBLIGATORY.
    PARAMETERS: p_text(50) OBLIGATORY.
    PARAMETERS: p_textid TYPE bapimepotext-text_id OBLIGATORY.
    DATA:
            lt_poitem         LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,
            lt_poitemx        LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,
            lt_return         LIKE bapiret2      OCCURS 0 WITH HEADER LINE,
            lt_bapi_itemtext  LIKE bapimepotext OCCURS 0 WITH HEADER LINE.
    <b>lt_poitem-po_item = '00010'.</b>
    APPEND lt_poitem.
    <b>lt_poitem-po_item = '00010'.</b>
    APPEND lt_poitem.
    lt_bapi_itemtext-po_number = p_ebeln.
    <b>lt_bapi_itemtext-po_item   = '00010'.</b>
    lt_bapi_itemtext-text_id   = p_textid.
    lt_bapi_itemtext-text_line = p_text.
    APPEND lt_bapi_itemtext.
    call the BAPI.
    CALL FUNCTION 'BAPI_PO_CHANGE'
         EXPORTING
              purchaseorder = p_ebeln
         TABLES
              return        = lt_return
              poitem        = lt_poitem
              poitemx       = lt_poitemx
              potextitem    = lt_bapi_itemtext.
    LOOP AT lt_return WHERE type = 'A' OR type  = 'E'.
      EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
      WRITE: / 'Error'.
    ELSE.
      COMMIT WORK.
      WRITE: / 'Success'.
    ENDIF.
    Thanks,
    Naren

  • Best Practice - Check/React to Conditions Before Sales Order Save

    I am saving, for discussionu2019s sake, what is essentially a sales order. 
    Component: /ALMGT/BT115H_SLSO
    View: SOHOverView
    When the 'Save' is pushed, we want to do some error checking/handling  u2013 very simple stuff, like
    If attr1 is initial and  attr2 > 0
        Issue message
       set attr_status to u2018Situation1u2019 
    endif .
    It seems like I can just redefine the eh_onsave() method, but I wanted to see if there is a more elegant or best practice methodology for doing this.
    Thanks...
    ...Mike
    Weu2019re running  FRM ( [Fundraising  Management|http://www.sap.com/services/portfolio/customdev/brochures/index.epx] ) u2013 SAP Custom Development u2013 on top of CRM 7.0

    Mike,
    Good to see you here again.  The best approach is actually to implement this logic below the UI layer in the oner order layer instead.  Based on the component it looks like you are using a business transaction, which means you can use the BADI ORDER_SAVE to trigger the error.
    Do a search in the CRM General Forum on how to use this.  Now I'm not familiar with that solution, but the techniques for manipulating transactions and using the BADI's available should be the same if the data is being saved as business transactions inside of CRM.
    Take care,
    Stephen

  • Change Item Category in Sales Order

    Dear Sir,
    We require Item Category field to be editable in VA02. Ours is MTO scenario when we enter Material in SO the Item Category fields gets grey out we require the same to be editable. We have also maintianed the MItC in Item category determination in VOV4 still the fields gets greyed out.
    Please guide.
    Regards,
    Mahendra

    Hi
    Item category will only be in editable mode  in VA02 unless and until the delivery is not made or partial delivery has been done
    Manual item category is to change manually the automatic determination done by the system and not to input manually when there is no automatic determination
    Even make to order item category TAK is in editable mode in VA02 transaction
    May be something else in your setup controlling this
    Regards
    raja

Maybe you are looking for

  • How can I get my Indesign script to apply to all pages in the document?

    My script (java) shown below will only apply to the first page of the document. How can i get it to apply to all pages of my document? What am I missing? Thanks. scirpt: myDocument = app.activeDocument with (myDocument.pages.item(0).marginPreferences

  • What are the standard datasource that are available in Solution manager?

    Hi All,   Can you please tel me which datasource will contain data about SLA and incident management.  The users are raising issues in SOLAR_*** Tcode and I dont know where it is getting updated. Please reply me asap. Thanks in advance! Regards, Rama

  • Problem with 10.2.0.5 patch on Windows 2008 Server R2 64bit

    Hello I have HP server with Windows 2008 Server R2 64bit. I installed latest 64-bit version of Oracle Database 10.2.0.4 and everything works fine and later installed the patch 10.2.0.5 (64 bits) as the Oracle maintains that with the R2 version of the

  • One to one Mapping Issue

    TopLink Version: 10.1.3.5.0.090715 JBOSS: 5.1.0 JDK: 1.6.0.17 Database: Microsoft Sql Server 2005 Problem Description: I have a table (TestTable1). This table has a PK that is a number from a sequence table as well as a 'SystemAssignedKey' that uses

  • IOS Update 5.1.1 and now slide shows play on LOCKED iPad.  How to stop it??

    I had made a backup before installing the update.  I installed the update, then noticed that the slide show button was visible on the lock screen.  You can press it and it plays your images.  There does not appear to be a way to turn off this lame 'f