08-01-2008 7:33 AM
Hi Experts,
I need to determine the next line item number using BAPI_SALESORDER_CHANGE USING (Sales order number and Item details)
and assign the new MATNR and copy the qty to the new line item number.
please provide the sample code ...
or idea how to use this BAPI for the above requirement.
regards,
Jay.
08-01-2008 7:38 AM
First fetch Sales order details using FM 'BAPISDORDER_GETDETAILEDLIST'.
sort t_items ascending.
read table t_items index 1.
t_items-ITM_NUMBER will be last item number of sales order.
Take next number i.e. ITM_NUMBER + 1.
Regards,
Aparna Gaikwad
08-01-2008 7:39 AM
first make selection from VBAP table to find the existing line items in SO..then apply the above logic...
regards
08-01-2008 7:42 AM
Sample code for ur reference -
Data:itab_order_items LIKE bapisditm OCCURS 0 WITH HEADER LINE,
itab_order_items_up LIKE bapisditmx OCCURS 0 WITH HEADER LINE.
itab_order_header_up-updateflag = 'U'.
itab_order_items-itm_number = l_itm_number.
itab_order_items-material = t_item_data-s_matnr.
itab_order_items-target_qty = l_qty.
APPEND itab_order_items.
CLEAR itab_order_items.
itab_order_items_up-updateflag = 'U'.
itab_order_items_up-material = 'X'.
itab_order_items_up-target_qty = 'X'.
APPEND itab_order_items_up.
CLEAR itab_order_items_up.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_vbeln
order_header_inx = itab_order_header_up
TABLES
return = return2
order_item_in = itab_order_items
order_item_inx = itab_order_items_up.
Hope u will find this useful.
Regards,
Aparna Gaikwad