2015 Sep 10 5:18 AM
Environment Data :
Sold to Party : 0001234567
Delivery Plant : 2001
Contract: 0008765432
All item set to plant 2001
SO is created with Material ABC11111 and Plant 1001.
Now, When change Material ABC11111 to ABC22222.
The plant will be change back to 2001. Why??
My Coding:
CLEAR ORDER_ITEM_IN.
ORDER_ITEM_IN-ITM_NUMBER = '000010'.
" ( change from ABC11111 to ABC22222 )
ORDER_ITEM_IN-MATERIAL = 'ABC22222'
" ( Plant 1001 still exist in SO ,
" even pass this value or not, plant will set to 2001 ( KNVV-VWERK )
ORDER_ITEM_IN-PLANT = '1001'
ORDER_ITEM_IN-TARGET_QTY = '1'.
ORDER_ITEM_IN-REF_DOC = CONTRACT.
ORDER_ITEM_IN-REF_DOC_IT = CONTRACT_ITM.
ORDER_ITEM_IN-REF_DOC_CA = 'G'.
APPEND ORDER_ITEM_IN.
CLEAR ORDER_ITEM_INX.
ORDER_ITEM_INX-ITM_NUMBER = '000010'.
ORDER_ITEM_INX-UPDATEFLAG = 'X'.
ORDER_ITEM_INX-MATERIAL = 'X'.
" ( even pass this value or not, plant will set to 2001 ( KNVV-VWERK )
ORDER_ITEM_INX-PLANT = 'X'.
ORDER_ITEM_INX-TARGET_QTY = 'X'.
ORDER_ITEM_INX-REF_DOC = 'X'.
ORDER_ITEM_INX-REF_DOC_IT = 'X'.
ORDER_ITEM_INX-REF_DOC_CA = 'X'.
APPEND ORDER_ITEM_INX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
..
..
..
2015 Sep 10 7:17 AM
Hi Miu,
As per the documentation:
Possible UPDATEFLAGS:
- U = change
- D = delete
- I = add
You use 'X' in your code.
Please Change it to U and check.Maybe it should work.If not do let me know.
Regards,
KS
2015 Sep 10 7:30 AM
Hi K S,
Paste error. My coding has set to UPDATEFLAG = 'U'.
" Case 1:
" Plant code update correctly, but Reference item(VBAP-VGPOS) cannot update
ORDER_ITEM_INX-ITM_NUMBER = '000010'.
ORDER_ITEM_INX-UPDATEFLAG = 'U'.
" Case 2:
" Reference item(VBAP-VGPOS), can update But the plant code is override by Delivery Plant ( KNVV-VWERK )
ORDER_ITEM_INX-ITM_NUMBER = 'X'.
ORDER_ITEM_INX-UPDATEFLAG = 'U'.
Please advise how to update VBAP-VGPOS and Plant code correctly ??
2015 Sep 10 7:57 AM
Hi Miu,
I doubt the field you use is only for plant and not delivering plant.
I find enhancement spots available to Change
DWERK is used in include L2032FXX
MOVE WWW_SHIP_TO_PARTY_IMP-DWERK TO SHIP_TO_PARTY_BAPI-DLV_PLANT.
Maybe you can put a break Point in this include to check how it works.
You can also check the enhancements above if it helps.
Regards,
KS
2015 Sep 10 8:10 AM
Hi K.S,
i have found out VBAP-WERKS clear and move KNVV-VWERK to VBAP-WERKS.
2015 Sep 10 8:20 AM
Particular material is extended to your plant?
Material - ABC22222 is extended to Plant 1001?
check the availability of Material quantity in 1001.
Thanks,
Kalyan.
2015 Sep 10 8:38 AM
Yes. Material - ABC22222 is extended to all Plant and set MARC-MTVFP = KP ( NO CHECK )
2015 Sep 10 9:15 AM
Sold to Party : 0001234567
Delivery Plant ( KNVV-VWERK) : 2001
SO: 2001234567
Item:10
Material: ABC11111
Plant: 1001
If change from ABC11111 => ABC22222 and 1001 => 3001 , Update correctly.
If change from ABC11111 => ABC22222 and 1001 => 1001 , Update incorrectly.
Plant will be override to Plant 2001. WHY ????
2015 Sep 10 9:11 PM
Since you are changing the material number it triggers the whole chain of events in the sales document. I can only guess that plant 2001 is determined by default based on the material # and the rest of the fields. And because in the second case the Plant value is actually the same (1001) it is just not perceived that the field value needs to be changed. It might as well be a bug in BAPI. If you try to separate material change and the plant update into two steps then I bet it would work.
As a side note - it does not actually make a lot of sense to change the material number in an existing line. If you reject or delete the existing line and create a new one then it'll be a "cleaner" process. Check with your SD consultant.