10-08-2008 11:08 PM
Hi Everyone,
Can you please let me know how to use this FM BAPI_CUSTOMERCONTRACT_CHANGE? my requirement is to change the item details of a particular contract which has more than 500 items so i can you please help me with FM.
i need to change the header enddate, outAg target quantity, profit center, material.
it would be really helpfull if someone can send me a sample code for this.
Thanks in advance
Srinivas
10-08-2008 11:14 PM
This example has just header data. For item is the same, must fill CONTRACT_ITEM_IN and CONTRACT_ITEM_INX structures.
DATA: vbeln TYPE vbeln.
DATA: return TYPE STANDARD TABLE OF bapiret2.
DATA: header TYPE bapisdh1.
DATA: headerx TYPE bapisdh1x.
*** New values
CLEAR: header.
header-bill_block = space.
header-pymt_meth = 'M'.
CONCATENATE 'MB-' wa_assin-ref_pag INTO header-purch_no_c.
*** Refer fields to be changed
CLEAR: headerx.
headerx-updateflag = 'U'.
headerx-bill_block = 'X'.
headerx-purch_no_c = 'X'.
headerx-pymt_meth = 'X'.
CALL FUNCTION 'BAPI_CUSTOMERCONTRACT_CHANGE'
EXPORTING
salesdocument = vbeln
contract_header_in = header
contract_header_inx = headerx
TABLES
return = return.
Regards,
Valter Oliveira.
10-10-2008 2:35 AM
Hi Valter,
thanks for your response, i have tried to change the material, plant and traget quantity but the values were not changed.
i have filled the tables
CONTRACT_ITEM_IN in this i have filled the item number, material, plant and target quantity
CONTRACT_ITEM_INX and have put X in the above mentioned fields
similarly i have filled
CONTRACT_HEADER_IN sales org, distribution channel, division
CONTRACT_HEADER_INX and have put X in the above mentioned fields
and also the UPDATEFLAG as U.
but the values are not getting changed, can you please correct me if i am wrong.
Thanks in Advance.
Thanks,
Srinivas
10-10-2008 2:53 AM
Check this....
s_contract_items_inx-updateflag = 'U'.
s_contract_items_in-itm_number = s_vbap-posnr.
s_contract_items_inx-itm_number = s_vbap-posnr.
s_contract_items_in-material = s_itm_record-matnr.
s_contract_items_inx-material = 'X'.
s_contract_items_in-target_qty = s_itm_record-zmeng.
s_contract_items_inx-target_qty = 'X'.
IF NOT s_itm_record-mvgr2 IS INITIAL.
SELECT SINGLE * FROM tvm2t WHERE bezei = s_itm_record-mvgr2
AND spras = 'E'.
s_contract_items_in-prc_group2 = tvm2t-mvgr2.
s_contract_items_inx-prc_group2 = 'X'.
ELSE.
s_contract_items_in-prc_group2 = ' '.
s_contract_items_inx-prc_group2 = 'X'.
ENDIF.
IF s_itm_record-mvgr3 = 'true'.
s_contract_items_in-prc_group3 = 'XXX'.
s_contract_items_inx-prc_group3 = 'X'.
ELSEIF s_itm_record-mvgr3 = 'false'.
s_contract_items_in-prc_group3 = ' '.
s_contract_items_inx-prc_group3 = 'X'.
ENDIF.
If you are changing the target quantity, i believe you may have to pass the net price also....
See if your contract has a agreeement ... If so then the values will be picked from the agreement.... try passing values to other fields and see if it is updated...
regards,
Madan....
10-10-2008 11:50 AM
Hi there!
First I would ask you to check what does return structure say ... It can tell you what the problem is ....
Another question. Are you using CONTRACT_ITEM_INX-posnr = 'X'? You shouldn't because you don't want to change item number, just material, quantity and plant (those should have the 'X', but remember that that material have to exist in the plant too ...)
I'm not sure if you can change all of those header data. Try commenting the change to these data (or just sales org) to see if the item data is changed (and the opposite too).
Also, don't forget to use FM BAPI_TRANSACTION_COMMIT after your BAPI.
If nothing of this works, can you please post the entire code (the code block where you call the bapi)?
Regards,
Valter Oliveira.
10-16-2008 11:30 PM
Hi,
I was trying to test the FM in SE37 and was trying to fill the values, the FM executes succesfully and i get a message saying that the item got processed successfully but when i check the contract it does'nt happen in va43.
CONTRACT_ITEM_INX-posnr = X.
i have just tried to change material and plant even it says that it has succesfully updated but the contract doesnt show those values.
Thanks & regards,
Srinivas
Edited by: srinivas reddy kaki on Oct 17, 2008 4:03 AM
10-17-2008 7:58 PM
Hello.
Using FM BAPI_CUSTOMERCONTRACT_CHANGE isolated in tcode se37 will never make a "real" change in the system because after BAPI execution you always have to use FM BAPI_TRAMSACTION_COMMIT. You normally use it in a program, but in SE37 you can also run 2 FM's at a time if you use a test sequence:
SE37->Function module (menu)->Test->Test sequences-
Regards,
Valter Oliveira.
10-20-2008 6:42 PM
Hi,
I have tried with the below code the header are being changed but the item values are not getting changed.
Can you please help to change the item values.
i want the target quantity, material and plant to be changed at the item level.
None of the item values are getting changed
DATA: vbeln TYPE vbeln.
DATA: return TYPE STANDARD TABLE OF bapiret2.
DATA: header TYPE bapisdh1.
DATA: headerx TYPE bapisdh1x.
DATA: item TYPE STANDARD TABLE OF BAPISDITM with header line.
DATA: itemx TYPE STANDARD TABLE OF BAPISDITMX with header line.
*New values
CLEAR: header.
header-CT_VALID_T = '20091231'.
*header-pymt_meth = 'M'.
*CONCATENATE 'MB-' wa_assin-ref_pag INTO header-purch_no_c.
vbeln = '0040001291'.
*Refer fields to be changed
CLEAR: headerx.
headerx-updateflag = 'U'.
headerx-CT_VALID_T = 'X'.
*headerx-purch_no_c = 'X'.
*headerx-pymt_meth = 'X'.
CLEAR: item.
item-ITM_NUMBER = '000010'.
*item-TARGET_QTY = '120'.
item-MATERIAL = '307'.
item-PLANT = '0548'.
CLEAR: itemx.
itemx-UPDATEFLAG = 'U'.
*itemx-ITM_NUMBER = 'X'.
*itemx-TARGET_QTY = 'X'.
itemx-MATERIAL = 'X'.
itemx-PLANT = 'X'.
.
CALL FUNCTION 'BAPI_CUSTOMERCONTRACT_CHANGE'
EXPORTING
salesdocument = vbeln
contract_header_in = header
contract_header_inx = headerx
TABLES
return = return
CONTRACT_ITEM_IN = item
CONTRACT_ITEM_INX = itemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
Thanks & regards,
Srinivas
10-20-2008 6:39 PM
Hi,
I have tried with the below code the header are being changed but the item values are not getting changed.
Can you please help to change the item values.
i want the target quantity, material and plant to be changed at the item level.
DATA: vbeln TYPE vbeln.
DATA: return TYPE STANDARD TABLE OF bapiret2.
DATA: header TYPE bapisdh1.
DATA: headerx TYPE bapisdh1x.
DATA: item TYPE STANDARD TABLE OF BAPISDITM with header line.
DATA: itemx TYPE STANDARD TABLE OF BAPISDITMX with header line.
New values
CLEAR: header.
header-CT_VALID_T = '20091231'.
*header-pymt_meth = 'M'.
*CONCATENATE 'MB-' wa_assin-ref_pag INTO header-purch_no_c.
vbeln = '0040001291'.
Refer fields to be changed
CLEAR: headerx.
headerx-updateflag = 'U'.
headerx-CT_VALID_T = 'X'.
*headerx-purch_no_c = 'X'.
*headerx-pymt_meth = 'X'.
CLEAR: item.
item-ITM_NUMBER = '000010'.
*item-TARGET_QTY = '120'.
item-MATERIAL = '307'.
item-PLANT = '0548'.
CLEAR: itemx.
itemx-UPDATEFLAG = 'U'.
*itemx-ITM_NUMBER = 'X'.
*itemx-TARGET_QTY = 'X'.
itemx-MATERIAL = 'X'.
itemx-PLANT = 'X'.
.
CALL FUNCTION 'BAPI_CUSTOMERCONTRACT_CHANGE'
EXPORTING
salesdocument = vbeln
contract_header_in = header
contract_header_inx = headerx
TABLES
return = return
CONTRACT_ITEM_IN = item
CONTRACT_ITEM_INX = itemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
Thanks & regards,
Srinivas
10-20-2021 7:23 PM
Even if this poste has been done in 2008, I am facing the same issue in 2021.
The Target_qty doesn't change. The return table provides all success messages
The BAPI_TRANSACTION_COMMIT return no error too.
Any idea to make the BAPI performing the quantity change to the specific Item number?
Regards
Daniel