Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CANNOT update plant using BAPI_SALESORDER_CHANGE

former_member1137458
Participant
0 Likes
3,256

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'

..

..

..

8 REPLIES 8
Read only

former_member188724
Contributor
0 Likes
2,629

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

Read only

0 Likes
2,629

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 ??

Read only

0 Likes
2,629

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

Read only

0 Likes
2,629

Hi K.S,

i have found out VBAP-WERKS clear and move KNVV-VWERK to VBAP-WERKS.


Read only

0 Likes
2,629

Particular material is extended to your plant?

Material - ABC22222 is extended to Plant 1001?

check the availability of Material quantity in 1001.



Thanks,

Kalyan.

Read only

0 Likes
2,629

Yes. Material - ABC22222 is extended to all Plant and  set  MARC-MTVFP = KP ( NO CHECK )

Read only

former_member1137458
Participant
0 Likes
2,629

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 ????

Read only

0 Likes
2,629

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.