Skip to Content

Unable to Update the Net Price in ME32K using BAPI_CONTRACT_CHANGE

Dear Experts,

I need your help , I have a requirement where I have to modify the existing Agreement in ME32K line item wise for Quantity and Price. I am using the BAPI:- BAPI_CONTRACT_CHANGE for doing the same.

I am able to modify the Target Quantity line Item wise and even add new materials & Qty to the existing Agreement, and my program is also displaying the SUCCESS message in the Output.

But My "Net Price" value is not getting changed... it is displaying the value that we have entered while creating the agreement. After the executing the BAPI I am getting a message of type "I" saying "Change NETPR could not be effected" in the RETURN table in the below format.

I ME 664 Change NETPR could not be effected
0 NETPR ITEM 4

Kindly Help...

Plz find the below code which I am using....

********BAPI Header Data
PURCHASINGDOCUMENT = v_podoc.

HEADER-NUMBER = v_podoc.
HEADER-COMP_CODE = it_excel-COMP_CODE.
HEADER-DOC_TYPE = it_excel-DOC_TYPE.
HEADER-CREAT_DATE = it_excel-CREAT_DATE.
HEADER-PURCH_ORG = it_excel-PURCH_ORG.
HEADER-PUR_GROUP = it_excel-PUR_GROUP.
HEADER-CURRENCY = it_excel-CURRENCY.
HEADER-VENDOR = it_excel-VENDOR.
HEADER-VPER_START = it_excel-VPER_START.
HEADER-VPER_END = it_excel-VPER_END.
********Header Data Change Parameter Outline Agreement
HEADERX-NUMBER = 'X'.
HEADERX-COMP_CODE = 'X'.
HEADERX-DOC_TYPE = 'X'.
HEADERX-CREAT_DATE = 'X'.
HEADERX-PURCH_ORG = 'X'.
HEADERX-PUR_GROUP = 'X'.
HEADERX-CURRENCY = 'X'.
HEADERX-VENDOR = 'X'.
HEADERX-VPER_START = 'X'.
HEADERX-VPER_END = 'X'.

********BAPI Item data
ITEM-ITEM_NO = V_LIN.
ITEM-MATERIAL = IT_EXCEL-MATERIAL.
ITEM-TARGET_QTY = IT_EXCEL-TARGET_QTY.
ITEM-NET_PRICE = IT_EXCEL-NET_PRICE.
APPEND ITEM.
******ITEM DATA CHANGE PARAMETER FOR OUTLINE AGREEMENT
ITEMX-ITEM_NO = V_LIN .
ITEMX-ITEM_NOX = 'X'.
ITEMX-MATERIAL = 'X'.
ITEMX-TARGET_QTY = 'X'.
ITEMX-NET_PRICE = 'X'.
APPEND ITEMX.

*****Account Assignment Data
ACCOUNT-ITEM_NO = V_LIN .
ACCOUNT-QUANTITY = IT_EXCEL-TARGET_QTY.
ACCOUNT-NET_VALUE = IT_EXCEL-NET_PRICE.
append ACCOUNT.

****Change Parameter - Account Assignment Data
ACCOUNTX-ITEM_NO = V_LIN .
ACCOUNTX-ITEM_NOX = 'X'.
ACCOUNTX-QUANTITY = 'X'.
ACCOUNTX-NET_VALUE = 'X'.
append ACCOUNTX.

CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
EXPORTING
PURCHASINGDOCUMENT = PURCHASINGDOCUMENT
HEADER = HEADER
HEADERX = HEADERX
* VENDOR_ADDRESS =
* TESTRUN =
* TECHNICAL_DATA =
IMPORTING
EXP_HEADER = EXP_HEADER
TABLES
ITEM = ITEM
ITEMX = ITEMX
ACCOUNT = ACCOUNT
* ACCOUNTPROFITSEGMENT =
ACCOUNTX = ACCOUNTX
* DELIVERY_ADDRESS =
* ITEM_COND_VALIDITY =
* ITEM_COND_VALIDITYX =
* ITEM_CONDITION =
* ITEM_CONDITIONX =
* ITEM_COND_SCALE_VALUE =
* ITEM_COND_SCALE_QUAN =
* ITEM_TEXT =
* HEADER_TEXT =
* HEAD_COND_VALIDITY =
* HEAD_COND_VALIDITYX =
* HEAD_CONDITION =
* HEAD_CONDITIONX =
* HEAD_COND_SCALE_VAL =
* HEAD_COND_SCALE_QUAN =
* PARTNER =
* PARTNERX =
RETURN = RETURN.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 28, 2012 at 02:48 PM

    For the same set of data try to post data manually. Great chances are that you will get the same message while posting using transaction. If so it might be a config issue or the data is not complete

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Experts,

      i´m facing the same issue now,

      while using the BAPI_CONTRACT_CHANGE

      i get the "Change NETPR could not be effected" message.

      i tried to do it manually in ME32K and the net price get changed with no errors.

      this is the code i´m using for the BAPI:


      call function 'BAPI_CONTRACT_GETDETAIL'

      exporting

      purchasingdocument = gs_ekko-ebeln

      item_data = abap_true

      tables

      item = lt_item_details

      return = lt_return.

      "// Header Data

      ls_header-number = gs_ekko-ebeln.

      ls_header-comp_code = gs_ekko-bukrs.

      ls_header-doc_type = gs_ekko-bsart.

      ls_header-creat_date = gs_ekko-aedat.

      ls_header-purch_org = gs_ekko-ekorg.

      ls_header-pur_group = gs_ekko-ekgrp.

      ls_header-currency = gs_ekko-waers.

      ls_header-vendor = gs_ekko-lifnr.

      ls_header-vper_start = gs_ekko-kdatb.

      ls_header-vper_end = gs_ekko-kdate.

      "// Header Data Change Parameter Outline Agreement

      ls_headerx-number = 'X'.

      ls_headerx-comp_code = 'X'.

      ls_headerx-doc_type = 'X'.

      ls_headerx-creat_date = 'X'.

      ls_headerx-purch_org = 'X'.

      ls_headerx-pur_group = 'X'.

      ls_headerx-vper_start = 'X'.

      ls_headerx-vper_end = 'X'.

      "//BAPI Item data

      read table lt_item_details

      into ls_item_details

      with key item_no = p_ebelp.

      ls_item-item_no = p_ebelp.

      ls_item-net_price = p_netpr.

      append ls_item to lt_item.

      "// ITEM DATA CHANGE PARAMETER FOR OUTLINE AGREEMENT

      ls_itemx-item_no = p_ebelp.

      ls_itemx-item_nox = 'X'.

      ls_itemx-net_price = 'X'.

      append ls_itemx to lt_itemx.

      "// Account Assignment Data

      ls_account-item_no = p_ebelp.

      ls_account-net_value = p_netpr.

      append ls_account to lt_account.

      "// Change Parameter - Account Assignment Data

      ls_accountx-item_no = p_ebelp.

      ls_accountx-item_nox = 'X'.

      ls_accountx-net_value = 'X'.

      append ls_accountx to lt_accountx.

      call function 'BAPI_CONTRACT_CHANGE'

      exporting

      purchasingdocument = gs_ekko-ebeln

      header = ls_header

      headerx = ls_headerx

      tables

      item = lt_item

      itemx = lt_itemx

      account = lt_account

      accountx = lt_accountx

      return = lt_return.

      loop at lt_return into ls_return.

      write:/ ls_return-message.

      endloop.


      can you tell if there is something missing?

      or any other clue?

      thank's in advance

  • avatar image
    Former Member
    Mar 29, 2012 at 07:38 AM

    Hi gopa kumar

    The Net Price is driven by the Condition records.

    In the simplest case you may only have one Gross Price Condition, for example:
    Net Price = Gross Price Condition

    In other, more complicated cases you may have fixed amount Surcharges and/or discounts:
    Net Price = Gross Price Condition + Surcharge Conditions - Discount Conditions

    And even more complicated, you may have Surcharges and Discounts that are percentage-based.

    As you can see, the Net Price is not just a simple database field but is calculated from other values - as such you cannot change the Net Price in isolation.

    If you are certain that you will only ever have one Gross Price Condition then it might be safe to update that Condition which will then update the Net Price but if it is possible for there to be more than one Condition then your logic will be much more complicated...

    You can use BAPI_CONTRACT_GETDETAIL to read the current Contract details, update the Condition record(s) and then use that data to feed BAPI_CONTRACT_CHANGE.

    All the best with it
    Glen

    Add comment
    10|10000 characters needed characters exceeded