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: 

Determine the Next Line Item Number using BAPI_SALESORDER_CHANGE

Former Member
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

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

0 Kudos

first make selection from VBAP table to find the existing line items in SO..then apply the above logic...

regards

0 Kudos

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