Skip to Content

BAPI_CONTRACT_CHANGE condition validity period and amount change.

Feb 10, 2017 at 10:33 AM


avatar image


I am using BAPI- ‘BAPI_CONTRACT_CHANGE’ to add/change condition validity and amount of contract (ME32K).

While uploading validity period less than system date BAPI is adding item condition validity from and to along with amount and showing the same amount in Agreement Items. But while uploading validity period in future date BAPI is doing the same as above except the amount in Agreement Items which is showing 0.00.

I am adding validity period of 15.02.2017 to 31.12.9999 with amount 50.00. As system date is 10.02.2017 so the validity lies in the existing period of 06.02.2017 to 14.02.2017 so the amount 10.00 should display in Agreement Items.

Below is the code i am using For the BAPI.

Kindly suggest the solution how to show the amount from existing validity period in line item level while uploading future validity period and amount.

READ TABLE it_a016 INTO wa_a016 WITH KEY evrtn = wa_upload-evrtn
evrtp = wa_upload-evrtp BINARY SEARCH.IF sy-subrc EQ 0.
ls_item_cond_validity_upd-valid_from = wa_upload-datab.
ls_item_cond_validity_upd-valid_to = wa_upload-datbi.
ls_item_cond_validity_upd-item_no = wa_upload-evrtp.
ls_item_cond_validity_upd-serial_id = wa_a016-knumh.
APPEND ls_item_cond_validity_upd TO lt_item_cond_validity_upd.CLEAR ls_item_cond_validity_upd.

ls_item_cond_validityx_upd-valid_from = 'X'.
ls_item_cond_validityx_upd-valid_to = 'X'.
ls_item_cond_validityx_upd-item_no = wa_upload-evrtp.
ls_item_cond_validityx_upd-serial_id = wa_a016-knumh.
APPEND ls_item_cond_validityx_upd TO lt_item_cond_validityx_upd.CLEAR ls_item_cond_validityx_upd.
READ TABLE it_konp INTO wa_konp WITH KEY knumh = wa_a016-knumh BINARY SEARCH.* kopos = wa_upload-evrtp+3(2) BINARY SEARCH.IF sy-subrc EQ 0.
wa_konp-kopos = wa_konp-kopos + 1.
ls_item_condition_upd-item_no = wa_upload-evrtp.
ls_item_condition_upd-serial_id = wa_a016-knumh.
ls_item_condition_upd-cond_count = wa_konp-kopos.
ls_item_condition_upd-cond_type = wa_konp-kschl.
ls_item_condition_upd-scale_type = 'A'.
ls_item_condition_upd-scale_base_ty = 'C'.
ls_item_condition_upd-scale_unit = 'L'.
ls_item_condition_upd-change_id = 'I'.
ls_item_condition_upd-calctypcon = 'C'.
IF wa_upload-netpr IS NOT INITIAL.
ls_item_condition_upd-cond_value = wa_upload-netpr.ENDIF.READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln = wa_upload-evrtn BINARY SEARCH.IF sy-subrc EQ 0.READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = wa_upload-evrtn
ebelp = wa_upload-evrtp BINARY SEARCH.IF sy-subrc EQ 0.

ls_item_condition_upd-currency = wa_ekko-waers.
ls_item_condition_upd-cond_p_unt = 1.
ls_item_condition_upd-cond_unit = wa_ekpo-meins.
ls_item_condition_upd-base_uom = wa_ekpo-meins.

APPEND ls_item_condition_upd TO lt_item_condition_upd.CLEAR ls_item_condition_upd.

ls_item_condition_updx-item_no = wa_ekpo-ebelp.
ls_item_condition_updx-serial_id = wa_a016-knumh.
ls_item_condition_updx-cond_count = wa_konp-kopos.
ls_item_condition_updx-cond_type = 'X'.
ls_item_condition_updx-scale_type = 'X'.
ls_item_condition_updx-scale_base_ty = 'X'.
ls_item_condition_updx-scale_unit = 'X'.
ls_item_condition_updx-cond_value = 'X'.
ls_item_condition_updx-currency = 'X'.
ls_item_condition_updx-cond_p_unt = 'X'.
ls_item_condition_updx-cond_unit = 'X'.
ls_item_condition_updx-base_uom = 'X'.
APPEND ls_item_condition_updx TO lt_item_condition_updx.CLEAR ls_item_condition_updx.

purchasingdocument = lv_con_noTABLES* item = lt_item_upd* itemx = lt_itemx_upd
item_cond_validity = lt_item_cond_validity_upd
item_cond_validityx = lt_item_cond_validityx_upd
item_condition = lt_item_condition_upd
item_conditionx = lt_item_condition_updx* item_cond_scale_quan = lt_item_cond_scale_quan_updreturn = lt_bapi_return.

Thanks and Regards,

K N Jenamani

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Jürgen L
Feb 15, 2017 at 01:12 PM

I recommend to read the KBA 1970016 - BAPI_CONTRACT_CHANGE : Unexpected item condition record validity periods are created

and its referenced OSS notes. The KBA explains how conditions are splittet, what the standard design is and what are the limitations of this BAPI

10 |10000 characters needed characters left characters exceeded