Skip to Content
author's profile photo Former Member
Former Member

Determine the Next Line Item Number using BAPI_SALESORDER_CHANGE

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.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2008 at 06: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.


    Aparna Gaikwad

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.



      salesdocument = p_vbeln

      order_header_inx = itab_order_header_up


      return = return2

      order_item_in = itab_order_items

      order_item_inx = itab_order_items_up.

      Hope u will find this useful.


      Aparna Gaikwad

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.