<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to INSERT items using BAPI_SALESORDER_CHANGE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026331#M1348551</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt; You need to update order_header_inx , ITEM_INX, schedule_in &amp;amp; schedule_inx  structures..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just pass.&lt;/P&gt;&lt;P&gt;       wa_header_inx-updateflag = 'U'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ITEM_INX.&lt;/P&gt;&lt;P&gt;       IT_items_INX-updateflag = 'U'.&lt;/P&gt;&lt;P&gt;  Here you have to have the value of the field as 'X' for those which you planned to change.like &lt;/P&gt;&lt;P&gt;MATERIAL, TARGET_QTY etc etc..&lt;/P&gt;&lt;P&gt;v_cnt is the new item no calculated..&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populating Schedule Lines&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;                       it_schedule_in-itm_number  = v_cnt.&lt;/P&gt;&lt;P&gt;                       it_schedule_in-sched_line = '0001'.&lt;/P&gt;&lt;P&gt;                       it_schedule_in-req_qty = 1.&lt;/P&gt;&lt;P&gt;                      it_schedule_in-req_date = sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Index Table&lt;/P&gt;&lt;P&gt;                       it_schedule_inx -updateflag = 'I'.&lt;/P&gt;&lt;P&gt;                       it_schedule_inx -itm_number = V_CNT.&lt;/P&gt;&lt;P&gt;                       it_schedule_inx -sched_line = 1.&lt;/P&gt;&lt;P&gt;Append all the tables...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Aug 2009 18:41:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-05T18:41:02Z</dc:date>
    <item>
      <title>how to INSERT items using BAPI_SALESORDER_CHANGE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026329#M1348549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am trying to insert a items into SALESDOCUMENT, i am making the following process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a SALESDOCUMENT from which a make a copy then i delete all the ITEMS and i try to insert the new one, i am trying to insert a new ITEMS which has relations with another material i am making this because i am expecting when i insert the ITEMS all the material will be recalculated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;position     material    quantity.&lt;/P&gt;&lt;P&gt;10            6050             1     this is the main material&lt;/P&gt;&lt;P&gt;20           7228             30    This is child record of the main material        &lt;/P&gt;&lt;P&gt;30           7143               1   this is child record of the main material.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i run my function i need to modify the main material as this &lt;/P&gt;&lt;P&gt;  position    material    quantity&lt;/P&gt;&lt;P&gt;       10              6050           2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i am expecting &lt;/P&gt;&lt;P&gt;position     material    quantity.&lt;/P&gt;&lt;P&gt;10            6050             2     this is the main material&lt;/P&gt;&lt;P&gt;20           7228             60    This is child record of the main material        &lt;/P&gt;&lt;P&gt;30           7143               2   this is child record of the main marial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'BAPI_SALESORDER_CHANGE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            salesdocument    = p_copia      "this is the copy &lt;/P&gt;&lt;P&gt;            order_header_inx = are_headx   " value U&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            return           = tab_retor&lt;/P&gt;&lt;P&gt;            order_item_in    = tab_items&lt;/P&gt;&lt;P&gt;            order_item_inx   = tab_itemx&lt;/P&gt;&lt;P&gt;            schedule_lines   = tab_sched&lt;/P&gt;&lt;P&gt;            schedule_linesx  = tab_schex.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i really i don`t how to do it, i have been using the bapi  BAPI_SALESORDER_CHANGE, this bapi delete the items this is ok , but  not insert the items that i need , 'does anybody has make something like this, i will really apprecite if someone give a hand, please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2009 18:20:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026329#M1348549</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-05T18:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to INSERT items using BAPI_SALESORDER_CHANGE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026330#M1348550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try to flag UPDATEFLAG field as 'U', in ORDER_ITEM_INX table, for line item you are trying to modify.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Frisoni&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2009 18:28:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026330#M1348550</guid>
      <dc:creator>guilherme_frisoni</dc:creator>
      <dc:date>2009-08-05T18:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to INSERT items using BAPI_SALESORDER_CHANGE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026331#M1348551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt; You need to update order_header_inx , ITEM_INX, schedule_in &amp;amp; schedule_inx  structures..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just pass.&lt;/P&gt;&lt;P&gt;       wa_header_inx-updateflag = 'U'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ITEM_INX.&lt;/P&gt;&lt;P&gt;       IT_items_INX-updateflag = 'U'.&lt;/P&gt;&lt;P&gt;  Here you have to have the value of the field as 'X' for those which you planned to change.like &lt;/P&gt;&lt;P&gt;MATERIAL, TARGET_QTY etc etc..&lt;/P&gt;&lt;P&gt;v_cnt is the new item no calculated..&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populating Schedule Lines&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;                       it_schedule_in-itm_number  = v_cnt.&lt;/P&gt;&lt;P&gt;                       it_schedule_in-sched_line = '0001'.&lt;/P&gt;&lt;P&gt;                       it_schedule_in-req_qty = 1.&lt;/P&gt;&lt;P&gt;                      it_schedule_in-req_date = sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Index Table&lt;/P&gt;&lt;P&gt;                       it_schedule_inx -updateflag = 'I'.&lt;/P&gt;&lt;P&gt;                       it_schedule_inx -itm_number = V_CNT.&lt;/P&gt;&lt;P&gt;                       it_schedule_inx -sched_line = 1.&lt;/P&gt;&lt;P&gt;Append all the tables...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2009 18:41:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026331#M1348551</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-05T18:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to INSERT items using BAPI_SALESORDER_CHANGE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026332#M1348552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT zsalesorder_change .
* Data declarations.
DATA:i_bapi_view LIKE order_view.
DATA:sales_documents LIKE sales_key OCCURS 0 WITH HEADER LINE.
*ORDER_OUT
DATA:order_items_out LIKE bapisdit OCCURS 0 WITH HEADER LINE.
DATA:order_headers_out LIKE bapisdhd OCCURS 0 WITH HEADER LINE.
DATA:order_header_inx LIKE bapisdh1x.
***ORDER_IN
DATA:order_item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE.
DATA:order_header_in LIKE bapisdh1 OCCURS 0 WITH HEADER LINE.
DATA:order_item_inx LIKE bapisditmx OCCURS 0 WITH HEADER LINE.
DATA:schedule_lines LIKE bapischdl OCCURS 0 WITH HEADER LINE.
DATA:schedule_linesx LIKE bapischdlx OCCURS 0 WITH HEADER LINE.
DATA: i_hdr TYPE bapisdh1.
DATA: itab_item          LIKE bapisditem  OCCURS 0 WITH HEADER LINE.
DATA: itab_ch          LIKE itab_item  OCCURS 0 WITH HEADER LINE.
DATA: s_order_header_in LIKE bapisdh1.
DATA: s_order_header_inx LIKE bapisdh1x.
DATA: BEGIN OF i_order_item_in OCCURS 0.
        INCLUDE STRUCTURE bapisditm.
DATA: END   OF i_order_item_in.
DATA: BEGIN OF i_order_item_inx OCCURS 0.
        INCLUDE STRUCTURE bapisditmx.
DATA: END   OF i_order_item_inx.
DATA: BEGIN OF it_return OCCURS 0.
        INCLUDE STRUCTURE bapiret2.
DATA: END OF it_return.
DATA: BEGIN OF i_sched OCCURS 10.
        INCLUDE STRUCTURE bapischdl.
DATA: END OF i_sched.
DATA: BEGIN OF i_schedx OCCURS 10.
        INCLUDE STRUCTURE bapischdlx.
DATA: END OF i_schedx.
DATA : zmsg(50) TYPE c.
* Parameters
SELECTION-SCREEN : BEGIN OF BLOCK order WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_vbeln TYPE vbap-vbeln OBLIGATORY,
            pval TYPE vbap-bwtar .
SELECTION-SCREEN : END OF BLOCK order.
order_header_in-sd_doc_cat  = 'C'.
order_header_inx-updateflag = 'U'.
i_bapi_view-header = 'X'.
i_bapi_view-item = 'X'.
sales_documents-vbeln = p_vbeln.
APPEND sales_documents.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: krupa jani on Aug 6, 2009 2:54 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 12:53:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026332#M1348552</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T12:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to INSERT items using BAPI_SALESORDER_CHANGE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026333#M1348553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
continue..................................................

***GET LIST OF SALESORDER
CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
  EXPORTING
    i_bapi_view       = i_bapi_view
  TABLES
    sales_documents   = sales_documents
    order_headers_out = order_headers_out
    order_items_out   = order_items_out.
LOOP AT order_items_out .
  MOVE-CORRESPONDING order_items_out TO order_item_in.
  order_item_in-val_type = pval.
  APPEND order_item_in.
ENDLOOP.
LOOP AT order_item_in .
  MOVE-CORRESPONDING order_item_in TO itab_ch.
  APPEND itab_ch.
ENDLOOP.
LOOP AT itab_ch .
*   Header update indicator
  s_order_header_inx-updateflag = 'U'.
  i_order_item_in-itm_number = itab_ch-itm_number .
  i_order_item_in-material =   itab_ch-material.
  i_order_item_in-target_qty = itab_ch-target_qty.
  i_order_item_in-sales_unit = itab_ch-sales_unit.
  i_order_item_in-val_type = itab_ch-val_type.
  i_order_item_inx-updateflag = 'I'.
  i_order_item_inx-itm_number = itab_ch-itm_number .
  i_order_item_inx-material = itab_ch-material.
  i_order_item_inx-target_qty = 'X'.
  i_order_item_inx-sales_unit = itab_ch-sales_unit.
  i_order_item_inx-val_type =  'X'.
  APPEND: i_order_item_in, i_order_item_inx.
**  Fill schedule lines
  i_sched-itm_number = itab_ch-itm_number .
  i_sched-sched_line = '0001'.
  i_sched-req_qty    = itab_ch-target_qty.
  APPEND i_sched.
*   Fill schedule line flags
  i_schedx-itm_number  = itab_ch-itm_number .
  i_schedx-sched_line = '0001'.
  i_schedx-updateflag  = 'I'.
  i_schedx-req_qty     = 'X'.
  APPEND i_schedx.
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
  EXPORTING
    salesdocument     = p_vbeln
    order_header_in   = s_order_header_in
    order_header_inx  = s_order_header_inx
    behave_when_error = 'P'
  TABLES
    return            = it_return
    order_item_in     = i_order_item_in
    order_item_inx    = i_order_item_inx
    schedule_lines    = i_sched
    schedule_linesx   = i_schedx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

LOOP AT it_return.
  WRITE / it_return-message.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 12:54:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026333#M1348553</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-06T12:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to INSERT items using BAPI_SALESORDER_CHANGE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026334#M1348554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;gilos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i guess you have to use 'BAPI_SALESORDER_CREATEFROMDAT2'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to update (for example remove the items from) a sales order you are using the right BAPI, but to create a new one, you have to use the above one, both are very similar &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check more details in tcode BAPI&lt;/P&gt;&lt;P&gt;at the menu choose: "Sales and Distribution" &amp;gt;&amp;gt; Sales &amp;gt;&amp;gt; Sales Order &amp;gt;&amp;gt; Create from data 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i hope it's was helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 13:53:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-items-using-bapi-salesorder-change/m-p/6026334#M1348554</guid>
      <dc:creator>FabioPagoti</dc:creator>
      <dc:date>2009-08-06T13:53:08Z</dc:date>
    </item>
  </channel>
</rss>

