Skip to Content

BAPI_SALESORDER_CHANGE - item quantity not being set

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 01:42 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 01:43 PM

    Sorry....

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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 09, 2008 at 01:49 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 01:57 PM

    I know that BAPI_SALESORDER_CREATEFROMDAT2 definitely works...

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.