Application Development 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: 

BAPI_SALESORDER_CHANGE - item quantity not being set

Former Member
0 Kudos
729

I am using BAPI_SALESORDER_CHANGE to add line items to a sales order. Everything works great except the quantity is not being saved into the sales order. I tried passing the quantity when creating the line item and that didn't work. Then I tried updating the quantity after creating the line item but the sales order is locked because the data is incomplete (quantity is missing). I have tried sending the UoM and that doesn't work. Does anybody have any idea what I can do? Also, if I send the UoM in item-target_qu will that override (or cause a conversion to) the sales unit?

Below is what I am passing:

header-sd_doc_cat = 'C'.

headerx-updateflag = 'U'.

schedule-itm_number = items-posnr.

schedulex-itm_number = 'X'.

schedule-sched_line = '0001'.

schedulex-sched_line = 'X'.

schedule-req_date = items-req_date.

schedulex-req_date = 'X'.

schedule-req_qty = items-zmeng.

schedulex-req_qty = 'X'.

schedulex-updateflag = 'I'.

item-itm_number = items-posnr.

itemx-itm_number = items-posnr.

item-material = items-matnr.

itemx-material = 'X'.

item-plant = items-werks.

itemx-plant = 'X'.

items-zmeng = items-zmeng * 1000.

item-target_qty = items-zmeng.

itemx-target_qty = 'X'.

itemx-updateflag = 'I'.

  • item-target_qu = 'EA'.

  • item-target_qu = 'X'.

APPEND: schedule, schedulex, item, itemx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = items-vbeln

order_header_in = header

order_header_inx = headerx

  • SIMULATION =

behave_when_error = 'P'

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

  • NO_STATUS_BUF_INIT = ' '

TABLES

return = return

order_item_in = item

order_item_inx = itemx

  • PARTNERS =

  • PARTNERCHANGES =

  • PARTNERADDRESSES =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

schedule_lines = schedule

schedule_linesx = schedulex

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Regards,

Davis

8 REPLIES 8

Former Member
0 Kudos
196

Hi Davis,

items-zmeng = items-zmeng * 1000.

item-target_qty = items-zmeng.

If items-zmeng is not filled before than it will still be 0?

Regards,

John.

0 Kudos
196

items-zmeng is filled (items is the structure that my BAPI is accepting and is a table of line items). When you use BAPI_SALESORDER_CREATEFROMDAT1 you must multiply the quantity by 1000 so I tried that hoping that it would fix my issue but it didn't.

Davis

0 Kudos
196

item-target_qu = 'EA'.

item-target_qu = 'X'. ---> itemx-target_qu = 'X'. ?

John.

0 Kudos
196

Hi John,

I originally had what you suggested but then commented it out and I guess when I commented it out I deleted the x but even when I pass a UoM it does not populate the item quantity.

Michael,

I will have to give it a try, thanks.

Regards,

Davis

Former Member
0 Kudos
196

Sorry....

Edited by: Michael on Jan 9, 2008 2:44 PM

Former Member
0 Kudos
196

When I use BAPI_SALESORDER_CREATEFROMDAT1, in a different program, I am creating the sales order at the same time I add the line item and I do not have to pass the schedule line item to that BAPI. I tried BAPI_SALESORDER_CHANGE with and without passing the schedule line info but it still doesn't work. I have seen other people have this issue, on SDN, but I have yet to see a solution. Can I use another FM (not SD_SALESDOCUMENT_CHANGE because it doesn't work either) to add a line item? I wasn't sure if BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2 would work

Davis

Former Member
0 Kudos
196

I know that BAPI_SALESORDER_CREATEFROMDAT2 definitely works...

0 Kudos
196

Michael,

That BAPI will not work for me. It gives me a return error that says:

"Ship-to part 15 is not assigned to a sold-to party".

I am passing both Ship-to and sold-to party numbers (both are customer 15 which is defined in the sales org) so I have no idea what is going on.

Does anybody have any idea how to make BAPI_SALESORDER_CHANGE work?

Is anybody using a BAPI to add line items to a sales order? If so can you post how you are doing it?

Regards,

Davis