Hi, I am trying to use the above bapi to add items to a sales order, but I can't get the qty to map across. I had the same problem using the create bapi whcih I resolved by populating the schedule tables, but in change this just causes an "unhandled exception" to occur, so i can;t even step into the FM to see the problem. Has anyone got any ideas.
s_header_inx-updateflag = 'U'.
* set item data
s_items-itm_number = s_stock-item_no.
s_items-material = s_stock-material_no.
s_items-target_qty = s_stock-quantity.
s_items-target_qu = s_stock-uom.
s_items-ref_doc = s_stock-agreement.
s_items-ref_doc_it = s_stock-agreement_item.
s_items-batch = s_stock-batch.
s_items-plant = s_stock-plant.
s_items-store_loc = s_stock-storage_location_no.
append s_items to it_items.
* set flag to add items (I)
s_itemsx-updateflag = insert.
s_itemsx-itm_number = s_items-itm_number.
s_itemsx-material = abap_true.
s_itemsx-target_qty = abap_true.
s_itemsx-ref_doc = abap_true.
s_itemsx-ref_doc_it = abap_true.
s_itemsx-batch = abap_true.
s_itemsx-plant = abap_true.
s_itemsx-store_loc = abap_true.
append s_itemsx to it_itemsx.
s_sched-itm_number = s_items-itm_number.
s_sched-sched_line = '0001'.
s_sched-REQ_DATE = sy-datum + 30.
s_sched-req_qty = s_items-target_qty.
append s_sched to it_sched.
* set flag to add items (I)
* s_schedx-updateflag = 'I'
s_schedx-itm_number = s_items-itm_number.
s_schedx-sched_line = '0001'.
s_schedx-REQ_DATE = 'X'.
s_schedx-req_qty = abap_true.
append s_schedx to it_schedx.
* Now call the BAPI to add the items
call function 'BAPI_SALESORDER_CHANGE'
exporting
salesdocument = me->number
* ORDER_HEADER_IN =
order_header_inx = s_header_inx
SIMULATION = ' '
* BEHAVE_WHEN_ERROR = 'P'
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
tables
return = it_return
order_item_in = it_items
order_item_inx = it_itemsx
* 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 =
order_schedules_in = it_sched
order_schedules_inx = it_schedx
* ORDER_TEXT =
* ORDER_KEYS =
* CONDITIONS_IN =
* CONDITIONS_INX =
* EXTENSIONIN =
.