2016 Jul 13 9:50 PM
Hello
Need help on adding a new Condition Validity Period (ME32K) I'm using 'BAPI_CONTRACT_CHANGE filling table ITEM_COND_VALIDITY and ITEM_CONDITION and setting CHANGE_ID = 'I' but I get the following error message: Internal error T IVAKE F IVAKE_INSERT I MV13F01
I also fill the corresponding "X" tables. Maybe I cannot add Validity Periods using BAPI_CONTRACT_CHANGE? Any help would be greatly appreciated.
Thanks
Gary
2016 Jul 15 10:52 AM
Dear Garry,
Sorry, i was running the program which i gave in the previous email, not in the latest sap version and ran successfully. My current sap version is SAP ECC 6.0 EHP 0.
But I have searched and read other scn, It would be the overlapping validity date. May be my solution which i could give to you are :
1. Update the latest validity date record which is :
07.19.2016 to 12.31.9999
to be
07/19/2016 to 07/31/2016
2. Insert the new validity date record which is :
08/01/2016 to 12/31/9999
I refer the below link :
1. 901718 - Conditions: Inconsistencies for material listing/exclusion
2. https://scn.sap.com/thread/3756719
Regards,
Yance
2016 Jul 14 4:41 AM
Dear Gary,
May be you can try the below logic :
DATA : lt_ekpo TYPE STANDARD TABLE OF ekpo.
DATA : lt_item_cond_validity TYPE STANDARD TABLE OF bapimeoutvalidity,
lt_item_cond_validityx TYPE STANDARD TABLE OF bapimeoutvalidityx,
lt_item_condition TYPE STANDARD TABLE OF bapimeoutcondition,
lt_item_conditionx TYPE STANDARD TABLE OF bapimeoutconditionx,
lt_item_cond_scale_quan TYPE STANDARD TABLE OF bapimeoutitemscalequan,
lt_return TYPE STANDARD TABLE OF bapiret2.
DATA : lx_ekpo TYPE ekpo.
DATA : lx_item_cond_validity TYPE bapimeoutvalidity,
lx_item_cond_validityx TYPE bapimeoutvalidityx,
lx_item_condition TYPE bapimeoutcondition,
lx_item_conditionx TYPE bapimeoutconditionx,
lx_item_cond_scale_quan TYPE bapimeoutitemscalequan.
DATA : lx_return TYPE bapiret2.
DATA : ld_purchasingdocument TYPE bapimeoutheader-number,
ld_error TYPE char1.
ld_purchasingdocument = '0141000000'.
SELECT *
INTO TABLE lt_ekpo
FROM ekpo
WHERE ebeln = ld_purchasingdocument.
LOOP AT lt_ekpo INTO lx_ekpo.
lx_item_cond_validity-item_no = lx_ekpo-ebelp.
lx_item_cond_validity-valid_from = '20160801'.
lx_item_cond_validity-valid_to = '20161231'.
APPEND lx_item_cond_validity TO lt_item_cond_validity.
lx_item_cond_validityx-item_no = lx_ekpo-ebelp.
lx_item_cond_validityx-item_nox = 'X'.
lx_item_cond_validityx-valid_from = 'X'.
lx_item_cond_validityx-valid_to = 'X'.
APPEND lx_item_cond_validityx TO lt_item_cond_validityx.
lx_item_condition-item_no = lx_ekpo-ebelp.
lx_item_condition-cond_count = '2'.
lx_item_condition-cond_type = 'PB00'.
lx_item_condition-scale_type = 'A'.
lx_item_condition-calctypcon = 'C'.
lx_item_condition-cond_value = '2500'.
lx_item_condition-currency = 'USD'.
lx_item_condition-currency_iso = 'USD'.
*NUMERATOR
*DENOMINATOR
lx_item_condition-cond_p_unt = 1.
lx_item_condition-cond_unit = 'UNT'.
lx_item_condition-cond_unit_iso = 'UNT'.
lx_item_condition-base_uom = 'UNT'.
lx_item_condition-base_uom_iso = 'UNT'.
*LOWERLIMIT
*UPPERLIMIT
lx_item_condition-vendor_no = '0000200000'.
lx_item_condition-change_id = 'I'.
APPEND lx_item_condition TO lt_item_condition.
lx_item_conditionx-item_no = lx_ekpo-ebelp.
lx_item_conditionx-cond_count = '2'.
lx_item_conditionx-item_nox = 'X'.
lx_item_conditionx-cond_countx = 'X'.
lx_item_conditionx-cond_type = 'X'.
lx_item_conditionx-scale_type = 'X'.
lx_item_conditionx-calctypcon = 'X'.
lx_item_conditionx-cond_value = 'X'.
lx_item_conditionx-currency = 'X'.
lx_item_conditionx-currency_iso = 'X'.
lx_item_conditionx-cond_unit = 'X'.
lx_item_conditionx-cond_unit_iso = 'X'.
lx_item_conditionx-cond_p_unt = 'X'.
lx_item_conditionx-base_uom = 'X'.
lx_item_conditionx-base_uom_iso = 'X'.
lx_item_conditionx-vendor_no = 'X'.
APPEND lx_item_conditionx TO lt_item_conditionx.
* lx_item_cond_scale_quan-item_no = lx_ekpo-ebelp.
* lx_item_cond_scale_quan-cond_count = '2'.
**LINE_NO
* lx_item_cond_scale_quan-scale_base_qty = 20000.
* lx_item_cond_scale_quan-cond_value = 2500.
* APPEND lx_item_cond_scale_quan TO lt_item_cond_scale_quan.
ENDLOOP.
CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
EXPORTING
purchasingdocument = ld_purchasingdocument
* HEADER =
* HEADERX =
* VENDOR_ADDRESS =
* TESTRUN =
* TECHNICAL_DATA =
* IMPORTING
* EXP_HEADER =
TABLES
* ITEM =
* ITEMX =
* ACCOUNT =
* ACCOUNTPROFITSEGMENT =
* ACCOUNTX =
* DELIVERY_ADDRESS =
item_cond_validity = lt_item_cond_validity
item_cond_validityx = lt_item_cond_validityx
item_condition = lt_item_condition
item_conditionx = lt_item_conditionx
* ITEM_COND_SCALE_VALUE =
item_cond_scale_quan = lt_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 =
* RELEASE_DOCU =
* EXTENSIONIN =
* EXTENSIONOUT =
return = lt_return
.
CLEAR ld_error.
LOOP AT lt_return TRANSPORTING NO FIELDS WHERE type = 'E' OR type = 'A'.
ld_error = 'X'.
ENDLOOP.
IF ld_error IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = lx_return.
ENDIF.
Regards,
Yance
2016 Jul 14 1:16 PM
Hello Yance
Thanks so much for responding to my post. I tried your code replacing Purchasing Document and Vendor number with my data and I still getting the following:
Internal error: T IVAKE F IVAKE_INSERT I MV120F01
2016 Jul 14 1:18 PM
Correction I typed the last part of the internal error message incorrectly it should be MV130F0I not MV120F0I
2016 Jul 14 1:49 PM
Dear Gary,
I have seen that error message in MV130F0I. The error will be happened if the valid date from and valid date to are the same with the existing record. Please make sure for the valid date from and valid date to.
Regards,
Yance
2016 Jul 14 2:40 PM
I tried From Date 08/01/2016 and To Date 12/31/2016 still getting that error. Attached are all the Validity Periods that currently exist for Purchasing Doc I'm trying to update .
2016 Jul 15 10:52 AM
Dear Garry,
Sorry, i was running the program which i gave in the previous email, not in the latest sap version and ran successfully. My current sap version is SAP ECC 6.0 EHP 0.
But I have searched and read other scn, It would be the overlapping validity date. May be my solution which i could give to you are :
1. Update the latest validity date record which is :
07.19.2016 to 12.31.9999
to be
07/19/2016 to 07/31/2016
2. Insert the new validity date record which is :
08/01/2016 to 12/31/9999
I refer the below link :
1. 901718 - Conditions: Inconsistencies for material listing/exclusion
2. https://scn.sap.com/thread/3756719
Regards,
Yance
2016 Jul 15 3:59 PM
That worked for the dates. Now need to get amount loaded for my new validation period. I fill Item_condition and Item_conditionx but looks like it is pulling previous amount, How do I get Amount to be 8 for new validation rcd?
2016 Jul 15 4:43 PM
Dear Gary,
Glad to hear that It worked.
To populate the amount that you should the parameter item_condition and item_conditionx. for example like the below :
lx_item_condition-item_no = lx_ekpo-ebelp.
lx_item_condition-cond_count = '2'. ->the last record + 1, If you insert the new record
if modify the existing record, get cond_count from table KONP
lx_item_condition-cond_type = 'PB00'. ->depends on your data
lx_item_condition-scale_type = 'A'. ->depends on your data
lx_item_condition-calctypcon = 'C'. ->depends on your data
lx_item_condition-cond_value = '2500'. -> put amount in here
lx_item_condition-currency = 'USD'. ->depends on your data
lx_item_condition-currency_iso = 'USD'. ->depends on your data
lx_item_condition-cond_p_unt = 1. ->depends on your data
lx_item_condition-cond_unit = 'EA'. ->depends on your data
lx_item_condition-cond_unit_iso = 'EA'. ->depends on your data
lx_item_condition-base_uom = 'EA'. ->depends on your data
lx_item_condition-base_uom_iso = 'EA'. ->depends on your data
lx_item_condition-vendor_no = '0000200000'. ->depends on your data
lx_item_condition-change_id = 'I'. -> I for new record, U for existing record
APPEND lx_item_condition TO lt_item_condition.
lx_item_conditionx-item_no = lx_ekpo-ebelp.
lx_item_conditionx-cond_count = '2'.
lx_item_conditionx-item_nox = 'X'.
lx_item_conditionx-cond_countx = 'X'.
lx_item_conditionx-cond_type = 'X'.
lx_item_conditionx-scale_type = 'X'.
lx_item_conditionx-calctypcon = 'X'.
lx_item_conditionx-cond_value = 'X'.
lx_item_conditionx-currency = 'X'.
lx_item_conditionx-currency_iso = 'X'.
lx_item_conditionx-cond_unit = 'X'.
lx_item_conditionx-cond_unit_iso = 'X'.
lx_item_conditionx-cond_p_unt = 'X'.
lx_item_conditionx-base_uom = 'X'.
lx_item_conditionx-base_uom_iso = 'X'.
lx_item_conditionx-vendor_no = 'X'.
APPEND lx_item_conditionx TO lt_item_conditionx.
I hope that It will help you.
Regards,
Yance
2016 Jul 15 7:44 PM
Dear Yance
Thanks so much for all your help, I'm so close. I tired filling item & itemx condition tables like you suggested but still not updating qty. It creates a validation rcd but with wrong qty. I have 19 Condition rcds for a particular Contract / item. Do I need to have all Condition rcds plus rcd I want to add in item condition table?
2016 Jul 16 3:51 AM
Dear Gary,
Do you ask me for updating amount or quantity ? My last email was to update the amount.
And Now is that you ask me to update the quantity, so my suggestion is
If your requirement is to have the contract based on quantity. please don't forget to put the below logic :
lx_item_condition-scale_type = 'A'. "Base scale
lx_item_condition-calctypcon = 'C'. "Quantity
Where do you wanna update the quantity ? Is it in line item or scale condition ?
If you wanna update the quantity in line item :
lx_item-target_qty = "fill in this..
If you wanna update the quantity in the scale condition :
lx_item_cond_scale_quan-item_no = lx_ekpo-ebelp.
lx_item_cond_scale_quan-cond_count = '2'.
*LINE_NO
lx_item_cond_scale_quan-scale_base_qty = 20000.
lx_item_cond_scale_quan-cond_value = 2500.e
APPEND lx_item_cond_scale_quan TO lt_item_cond_scale_quan.
I hope that it works for you..
Please try to search in google for the other reference (sap BAPI_CONTRACT_CHANGE), it will help you so much.
Regards,
Yance
2016 Jul 19 3:19 PM
I searched and searched on internet and cannot figure what I'm doing wrong when I use BAPI_CONTRACT_CHANGE to add a condition Record. Here is what is happening, on Item Overview screen for Item 80 the Net Price is changed to 11 which is correct. see below
But on the Condition screen amount should be 11 but it is 3. The amount of 3 is coming from the last condition record. How do I get the correct amount on this screen?
on the
2016 Jul 20 10:49 AM
Dear Gary,
Have you tried the below condition ?
lx_item_cond_validity-item_no = '00080'.
lx_item_cond_validity-valid_from = '20130410'.
lx_item_cond_validity-valid_to = '9991231'.
APPEND lx_item_cond_validity TO lt_item_cond_validity.
lx_item_cond_validityx-item_no = '00080'.
lx_item_cond_validityx-item_nox = 'X'.
lx_item_cond_validityx-valid_from = 'X'.
lx_item_cond_validityx-valid_to = 'X'.
APPEND lx_item_cond_validityx TO lt_item_cond_validityx.
lx_item_condition-item_no = '00080'.
lx_item_condition-cond_count = '2'. ->your sequence
lx_item_condition-cond_type = 'PB00'.
lx_item_condition-scale_type = 'A'.
lx_item_condition-calctypcon = 'C'.
lx_item_condition-cond_value = '11'.
lx_item_condition-currency = 'USD'.
lx_item_condition-currency_iso = 'USD'.
lx_item_condition-cond_p_unt = 1.
lx_item_condition-cond_unit = 'EA'.
lx_item_condition-cond_unit_iso = 'EA'.
lx_item_condition-base_uom = 'EA'.
lx_item_condition-base_uom_iso = 'EA'.
lx_item_condition-change_id = 'U'.
APPEND lx_item_condition TO lt_item_condition.
lx_item_conditionx-item_no = '00080'. ->your sequence
lx_item_conditionx-cond_count = '2'.
lx_item_conditionx-item_nox = 'X'.
lx_item_conditionx-cond_countx = 'X'.
lx_item_conditionx-cond_type = 'X'.
lx_item_conditionx-scale_type = 'X'.
lx_item_conditionx-calctypcon = 'X'.
lx_item_conditionx-cond_value = 'X'.
lx_item_conditionx-currency = 'X'.
lx_item_conditionx-currency_iso = 'X'.
lx_item_conditionx-cond_unit = 'X'.
lx_item_conditionx-cond_unit_iso = 'X'.
lx_item_conditionx-cond_p_unt = 'X'.
lx_item_conditionx-base_uom = 'X'.
lx_item_conditionx-base_uom_iso = 'X'.
APPEND lx_item_conditionx TO lt_item_conditionx.
I tried in my system, It worked.
How about you ? Is it returned Error?
Regards,
Yance
2016 Jul 20 2:05 PM
Thanks so much for all your help Yance.
The code works great when I want to do a change, but I can not get the add to work (create a new condition record) When I do an add I have to adjust last record in Validity Table that has a from date of 12/31/9999 to 9/01/2013 then my new date range for new rcd will be 9/02/2013 - 12/31/9999 otherwise I get an duplicate error message when I run 'BAPI_CONTRACT_CHANGE'. My Item Validity and Condition tables have all ITEM_NO (00080) rcds. Not sure if suppose to fill SERIAL_ID for my new rcd and not sure what I should enter so I leave it blank. I set CHANGE_ID to 'I'. for insert. This seems to work but amount on Overview Screen and Condition Price not matching.
Gary
2016 Jul 20 2:58 PM
Dear Gary Morman,
I think that you just combined the change and insert indicator.
For edit the last record :
lx_item_cond_validity-item_no = '00080'.
lx_item_cond_validity-serial_id = A068-KNUMH ->please query first
lx_item_cond_validity-valid_from = '20130410'.
lx_item_cond_validity-valid_to = '20130509'.
APPEND lx_item_cond_validity TO lt_item_cond_validity.
lx_item_cond_validityx-item_no = '00080'.
lx_item_cond_validity-serial_id = A068-KNUMH ->please query first
lx_item_cond_validityx-item_nox = 'X'.
lx_item_cond_validityx-valid_from = 'X'.
lx_item_cond_validityx-valid_to = 'X'.
APPEND lx_item_cond_validityx TO lt_item_cond_validityx.
lx_item_condition-item_no = '00080'.
lx_item_condition-serial_id = A068-KNUMH ->please query first
lx_item_condition-cond_count = '1'. ->your sequence
lx_item_condition-cond_type = 'PB00'.
lx_item_condition-scale_type = 'A'.
lx_item_condition-calctypcon = 'C'.
lx_item_condition-cond_value = '11'.
lx_item_condition-currency = 'USD'.
lx_item_condition-currency_iso = 'USD'.
lx_item_condition-cond_p_unt = 1.
lx_item_condition-cond_unit = 'EA'.
lx_item_condition-cond_unit_iso = 'EA'.
lx_item_condition-base_uom = 'EA'.
lx_item_condition-base_uom_iso = 'EA'.
lx_item_condition-change_id = 'U'.
APPEND lx_item_condition TO lt_item_condition.
lx_item_conditionx-item_no = '00080'. ->your sequence
lx_item_conditionx-serial_id = A068-KNUMH ->please query first
lx_item_conditionx-cond_count = '1'.
lx_item_conditionx-item_nox = 'X'.
lx_item_conditionx-cond_countx = 'X'.
lx_item_conditionx-cond_type = 'X'.
lx_item_conditionx-scale_type = 'X'.
lx_item_conditionx-calctypcon = 'X'.
lx_item_conditionx-cond_value = 'X'.
lx_item_conditionx-currency = 'X'.
lx_item_conditionx-currency_iso = 'X'.
lx_item_conditionx-cond_unit = 'X'.
lx_item_conditionx-cond_unit_iso = 'X'.
lx_item_conditionx-cond_p_unt = 'X'.
lx_item_conditionx-base_uom = 'X'.
lx_item_conditionx-base_uom_iso = 'X'.
APPEND lx_item_conditionx TO lt_item_conditionx.
For Insert the new record :
lx_item_cond_validity-item_no = '00080'.
lx_item_cond_validity-serial_id = ''.
lx_item_cond_validity-valid_from = '20130510'.
lx_item_cond_validity-valid_to = '99991231'.
APPEND lx_item_cond_validity TO lt_item_cond_validity.
lx_item_cond_validityx-item_no = '00080'.
lx_item_cond_validityx-serial_id = ''.
lx_item_cond_validityx-item_nox = 'X'.
lx_item_cond_validityx-valid_from = 'X'.
lx_item_cond_validityx-valid_to = 'X'.
APPEND lx_item_cond_validityx TO lt_item_cond_validityx.
lx_item_condition-item_no = '00080'.
lx_item_condition-serial_id = ''.
lx_item_condition-cond_count = '1'.
lx_item_condition-cond_type = 'PB00'.
lx_item_condition-scale_type = 'A'.
lx_item_condition-calctypcon = 'C'.
lx_item_condition-cond_value = '12'.
lx_item_condition-currency = 'USD'.
lx_item_condition-currency_iso = 'USD'.
lx_item_condition-cond_p_unt = 1.
lx_item_condition-cond_unit = 'EA'.
lx_item_condition-cond_unit_iso = 'EA'.
lx_item_condition-base_uom = 'EA'.
lx_item_condition-base_uom_iso = 'EA'.
lx_item_condition-change_id = 'I'.
APPEND lx_item_condition TO lt_item_condition.
lx_item_conditionx-item_no = '00080'.
lx_item_conditionx-serial_id = ''.
lx_item_conditionx-cond_count = '1'.
lx_item_conditionx-item_nox = 'X'.
lx_item_conditionx-cond_countx = 'X'.
lx_item_conditionx-cond_type = 'X'.
lx_item_conditionx-scale_type = 'X'.
lx_item_conditionx-calctypcon = 'X'.
lx_item_conditionx-cond_value = 'X'.
lx_item_conditionx-currency = 'X'.
lx_item_conditionx-currency_iso = 'X'.
lx_item_conditionx-cond_unit = 'X'.
lx_item_conditionx-cond_unit_iso = 'X'.
lx_item_conditionx-cond_p_unt = 'X'.
lx_item_conditionx-base_uom = 'X'.
lx_item_conditionx-base_uom_iso = 'X'.
APPEND lx_item_conditionx TO lt_item_conditionx.
I hope that will help you.
Regards,
Yance
2016 Jul 20 4:19 PM
Thanks for all your help. I did what you suggested but now getting the following error, does this make any sense to you?
These are the parms I'm passing in, do I need to add HEAD structure to 'BAPI_CONTRACT_CHANGE'. I did add HEADER and HEADERx on a previous try but still got the same error unless not filling fields correctly.
2016 Jul 20 6:44 PM
Thanks Yance for all your help and patience with me, your code worked I just had some data discrepancies to work out.
Gary Morman
2016 Jul 20 10:10 PM
I thought I had it working using code for update and insert posted earlier but the Amount in the Price Condition (PB00) is not getting the value I have coded in the Insert part of the code. The Net Price on the Item Over View screen is getting set to the correct value but the Amount in the Condition Rcd (PB00) is using the previous PB00 value.
2016 Jul 21 2:13 PM
Dear Gary,
Could I see your coding in how you populate the bapi parameters?
Regards,
Yance
2016 Jul 21 3:26 PM
I think I found the problem but not sure how to fix? When I just do an update CHANGE_ID = 'U' change validity date from 9999/1231 to 20101229 it automatically creates a second record 20101230 - 99991231. But the SERIAL_ID are visa versa
That is why qty is not correct. The VALID_TO = 99991231 should have SERIAL_ID = 0000783712. Any ideas what I need to do?
2016 Jul 21 3:50 PM
Here is my code. Having trouble getting it formatted hope you can read it or let me know how to post large amount of code
DATA : ld_purchasingdocument TYPE bapimeoutheader-number, ld_error TYPE char1, l_date TYPE datum. DATA: lt_val TYPE TABLE OF bapimeoutvalidity, ls_val TYPE bapimeoutvalidity, lt_valx TYPE TABLE OF bapimeoutvalidityx, ls_valx TYPE bapimeoutvalidityx, lt_con TYPE TABLE OF bapimeoutcondition, ls_con TYPE bapimeoutcondition, lt_conx TYPE TABLE OF bapimeoutconditionx, ls_conx TYPE bapimeoutconditionx, lt_return TYPE TABLE OF bapiret2, ls_return TYPE bapiret2, ls_head TYPE bapimeoutheader, lt_item TYPE TABLE OF bapimeoutitem, lt_itemx TYPE TABLE OF bapimeoutitemx, ls_itemx TYPE bapimeoutitemx. break spgmr18. ld_purchasingdocument = '4700000001'. CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL' EXPORTING purchasingdocument = ld_purchasingdocument item_data = 'X' condition_data = 'X' IMPORTING header = ls_head TABLES item = lt_item item_cond_validity = lt_val item_condition = lt_con. *Remove Validity Rcds not associated with ITEM_NO DELETE lt_val WHERE item_no <> '00030' OR item_no = '00030' AND valid_to <> '99991231'. *Set VALID_TO in Validity Table READ TABLE lt_val INTO ls_val INDEX 1. ls_val-valid_to = ls_val-valid_from + 1. MODIFY lt_val FROM ls_val INDEX 1. *Remove Condition Rcds not assiciated with SERIAL_ID DELETE lt_con WHERE serial_id <> ls_val-serial_id. l_date = ls_val-valid_to. *Set CHANGE_ID to "U" in Condition Table READ TABLE lt_con INTO ls_con INDEX 1. ls_con-change_id = 'U'. MODIFY lt_con FROM ls_con INDEX 1. *Insert Validity Rcd CLEAR ls_val. ls_val-item_no = '00030'. ls_val-valid_from = l_date + 1. ls_val-valid_to = '99991231'. APPEND ls_val TO lt_val. *Create Validity "X" Rcds LOOP AT lt_val INTO ls_val. CLEAR ls_valx. ls_valx-item_no = ls_val-item_no. ls_valx-serial_id = ls_val-serial_id. ls_valx-item_nox = 'X'. * IF ls_val-serial_id IS NOT INITIAL. * ls_valx-serial_idx = 'X'. * ENDIF. ls_valx-valid_from = 'X'. ls_valx-valid_to = 'X'. APPEND ls_valx TO lt_valx. ENDLOOP. *Insert Condition Rcd CLEAR ls_con. ls_con-item_no = '00030'. ls_con-cond_count = '01'. ls_con-cond_type = 'PB00'. ls_con-scale_type = 'A'. ls_con-calctypcon = 'C'. ls_con-cond_value = 4. ls_con-cond_p_unt = 1000. ls_con-currency = 'USD'. ls_con-currency_iso = 'USD'. ls_con-numerator = 1. ls_con-denominator = 1. ls_con-cond_unit = 'EA'. ls_con-cond_unit_iso = 'EA'. ls_con-base_uom = 'EA'. ls_con-base_uom_iso = 'EA'. ls_con-change_id = 'I'. APPEND ls_con TO lt_con. *Create Condition "X" Rcds LOOP AT lt_con INTO ls_con. CLEAR ls_conx. ls_conx-item_no = ls_con-item_no. ls_conx-serial_id = ls_con-serial_id. ls_conx-cond_count = ls_con-cond_count. ls_conx-item_nox = 'X'. * IF ls_con-serial_id IS NOT INITIAL. * ls_conx-serial_idx = 'X'. * ENDIF. ls_conx-cond_countx = 'X'. ls_conx-cond_type = 'X'. ls_conx-scale_type = 'X'. ls_conx-calctypcon = 'X'. ls_conx-cond_value = 'X'. ls_conx-currency = 'X'. ls_conx-currency_iso = 'X'. ls_conx-cond_unit = 'X'. ls_conx-cond_unit_iso = 'X'. ls_conx-numerator = 'X'. ls_conx-denominator = 'X'. ls_conx-cond_p_unt = 'X'. ls_conx-base_uom = 'X'. ls_conx-base_uom_iso = 'X'. APPEND ls_conx TO lt_conx. ENDLOOP. DATA: ls_headx TYPE bapimeoutheaderx. ls_headx-vper_start = 'X'. ls_headx-vper_end = 'X'. DELETE lt_item WHERE item_no <> '00030'. ls_itemx-item_no = '00030'. ls_itemx-item_nox = 'X'. ls_itemx-net_price = 'X'. APPEND ls_itemx TO lt_itemx. break spgmr18. CALL FUNCTION 'BAPI_CONTRACT_CHANGE' EXPORTING purchasingdocument = ld_purchasingdocument * header = ls_head * headerx = ls_headx TABLES * item = lt_item * itemx = lt_itemx item_cond_validity = lt_val item_cond_validityx = lt_valx item_condition = lt_con item_conditionx = lt_conx return = lt_return. CLEAR ld_error. LOOP AT lt_return TRANSPORTING NO FIELDS WHERE type = 'E' OR type = 'A'. ld_error = 'X'. EXIT. ENDLOOP. IF ld_error IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' * EXPORTING * wait = 'X' IMPORTING return = ls_return. ENDIF. break spgmr18.
2016 Jul 22 2:39 PM
Dear Gary,
I got the environment to try the coding with the same with your environment.
To insert the new condition price, just change the valid-from date from the last record (99991231), and then change the unit price.
I edited your coding, and please try the below coding :
DATA : ld_purchasingdocument TYPE bapimeoutheader-number,
ld_error TYPE char1,
l_date TYPE datum.
DATA: lt_val TYPE TABLE OF bapimeoutvalidity,
ls_val TYPE bapimeoutvalidity,
lt_valx TYPE TABLE OF bapimeoutvalidityx,
ls_valx TYPE bapimeoutvalidityx,
lt_con TYPE TABLE OF bapimeoutcondition,
ls_con TYPE bapimeoutcondition,
lt_conx TYPE TABLE OF bapimeoutconditionx,
ls_conx TYPE bapimeoutconditionx,
lt_return TYPE TABLE OF bapiret2,
ls_return TYPE bapiret2,
ls_head TYPE bapimeoutheader,
lt_item TYPE TABLE OF bapimeoutitem,
ls_item TYPE bapimeoutitem,
lt_itemx TYPE TABLE OF bapimeoutitemx,
ls_itemx TYPE bapimeoutitemx.
ld_purchasingdocument = '3100000002'.
CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL'
EXPORTING
purchasingdocument = ld_purchasingdocument
item_data = 'X'
condition_data = 'X'
IMPORTING
header = ls_head
TABLES
item = lt_item
item_cond_validity = lt_val
item_condition = lt_con.
*Remove Validity Rcds not associated with ITEM_NO
DELETE lt_val WHERE valid_to <> '99991231'.
*Set VALID_TO in Validity Table
READ TABLE lt_val INTO ls_val INDEX 1.
ls_val-valid_from = ls_val-valid_from + 1.
MODIFY lt_val FROM ls_val INDEX 1.
*Remove Condition Rcds not assiciated with SERIAL_ID
DELETE lt_con WHERE serial_id <> ls_val-serial_id.
l_date = ls_val-valid_to.
*Set CHANGE_ID to "U" in Condition Table
READ TABLE lt_con INTO ls_con INDEX 1.
ls_con-cond_type = 'PB00'.
ls_con-scale_type = 'A'.
ls_con-calctypcon = 'C'.
ls_con-cond_value = 3.
ls_con-cond_p_unt = 1.
ls_con-currency = 'MYR'.
ls_con-currency_iso = 'MYR'.
ls_con-numerator = 1.
ls_con-denominator = 1.
ls_con-cond_unit = 'EA'.
ls_con-cond_unit_iso = 'EA'.
ls_con-base_uom = 'EA'.
ls_con-base_uom_iso = 'EA'.
ls_con-change_id = 'U'.
MODIFY lt_con FROM ls_con INDEX 1.
*Insert Validity Rcd
*CLEAR ls_val.
*ls_val-item_no = '00010'.
*ls_val-valid_from = l_date + 1.
*ls_val-valid_to = '99991231'.
*APPEND ls_val TO lt_val.
*Create Validity "X" Rcds
LOOP AT lt_val INTO ls_val.
CLEAR ls_valx.
ls_valx-item_no = ls_val-item_no.
ls_valx-serial_id = ls_val-serial_id.
ls_valx-item_nox = 'X'.
IF ls_val-serial_id IS NOT INITIAL.
ls_valx-serial_idx = 'X'.
ENDIF.
ls_valx-valid_from = 'X'.
ls_valx-valid_to = 'X'.
APPEND ls_valx TO lt_valx.
ENDLOOP.
*Create Condition "X" Rcds
LOOP AT lt_con INTO ls_con.
CLEAR ls_conx.
ls_conx-item_no = ls_con-item_no.
ls_conx-serial_id = ls_con-serial_id.
ls_conx-cond_count = ls_con-cond_count.
ls_conx-item_nox = 'X'.
* IF ls_con-serial_id IS NOT INITIAL.
* ls_conx-serial_idx = 'X'.
* ENDIF.
ls_conx-cond_countx = 'X'.
ls_conx-cond_type = 'X'.
ls_conx-scale_type = 'X'.
ls_conx-calctypcon = 'X'.
ls_conx-cond_value = 'X'.
ls_conx-currency = 'X'.
ls_conx-currency_iso = 'X'.
ls_conx-cond_unit = 'X'.
ls_conx-cond_unit_iso = 'X'.
ls_conx-numerator = 'X'.
ls_conx-denominator = 'X'.
ls_conx-cond_p_unt = 'X'.
ls_conx-base_uom = 'X'.
ls_conx-base_uom_iso = 'X'.
APPEND ls_conx TO lt_conx.
ENDLOOP.
DATA: ls_headx TYPE bapimeoutheaderx.
ls_headx-vper_start = 'X'.
ls_headx-vper_end = 'X'.
DELETE lt_item WHERE item_no <> '00010'.
READ TABLE lt_item INTO ls_item INDEX 1.
ls_item-PREQ_NAME = 'TEST'.
MODIFY lt_item FROM ls_item INDEX 1.
ls_itemx-item_no = '00010'.
ls_itemx-item_nox = 'X'.
ls_itemx-net_price = 'X'.
APPEND ls_itemx TO lt_itemx.
CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
EXPORTING
purchasingdocument = ld_purchasingdocument
* header = ls_head
* headerx = ls_headx
TABLES
* item = lt_item
* itemx = lt_itemx
item_cond_validity = lt_val
item_cond_validityx = lt_valx
item_condition = lt_con
item_conditionx = lt_conx
return = lt_return.
CLEAR ld_error.
LOOP AT lt_return TRANSPORTING NO FIELDS WHERE type = 'E' OR type = 'A'.
ld_error = 'X'.
EXIT.
ENDLOOP.
IF ld_error IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* wait = 'X'
IMPORTING
return = ls_return.
ENDIF.
I hope that you understand with the above coding.
Regards,
Yance
2016 Jul 22 8:16 PM
Dear Yance
I ran your code (Changing Doc to 4700000003) and I get the following error.
Gary
2016 Jul 23 5:41 AM
Dear Gary,
Why did it go back to the first error message?
Could you debug with your data, in program MV130F0I subroutine ivake_insert and break-point in MESSAGE a067 WITH 'IVAKE' 'IVAKE_INSERT' 'MV130F0I'. ?
IVAKE and XVAKE table.
Which data causes error and analyze why?
Regards,
Yance
2016 Jul 25 10:41 PM
Dear Yance
Thanks so much for your help it has been greatly appreciated. I'm just about ready to give up. I have screen shots of IVAKE & XVAKE when I run the code you modified for me. Not sure what is going on? Line 68 is where I get the error (see below 3rd screen shot)
Regards Gary
2016 Jul 26 4:20 PM
Dear Gary,
I am still curiouse with your system, how many times that ivake_insert to be called in your system.
Because ivake_insert which is called in my system is only once and the total and condition ivake and xvake is 3 records which is the same with you.
Btw...for the last option that i can give to you which is to run BAPI_CONTRACT_CHANGE twice.
1. Change the new validity date and run BAPI_CONTRACT_CHANGE
2. Change the condition price for the last date (99991231) and run BAPI_CONTRACT_CHANGE.
Regards,
Yance
2016 Jul 26 7:12 PM
Hello
I think I found the problem I am having.
In program MV130F0I at line 55 should the value of sy-tabix be ivake-tabix?
When I have my program in debug and change the value in sy-tabix to match ivake-tabix it works. Can someone let me know if program MV130F0I in my system is missing a release update?
Thanks Gary
2016 Aug 30 1:37 AM