Sales order creation with bapi in webdynpro

When i use table control to update the line items only first row is getting updated in the sale order creation and the loop is not updating the other row to header only the first row is getting saved, for the same set of  data sale order is getting created in  va01 for multiple line items.
Pls give me some idea to resolve this issue,
here is the code i am using for creating sale order using bapi 'BAPI_SALESORDER_CREATEFROMDAT2'
method CREATE_SALES_ORDER .
Declaration for Order Header Node
DATA: node_order_header TYPE REF TO if_wd_context_node,
       elem_order_header TYPE REF TO if_wd_context_element,
       stru_order_header TYPE if_componentcontroller=>element_order_header .
Declaration for Order Items Node
DATA: node_order_items TYPE REF TO if_wd_context_node,
       elem_order_items TYPE REF TO if_wd_context_element,
       stru_order_items TYPE if_componentcontroller=>element_order_items .
Declaration for Order Partners Node
DATA: node_order_partners TYPE REF TO if_wd_context_node,
elem_order_partners TYPE REF TO if_wd_context_element,
stru_order_partners TYPE if_componentcontroller=>element_order_partners .
node_order_header = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_order_header
elem_order_header = node_order_header->get_element( ).
elem_order_header->get_static_attributes(
IMPORTING static_attributes = stru_order_header
<ORDER_ITEMS> via lead selection
node_order_items = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_order_items ).
elem_order_items = node_order_items->get_element( ).
elem_order_items->get_static_attributes(
IMPORTING static_attributes = stru_order_items ).
<ORDER_PARTNERS> via lead selection
node_order_partners = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_order_partners ).
elem_order_partners = node_order_partners->get_element( ).
elem_order_partners->get_static_attributes(
IMPORTING static_attributes = stru_order_partners ).
DATA: v_sales_doc TYPE bapivbeln-vbeln.
DATA: w_order_header_in TYPE bapisdhd1,
      i_order_header_in TYPE table of bapisdhd1,"
      i_order_partners TYPE TABLE OF bapiparnr,
      w_order_partners TYPE bapiparnr,
      i_return TYPE TABLE OF bapiret2,
      w_return TYPE bapiret2,
      i_order_items_in TYPE TABLE OF bapisditm,
      w_order_items_in TYPE bapisditm,
      i_order_conditions_in TYPE TABLE OF bapicond,
      w_order_conditions_in TYPE bapicond,
      w_order_SCHDL type  BAPISCHDL,
      i_order_SCHDL type table of BAPISCHDL.
Order Header Details
CLEAR: w_order_header_in, i_order_partners, i_return, i_order_items_in,
          i_order_conditions_in, w_order_SCHDL, i_order_SCHDL.
refresh : i_order_partners, i_return, i_order_items_in,
          i_order_conditions_in, i_order_SCHDL.
w_order_header_in-doc_type = stru_order_header-doc_type.
w_order_header_in-sales_org = stru_order_header-sales_org.
w_order_header_in-distr_chan = stru_order_header-distr_chan.
w_order_header_in-division = stru_order_header-division.
w_order_header_in-req_date_h = stru_order_header-req_date_h.
w_order_header_in-sales_dist = stru_order_header-sales_dist.
w_order_header_in-purch_no_c = stru_order_header-purch_no_c.
Order Item Details
  CLEAR: i_order_items_in,w_order_items_in.
w_order_items_in-itm_num = stru_order_items-itm_num.
w_order_items_in-ITM_NUMBER =  stru_order_items-ITM_NUMBER.
w_order_items_in-material = stru_order_items-material.
w_order_items_in-target_qty = stru_order_items-target_qty."'5'.
w_order_items_in-target_qu = stru_order_items-target_qu."'5'.
w_order_items_in-plant = stru_order_items-plant.
w_order_items_in-target_val = stru_order_items-target_val.
w_order_items_in-currency = stru_order_items-currency.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
   input = w_order_items_in-material
   IMPORTING output = w_order_items_in-material.
APPEND w_order_items_in TO i_order_items_in.
Order Partner Details
CLEAR: i_order_partners,w_order_partners.
w_order_partners-partn_role = stru_order_partners-partn_role.
w_order_partners-partn_numb = stru_order_partners-partn_numb.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING input = w_order_partners-partn_numb
   IMPORTING output = w_order_partners-partn_numb.
APPEND w_order_partners TO i_order_partners.
Order Condition Details
w_order_SCHDL-ITM_NUMBER  = stru_order_items-itm_number." '000010'.
         w_order_SCHDL-req_qty     = stru_order_items-target_qty." '5'.
          APPEND w_order_SCHDL to i_order_SCHDL.
Create Sales Order BAPI Call
*loop at i_order_header_in into  w_order_header_in.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
   order_header_in = w_order_header_in
   IMPORTING
     salesdocument = v_sales_doc
     TABLES
       return = i_return
       order_items_in = i_order_items_in
       order_partners = i_order_partners
        order_schedules_in  = i_order_SCHDL
       order_conditions_in = i_order_conditions_in.
Get message manager
  DATA: l_current_controller TYPE REF TO if_wd_controller,
        l_message_manager    TYPE REF TO if_wd_message_manager.
  l_current_controller ?= wd_this->wd_get_api( ).
  CALL METHOD l_current_controller->get_message_manager
    RECEIVING
      message_manager = l_message_manager.
  DATA: v_message_text TYPE string.
When Sales Order is created commit the data
IF NOT v_sales_doc IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
      wait = 'X'.
    CONCATENATE 'Sales Document' v_sales_doc 'has been created.'
    INTO v_message_text SEPARATED BY space.
Report Success message
    CALL METHOD l_message_manager->report_success
    EXPORTING message_text = v_message_text.
    ELSE.
      v_message_text = 'Error Creating Sales Order'.
Report Error message
      CALL METHOD l_message_manager->report_error_message
      EXPORTING message_text = v_message_text.
      ENDIF.
*endloop.
endmethod.
and code for table control i am using is
method WDDOINIT .
  Types : Begin of item_tab,
        itm_number  type bapisditm-itm_number,
        material type bapisditm-material,
        plant type bapisditm-plant ,
        target_qty type bapisditm-target_qty,
        target_qu type bapisditm-target_qu,
        target_val type bapisditm-target_val,
    currency type bapisditm-currency,
        end of item_tab.
*Creating internal table and Work Area of the same structure
*as that of the Node created.
Data : it_item type standard table of item_tab,
        wa_item type item_tab.
*Appending Blank Work Area to Internal table.
***********************************************888
*LOOP AT it_item INTO wa_item.
**wa_item-itm_number to  bapisditm-itm_number.
**wa_item-material to bapisditm-material.
**wa_item-plant to bapisditm-plant.
**wa_item-target_qty to bapisditm-target_qty.
**wa_item-target_qu to bapisditm-target_qu.
**wa_item-target_val to bapisditm-target_val.
**wa_item-currency to bapisditm-currency.
   APPEND wa_item TO it_item.
*ENDLOOP.
**********************************************88
Do 10 times.
Append wa_item to it_item.
enddo.
"Binding the table
DATA lo_nd_order_items TYPE REF TO if_wd_context_node.
DATA lt_material TYPE wd_this->Elements_material.
navigate from <CONTEXT> to <MATERIAL> via lead selection
  lo_nd_order_items = wd_context->get_child_node( name = wd_this->wdctx_order_items ).
@TODO handle non existant child
IF lo_nd_material IS INITIAL.
ENDIF.
@TODO compute values
e.g. call a model function
  lo_nd_order_items->bind_table( new_items =
  it_item set_initial_elements = abap_true ).
endmethod.

When i use table control to update the line items only first row is getting updated in the sale order creation and the loop is not updating the other row to header only the first row is getting saved, for the same set of  data sale order is getting created in  va01 for multiple line items.
Pls give me some idea to resolve this issue,
here is the code i am using for creating sale order using bapi 'BAPI_SALESORDER_CREATEFROMDAT2'
method CREATE_SALES_ORDER .
Declaration for Order Header Node
DATA: node_order_header TYPE REF TO if_wd_context_node,
       elem_order_header TYPE REF TO if_wd_context_element,
       stru_order_header TYPE if_componentcontroller=>element_order_header .
Declaration for Order Items Node
DATA: node_order_items TYPE REF TO if_wd_context_node,
       elem_order_items TYPE REF TO if_wd_context_element,
       stru_order_items TYPE if_componentcontroller=>element_order_items .
Declaration for Order Partners Node
DATA: node_order_partners TYPE REF TO if_wd_context_node,
elem_order_partners TYPE REF TO if_wd_context_element,
stru_order_partners TYPE if_componentcontroller=>element_order_partners .
node_order_header = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_order_header
elem_order_header = node_order_header->get_element( ).
elem_order_header->get_static_attributes(
IMPORTING static_attributes = stru_order_header
<ORDER_ITEMS> via lead selection
node_order_items = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_order_items ).
elem_order_items = node_order_items->get_element( ).
elem_order_items->get_static_attributes(
IMPORTING static_attributes = stru_order_items ).
<ORDER_PARTNERS> via lead selection
node_order_partners = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_order_partners ).
elem_order_partners = node_order_partners->get_element( ).
elem_order_partners->get_static_attributes(
IMPORTING static_attributes = stru_order_partners ).
DATA: v_sales_doc TYPE bapivbeln-vbeln.
DATA: w_order_header_in TYPE bapisdhd1,
      i_order_header_in TYPE table of bapisdhd1,"
      i_order_partners TYPE TABLE OF bapiparnr,
      w_order_partners TYPE bapiparnr,
      i_return TYPE TABLE OF bapiret2,
      w_return TYPE bapiret2,
      i_order_items_in TYPE TABLE OF bapisditm,
      w_order_items_in TYPE bapisditm,
      i_order_conditions_in TYPE TABLE OF bapicond,
      w_order_conditions_in TYPE bapicond,
      w_order_SCHDL type  BAPISCHDL,
      i_order_SCHDL type table of BAPISCHDL.
Order Header Details
CLEAR: w_order_header_in, i_order_partners, i_return, i_order_items_in,
          i_order_conditions_in, w_order_SCHDL, i_order_SCHDL.
refresh : i_order_partners, i_return, i_order_items_in,
          i_order_conditions_in, i_order_SCHDL.
w_order_header_in-doc_type = stru_order_header-doc_type.
w_order_header_in-sales_org = stru_order_header-sales_org.
w_order_header_in-distr_chan = stru_order_header-distr_chan.
w_order_header_in-division = stru_order_header-division.
w_order_header_in-req_date_h = stru_order_header-req_date_h.
w_order_header_in-sales_dist = stru_order_header-sales_dist.
w_order_header_in-purch_no_c = stru_order_header-purch_no_c.
Order Item Details
  CLEAR: i_order_items_in,w_order_items_in.
w_order_items_in-itm_num = stru_order_items-itm_num.
w_order_items_in-ITM_NUMBER =  stru_order_items-ITM_NUMBER.
w_order_items_in-material = stru_order_items-material.
w_order_items_in-target_qty = stru_order_items-target_qty."'5'.
w_order_items_in-target_qu = stru_order_items-target_qu."'5'.
w_order_items_in-plant = stru_order_items-plant.
w_order_items_in-target_val = stru_order_items-target_val.
w_order_items_in-currency = stru_order_items-currency.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
   input = w_order_items_in-material
   IMPORTING output = w_order_items_in-material.
APPEND w_order_items_in TO i_order_items_in.
Order Partner Details
CLEAR: i_order_partners,w_order_partners.
w_order_partners-partn_role = stru_order_partners-partn_role.
w_order_partners-partn_numb = stru_order_partners-partn_numb.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING input = w_order_partners-partn_numb
   IMPORTING output = w_order_partners-partn_numb.
APPEND w_order_partners TO i_order_partners.
Order Condition Details
w_order_SCHDL-ITM_NUMBER  = stru_order_items-itm_number." '000010'.
         w_order_SCHDL-req_qty     = stru_order_items-target_qty." '5'.
          APPEND w_order_SCHDL to i_order_SCHDL.
Create Sales Order BAPI Call
*loop at i_order_header_in into  w_order_header_in.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
   order_header_in = w_order_header_in
   IMPORTING
     salesdocument = v_sales_doc
     TABLES
       return = i_return
       order_items_in = i_order_items_in
       order_partners = i_order_partners
        order_schedules_in  = i_order_SCHDL
       order_conditions_in = i_order_conditions_in.
Get message manager
  DATA: l_current_controller TYPE REF TO if_wd_controller,
        l_message_manager    TYPE REF TO if_wd_message_manager.
  l_current_controller ?= wd_this->wd_get_api( ).
  CALL METHOD l_current_controller->get_message_manager
    RECEIVING
      message_manager = l_message_manager.
  DATA: v_message_text TYPE string.
When Sales Order is created commit the data
IF NOT v_sales_doc IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
      wait = 'X'.
    CONCATENATE 'Sales Document' v_sales_doc 'has been created.'
    INTO v_message_text SEPARATED BY space.
Report Success message
    CALL METHOD l_message_manager->report_success
    EXPORTING message_text = v_message_text.
    ELSE.
      v_message_text = 'Error Creating Sales Order'.
Report Error message
      CALL METHOD l_message_manager->report_error_message
      EXPORTING message_text = v_message_text.
      ENDIF.
*endloop.
endmethod.
and code for table control i am using is
method WDDOINIT .
  Types : Begin of item_tab,
        itm_number  type bapisditm-itm_number,
        material type bapisditm-material,
        plant type bapisditm-plant ,
        target_qty type bapisditm-target_qty,
        target_qu type bapisditm-target_qu,
        target_val type bapisditm-target_val,
    currency type bapisditm-currency,
        end of item_tab.
*Creating internal table and Work Area of the same structure
*as that of the Node created.
Data : it_item type standard table of item_tab,
        wa_item type item_tab.
*Appending Blank Work Area to Internal table.
***********************************************888
*LOOP AT it_item INTO wa_item.
**wa_item-itm_number to  bapisditm-itm_number.
**wa_item-material to bapisditm-material.
**wa_item-plant to bapisditm-plant.
**wa_item-target_qty to bapisditm-target_qty.
**wa_item-target_qu to bapisditm-target_qu.
**wa_item-target_val to bapisditm-target_val.
**wa_item-currency to bapisditm-currency.
   APPEND wa_item TO it_item.
*ENDLOOP.
**********************************************88
Do 10 times.
Append wa_item to it_item.
enddo.
"Binding the table
DATA lo_nd_order_items TYPE REF TO if_wd_context_node.
DATA lt_material TYPE wd_this->Elements_material.
navigate from <CONTEXT> to <MATERIAL> via lead selection
  lo_nd_order_items = wd_context->get_child_node( name = wd_this->wdctx_order_items ).
@TODO handle non existant child
IF lo_nd_material IS INITIAL.
ENDIF.
@TODO compute values
e.g. call a model function
  lo_nd_order_items->bind_table( new_items =
  it_item set_initial_elements = abap_true ).
endmethod.

Similar Messages

  • Sales order creation with bapi in webdynpro using table control

    When i use table control to update the line items only first row is getting updated in the sale order creation and the loop is not updating the other row to header only the first row is getting saved, for the same set of data sale order is getting created in va01 for multiple line items. Pls give me some idea to resolve this issue, here is the code i am using for creating sale order using bapi 'BAPI_SALESORDER_CREATEFROMDAT2' method CREATE_SALES_ORDER .
    Declaration for Order Header Node DATA: node_order_header TYPE REF TO if_wd_context_node, elem_order_header TYPE REF TO if_wd_context_element, stru_order_header TYPE if_componentcontroller=>element_order_header . * Declaration for Order Items Node DATA: node_order_items TYPE REF TO if_wd_context_node, elem_order_items TYPE REF TO if_wd_context_element, stru_order_items TYPE if_componentcontroller=>element_order_items . * Declaration for Order Partners Node DATA: node_order_partners TYPE REF TO if_wd_context_node, elem_order_partners TYPE REF TO if_wd_context_element, stru_order_partners TYPE if_componentcontroller=>element_order_partners . node_order_header = wd_context->get_child_node( name = if_componentcontroller=>wdctx_order_header ). elem_order_header = node_order_header->get_element( ). elem_order_header->get_static_attributes( IMPORTING static_attributes = stru_order_header ). * via lead selection node_order_items = wd_context->get_child_node( name = if_componentcontroller=>wdctx_order_items ). elem_order_items = node_order_items->get_element( ). elem_order_items->get_static_attributes( IMPORTING static_attributes = stru_order_items ). * via lead selection node_order_partners = wd_context->get_child_node( name = if_componentcontroller=>wdctx_order_partners ). elem_order_partners = node_order_partners->get_element( ). elem_order_partners->get_static_attributes( IMPORTING static_attributes = stru_order_partners ). DATA: v_sales_doc TYPE bapivbeln-vbeln. DATA: w_order_header_in TYPE bapisdhd1, i_order_header_in TYPE table of bapisdhd1," i_order_partners TYPE TABLE OF bapiparnr, w_order_partners TYPE bapiparnr, i_return TYPE TABLE OF bapiret2, w_return TYPE bapiret2, i_order_items_in TYPE TABLE OF bapisditm, w_order_items_in TYPE bapisditm, i_order_conditions_in TYPE TABLE OF bapicond, w_order_conditions_in TYPE bapicond, w_order_SCHDL type BAPISCHDL, i_order_SCHDL type table of BAPISCHDL. * Order Header Details CLEAR: w_order_header_in, i_order_partners, i_return, i_order_items_in, i_order_conditions_in, w_order_SCHDL, i_order_SCHDL. refresh : i_order_partners, i_return, i_order_items_in, i_order_conditions_in, i_order_SCHDL. w_order_header_in-doc_type = stru_order_header-doc_type. w_order_header_in-sales_org = stru_order_header-sales_org. w_order_header_in-distr_chan = stru_order_header-distr_chan. w_order_header_in-division = stru_order_header-division. w_order_header_in-req_date_h = stru_order_header-req_date_h. w_order_header_in-sales_dist = stru_order_header-sales_dist. w_order_header_in-purch_no_c = stru_order_header-purch_no_c. * Order Item Details CLEAR: i_order_items_in,w_order_items_in. * w_order_items_in-itm_num = stru_order_items-itm_num. w_order_items_in-ITM_NUMBER = stru_order_items-ITM_NUMBER. w_order_items_in-material = stru_order_items-material. w_order_items_in-target_qty = stru_order_items-target_qty."'5'. w_order_items_in-target_qu = stru_order_items-target_qu."'5'. w_order_items_in-plant = stru_order_items-plant. w_order_items_in-target_val = stru_order_items-target_val. w_order_items_in-currency = stru_order_items-currency. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = w_order_items_in-material IMPORTING output = w_order_items_in-material. APPEND w_order_items_in TO i_order_items_in. * Order Partner Details CLEAR: i_order_partners,w_order_partners. w_order_partners-partn_role = stru_order_partners-partn_role. w_order_partners-partn_numb = stru_order_partners-partn_numb. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = w_order_partners-partn_numb IMPORTING output = w_order_partners-partn_numb. APPEND w_order_partners TO i_order_partners. * Order Condition Details w_order_SCHDL-ITM_NUMBER = stru_order_items-itm_number." '000010'. w_order_SCHDL-req_qty = stru_order_items-target_qty." '5'. APPEND w_order_SCHDL to i_order_SCHDL. * Create Sales Order BAPI Call *loop at i_order_header_in into w_order_header_in. CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2' EXPORTING order_header_in = w_order_header_in IMPORTING salesdocument = v_sales_doc TABLES return = i_return order_items_in = i_order_items_in order_partners = i_order_partners order_schedules_in = i_order_SCHDL order_conditions_in = i_order_conditions_in. * Get message manager DATA: l_current_controller TYPE REF TO if_wd_controller, l_message_manager TYPE REF TO if_wd_message_manager. l_current_controller ?= wd_this->wd_get_api( ). CALL METHOD l_current_controller->get_message_manager RECEIVING message_manager = l_message_manager. DATA: v_message_text TYPE string. * When Sales Order is created commit the data IF NOT v_sales_doc IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. CONCATENATE 'Sales Document' v_sales_doc 'has been created.' INTO v_message_text SEPARATED BY space. * Report Success message CALL METHOD l_message_manager->report_success EXPORTING message_text = v_message_text. ELSE. v_message_text = 'Error Creating Sales Order'. * Report Error message CALL METHOD l_message_manager->report_error_message EXPORTING message_text = v_message_text. ENDIF. *endloop. endmethod. and code for table control i am using is method WDDOINIT . Types : Begin of item_tab, itm_number type bapisditm-itm_number, material type bapisditm-material, plant type bapisditm-plant , target_qty type bapisditm-target_qty, target_qu type bapisditm-target_qu, target_val type bapisditm-target_val, currency type bapisditm-currency, end of item_tab. *Creating internal table and Work Area of the same structure *as that of the Node created. Data : it_item type standard table of item_tab, wa_item type item_tab. *Appending Blank Work Area to Internal table. ***********************************************888 *LOOP AT it_item INTO wa_item. **wa_item-itm_number to bapisditm-itm_number. **wa_item-material to bapisditm-material. **wa_item-plant to bapisditm-plant. **wa_item-target_qty to bapisditm-target_qty. **wa_item-target_qu to bapisditm-target_qu. **wa_item-target_val to bapisditm-target_val. **wa_item-currency to bapisditm-currency. ** * APPEND wa_item TO it_item. *ENDLOOP. **********************************************88 ******** Do 10 times. Append wa_item to it_item. enddo. ********* "Binding the table DATA lo_nd_order_items TYPE REF TO if_wd_context_node. * DATA lt_material TYPE wd_this->Elements_material. * navigate from to via lead selection lo_nd_order_items = wd_context->get_child_node( name = wd_this->wdctx_order_items ). * @TODO handle non existant child * IF lo_nd_material IS INITIAL. * ENDIF. ** @TODO compute values ** e.g. call a model function * lo_nd_order_items->bind_table( new_items = it_item set_initial_elements = abap_true ). endmethod.

    DATA: node_order_header TYPE REF TO if_wd_context_node, elem_order_header TYPE REF TO if_wd_context_element, stru_order_header TYPE if_componentcontroller=>element_order_header . * Declaration for Order Items Node DATA: node_order_items TYPE REF TO if_wd_context_node, elem_order_items TYPE REF TO if_wd_context_element, stru_order_items TYPE if_componentcontroller=>element_order_items . * Declaration for Order Partners Node DATA: node_order_partners TYPE REF TO if_wd_context_node, elem_order_partners TYPE REF TO if_wd_context_element, stru_order_partners TYPE if_componentcontroller=>element_order_partners . node_order_header = wd_context->get_child_node( name = if_componentcontroller=>wdctx_order_header ). elem_order_header = node_order_header->get_element( ). elem_order_header->get_static_attributes( IMPORTING static_attributes = stru_order_header ). * via lead selection node_order_items = wd_context->get_child_node( name = if_componentcontroller=>wdctx_order_items ). elem_order_items = node_order_items->get_element( ). elem_order_items->get_static_attributes( IMPORTING static_attributes = stru_order_items ). * via lead selection node_order_partners = wd_context->get_child_node( name = if_componentcontroller=>wdctx_order_partners ). elem_order_partners = node_order_partners->get_element( ). elem_order_partners->get_static_attributes( IMPORTING static_attributes = stru_order_partners ). DATA: v_sales_doc TYPE bapivbeln-vbeln. DATA: w_order_header_in TYPE bapisdhd1, i_order_header_in TYPE table of bapisdhd1," i_order_partners TYPE TABLE OF bapiparnr, w_order_partners TYPE bapiparnr, i_return TYPE TABLE OF bapiret2, w_return TYPE bapiret2, i_order_items_in TYPE TABLE OF bapisditm, w_order_items_in TYPE bapisditm, i_order_conditions_in TYPE TABLE OF bapicond, w_order_conditions_in TYPE bapicond, w_order_SCHDL type BAPISCHDL, i_order_SCHDL type table of BAPISCHDL. * Order Header Details CLEAR: w_order_header_in, i_order_partners, i_return, i_order_items_in, i_order_conditions_in, w_order_SCHDL, i_order_SCHDL. refresh : i_order_partners, i_return, i_order_items_in, i_order_conditions_in, i_order_SCHDL. w_order_header_in-doc_type = stru_order_header-doc_type. w_order_header_in-sales_org = stru_order_header-sales_org. w_order_header_in-distr_chan = stru_order_header-distr_chan. w_order_header_in-division = stru_order_header-division. w_order_header_in-req_date_h = stru_order_header-req_date_h. w_order_header_in-sales_dist = stru_order_header-sales_dist. w_order_header_in-purch_no_c = stru_order_header-purch_no_c. * Order Item Details CLEAR: i_order_items_in,w_order_items_in. * w_order_items_in-itm_num = stru_order_items-itm_num. w_order_items_in-ITM_NUMBER = stru_order_items-ITM_NUMBER. w_order_items_in-material = stru_order_items-material. w_order_items_in-target_qty = stru_order_items-target_qty."'5'. w_order_items_in-target_qu = stru_order_items-target_qu."'5'. w_order_items_in-plant = stru_order_items-plant. w_order_items_in-target_val = stru_order_items-target_val. w_order_items_in-currency = stru_order_items-currency. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = w_order_items_in-material IMPORTING output = w_order_items_in-material. APPEND w_order_items_in TO i_order_items_in. * Order Partner Details CLEAR: i_order_partners,w_order_partners. w_order_partners-partn_role = stru_order_partners-partn_role. w_order_partners-partn_numb = stru_order_partners-partn_numb. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = w_order_partners-partn_numb IMPORTING output = w_order_partners-partn_numb. APPEND w_order_partners TO i_order_partners. * Order Condition Details w_order_SCHDL-ITM_NUMBER = stru_order_items-itm_number." '000010'. w_order_SCHDL-req_qty = stru_order_items-target_qty." '5'. APPEND w_order_SCHDL to i_order_SCHDL. * Create Sales Order BAPI Call *loop at i_order_header_in into w_order_header_in. CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2' EXPORTING order_header_in = w_order_header_in IMPORTING salesdocument = v_sales_doc TABLES return = i_return order_items_in = i_order_items_in order_partners = i_order_partners order_schedules_in = i_order_SCHDL order_conditions_in = i_order_conditions_in. * Get message manager DATA: l_current_controller TYPE REF TO if_wd_controller, l_message_manager TYPE REF TO if_wd_message_manager. l_current_controller ?= wd_this->wd_get_api( ). CALL METHOD l_current_controller->get_message_manager RECEIVING message_manager = l_message_manager. DATA: v_message_text TYPE string. * When Sales Order is created commit the data IF NOT v_sales_doc IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. CONCATENATE 'Sales Document' v_sales_doc 'has been created.' INTO v_message_text SEPARATED BY space. * Report Success message CALL METHOD l_message_manager->report_success EXPORTING message_text = v_message_text. ELSE. v_message_text = 'Error Creating Sales Order'. * Report Error message CALL METHOD l_message_manager->report_error_message EXPORTING message_text = v_message_text. ENDIF. *endloop. endmethod. and code for table control i am using is method WDDOINIT . Types : Begin of item_tab, itm_number type bapisditm-itm_number, material type bapisditm-material, plant type bapisditm-plant , target_qty type bapisditm-target_qty, target_qu type bapisditm-target_qu, target_val type bapisditm-target_val, currency type bapisditm-currency, end of item_tab. *Creating internal table and Work Area of the same structure *as that of the Node created. Data : it_item type standard table of item_tab, wa_item type item_tab. *Appending Blank Work Area to Internal table. ***********************************************888 *LOOP AT it_item INTO wa_item. **wa_item-itm_number to bapisditm-itm_number. **wa_item-material to bapisditm-material. **wa_item-plant to bapisditm-plant. **wa_item-target_qty to bapisditm-target_qty. **wa_item-target_qu to bapisditm-target_qu. **wa_item-target_val to bapisditm-target_val. **wa_item-currency to bapisditm-currency. ** * APPEND wa_item TO it_item. *ENDLOOP. **********************************************88 ******** Do 10 times. Append wa_item to it_item. enddo. ********* "Binding the table DATA lo_nd_order_items TYPE REF TO if_wd_context_node. * DATA lt_material TYPE wd_this->Elements_material. * navigate from to via lead selection lo_nd_order_items = wd_context->get_child_node( name = wd_this->wdctx_order_items ). * @TODO handle non existant child * IF lo_nd_material IS INITIAL. * ENDIF. ** @TODO compute values ** e.g. call a model function * lo_nd_order_items->bind_table( new_items = it_item set_initial_elements = abap_true ). endmethod.

  • Reena Prabhakar - Sales order creation Using BAPI

    Hi Reena,
    This is Dinesh,i also face problem in Sales order creation using BAPI if you can send me the code it would be great help to me.
    Regards,
    Dinesh

    Anyhow, here is the code that I am using currently which works perfectly well. Not sure if it will be of any help to you, since the values to the BAPI come from the Webdynpro application. I have values stored in my "Test data directory" which I use for testing from the backend.
    FUNCTION ztest.
    Call the BAPI to create Sales Order
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
        EXPORTING
          order_header_in     = l_order_header
        IMPORTING
          salesdocument       = l_salesdocument
        TABLES
          return              = it_return
          order_items_in      = it_order_items
          order_partners      = it_order_partners
          order_schedules_in  = it_order_schdl
          order_conditions_in = it_order_conditions
          order_text          = it_order_text.
      READ TABLE it_return WITH KEY type = 'E'.
      IF sy-subrc = 0.
    *-- error occured
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ELSE.
    *-- no error
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
    ENDFUNCTION.

  • Mass sales order creation using BAPI

    Dear All,
    Can anyone help in  mass sales order creation using Bapi BAPI_SALESORDER_CREATEFROMDAT2.
    For example if i want to create 3 sales order with three item per order . i am populating
    HEADER = 3 Records
    Item   = 9 records
    schedule = 9 records
    partner  = 1 record.
    Then after populating the records I am calling Bapi BAPI_SALESORDER_CREATEFROMDAT2
    to create order. It should have created three order but unfortunately it creates
    only one sales order. I debugged and found that records are correct both in header,
    item, scheudle and partners.
    Could you please guide me what I am missing for creation of mass orders.
    I appreciate your time and many thanks in advance.
    cheers
    chandra

    Hi Chandra,
    Do like this.
    Loop at Header table into wa_header.
    *-- Move BAPI Header data
    Loop at item table into wa_item where condition.
    *--  in this move all Item and Schedule line item  to the BAPI.
      At end of item .
    Use the below function modules.
    BAPI_SALESORDER_CREATEFROMDAT2
    BAPI_TRANSACTION_COMMIT.
    Endloop.
    Endloop.
    Regards,
    Balavardhan.K

  • Create ecatt script for one sales order creation with multiple line items

    Hi ,
    I want to create a ecatt script for one sales order creation with multiple line items. Preferably SAP GUI.
    This selection of data will be from an external file/ variants which will have only one row of data in it.
    Firstly: I have to sort the external file having same PO Numbers in an order.Group them together.
    Second: I have to create sales order for those many line items having same PO Number.
    Best Regard
    Taranum

    Hi Micky
    Firstl you should upload the Line items for a particular sales Order in an Internal table
    and then pass that internal table to your BAPI during your coding corresponding to a particu;lar sales order
    In case of any issues pls revert back
    Reward points if helpful
    Regards
    Hitesh

  • Need sales order creation using bapi in oops

    need code for sales order creation using bapi in oops

    hi rocky,
              could you pls give a bit explanation on what you are expecting.
    regards,
    Pavan

  • SALES order creation using BAPI's

    Hai to all,
    I want to create sales order using bapis .I am new to this topic could any body guide me how to create sales order  step by step process using bapis.
    Thanks in advance.
    Regards,
    Chaitanya

    **&#12288;&#12503;&#12525;&#12464;&#12521;&#12512;&#65321;&#65316;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288; &#65306; ZBAPI_SALESORDER_CREATE               *
    **&#12288;&#12503;&#12525;&#12464;&#12521;&#12512;&#21517;&#31216;&#12288;&#12288;    &#12288;&#12288; &#65306; Upload Sales Order Creation                   *
    **&#12288;&#20966;&#29702;&#27010;&#35201;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;   &#12288;&#65306;                                       *
    **&#12288;&#20316;&#25104;&#32773;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288; &#65306; Karthik.P                             *
    **&#12288;&#20316;&#25104;&#26085;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288; &#65306; 2006/08/10                            *
    REPORT  ZBAPI_SALESORDER_CREATE LINE-SIZE 132 MESSAGE-ID ZMMBAPI .
           Internal table definition                                     *
    ****<<<<<Communication Fields: Sales and Distribution Document Header>>>>>>>>
    DATA: GT_ORDER_HEADER_IN LIKE BAPISDHD1,
    *******<<<Checkbox Fields for Sales and Distribution Document Header>>>>>>>>>
          GT_ORDER_HEADER_INX  LIKE    BAPISDHD1X,
    *****<<<<<Return Parameter>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          GT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,  " Return Messages
    *********<<<Communication Fields: Sales and Distribution Document Item<>>>>>
          GT_ORDER_ITEMS_IN LIKE BAPISDITM OCCURS 0 WITH HEADER LINE, " Item Data
    *********<<<Communication Fields: Sales and Distribution Document Item>>>>>>>
          GT_ORDER_ITEMS_INX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE, "Item Data Checkbox
    *********<<<Communication Fields: Sales and Distribution Document Item>>>>>>>
          GT_SALESDOCUMENT LIKE BAPIVBELN-VBELN , "Number of Generated Document
    *********<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>
          GT_ORDER_PARTNERS  LIKE BAPIPARNR OCCURS 0 WITH HEADER LINE, "Document Partner
    ********<<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>
          GT_ORDER_SCHEDULES_IN LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE, "Schedule Line Data
    ****<<<<<<<<Checkbox List for Maintaining Sales Document Schedule Line>>>>>>>>
          GT_ORDER_SCHEDULES_INX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE, " Checkbox Schedule Line Data
    *******Communication Fields for Maintaining Conditions in the Order
          GT_ORDER_CONDITIONS_IN  LIKE BAPICOND OCCURS 0 WITH HEADER LINE,
    ******Communication Fields for Maintaining Conditions in the Order
          GT_ORDER_CONDITIONS_INX LIKE BAPICONDX OCCURS 0 WITH HEADER LINE.
           Data definition                                               *
    DATA:  BEGIN OF GT_FT_SALES OCCURS 0,
           DOC_TYPE(4)  ,        "Sales Document Type
           SALES_ORG(4) ,        "Sales Organization
           DISTR_CHAN(2)  ,      "Distribution Channel
           DIVISION(2)   ,       "DIVISION(2)
           SALES_DIST(6)  ,      "Sales district
           INCOTERMS1(3)  ,      "Incoterms (part 1)
           INCOTERMS2(28)  ,     "Incoterms (part 2)
           PMNTTRMS(4)  ,        "Terms of payment key
           PRICE_DATE(8) ,       "Date for pricing and exchange rate
           PURCH_NO_C(35)  ,     "Customer purchase order number
           PURCH_NO_S(35)  ,     "Ship-to Party's Purchase Order Number
           EXCHG_RATE(8)  ,      "Directly quoted exchange rate for pricing and statistics
           CURRENCY(5) ,         "SD document currency
           MATERIAL(18),         "MATERIAL
           TARGET_QTY(13)  ,     "Target quantity in sales units
           ITEM_CATEG(4)  ,      "Sales document item category
           MATL_GROUP(8)  ,      "Material Group
           PURCH_NO_C1(35),      "Customer purchase order number
           SALES_DIST1(6)  ,     "Sales district
           INCOTERMS11(3)  ,     "Incoterms (part 1)
           INCOTERMS21(28),     "Incoterms (part 2)
           PMNTTRMS1(4)  ,     "Terms of payment key
           EXCHG_RATE1(8) ,    "Directly quoted exchange rate for pricing and statistics
           PRICE_DATE1(8) ,    "Date for pricing and exchange rate
           TRG_QTY_NO(5)    , "Factor for converting sales units to base units (target qty)
           DIVISION1(2)     ,                                   "DIVISION1
           SALQTYNUM(5)     , "Numerator (factor) for conversion of sales quantity into SKU
           GROSS_WGHT(3)    , "Gross Weight of the Item
           NET_WEIGHT(15)    , "Net Weight of the Item
           UNTOF_WGHT(3)    ,"Weight Unit
           PARTN_ROLE(2)   ,"Partner function
           PARTN_NUMB(10)   ,"Customer Number 1
    ********<<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>
           ITM_NUMBER(6) ,"Item number of the SD document
           REQ_QTY(8)  , "Schedule line date
           DLV_DATE(8)  , "Schedule line date
           MS_DATE(8)  , "Material availability date
           LOAD_DATE(8) , "Loading time (local time with reference to a shipping point)
           GI_DATE(8), "Time of goods issue (local DATE, with reference to a plant)
           TP_DATE(8)  , "Transportation planning -time (local w/ref. to shipping pnt)
           ITM_NUMBER2(6) , "Condition item number
    END OF GT_FT_SALES,
           MSG(240) TYPE  C,  " Return Message
           E_REC(8) TYPE C,    " Error Records Counter
           REC_NO(8) TYPE C, " Records Number Indicator
           S_REC(8) TYPE C,   " Successful Records Counter
           T_REC(8) TYPE C.   " Total Records Counter
    selection block for EXCEL UPLOAD FILE>>>>>>>>>>>>>>>>>>>>>>>>
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
      PARAMETERS FILE TYPE  IBIPPARMS-PATH OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    *<<<<AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .>>>>>>>>>>>>
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
        IMPORTING
          FILE_NAME     = FILE.
    **<<<<<<<<<<<<<<<<<START-OF-SELECTION.>>>>>>>>>>>>>>>>>>>>>>>>>>>
    START-OF-SELECTION.
      CALL FUNCTION 'WS_UPLOAD'                                 "#EC *
        EXPORTING
          FILENAME                = FILE
          FILETYPE                = 'DAT'
        TABLES
          DATA_TAB                = GT_FT_SALES
        EXCEPTIONS
          CONVERSION_ERROR        = 1
          FILE_OPEN_ERROR         = 2
          FILE_READ_ERROR         = 3
          INVALID_TYPE            = 4
          NO_BATCH                = 5
          UNKNOWN_ERROR           = 6
          INVALID_TABLE_WIDTH     = 7
          GUI_REFUSE_FILETRANSFER = 8
          CUSTOMER_ERROR          = 9
          NO_AUTHORITY            = 10
          OTHERS                  = 11.
      IF  SY-SUBRC <> 0  .
        MESSAGE E000.
      ENDIF.
      SKIP 3.
      FORMAT COLOR COL_HEADING INVERSE ON.
        WRITE 40 TEXT-001.
      FORMAT COLOR COL_HEADING INVERSE OFF.
      SKIP 1.
      FORMAT COLOR COL_NEGATIVE INVERSE ON.
        WRITE :/ TEXT-002, 13 SY-MANDT , 104 TEXT-003, 111 SY-UNAME,
                  / TEXT-004, 13 SY-DATUM , 104 TEXT-005, 111 SY-UZEIT.
      FORMAT COLOR COL_NEGATIVE INVERSE OFF.
      SKIP 3.
      LOOP AT GT_FT_SALES.
          PERFORM SLALE_UPLOAD_DATA.
      ENDLOOP.
      T_REC = E_REC + S_REC.
      SKIP 3.
      FORMAT COLOR COL_TOTAL INVERSE ON.
        WRITE: /38 TEXT-007, T_REC.
      FORMAT COLOR COL_TOTAL INVERSE OFF.
      FORMAT COLOR COL_NEGATIVE INVERSE ON.
        WRITE: /38 TEXT-008, E_REC.
      FORMAT COLOR COL_NEGATIVE INVERSE OFF.
      FORMAT COLOR COL_TOTAL INVERSE ON.
        WRITE: /38 TEXT-009, S_REC.
      FORMAT COLOR COL_TOTAL INVERSE OFF.
    *&      Form  SLALE_UPLOAD_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM SLALE_UPLOAD_DATA .
    *******<<<<<<<<<<Communication Fields: Sales and Distribution Document Header>>>>>>
        GT_ORDER_HEADER_IN-DOC_TYPE =    'TA'.
        GT_ORDER_HEADER_IN-SALES_ORG =  GT_FT_SALES-SALES_ORG . "'0001'
        GT_ORDER_HEADER_IN-DISTR_CHAN = GT_FT_SALES-DISTR_CHAN. "'01'
        GT_ORDER_HEADER_IN-DIVISION  =   GT_FT_SALES-DIVISION.  " '01'
        GT_ORDER_HEADER_IN-SALES_DIST = GT_FT_SALES-SALES_DIST ."'000001'
        GT_ORDER_HEADER_IN-INCOTERMS1 = GT_FT_SALES-INCOTERMS1.  "'CFR'
        GT_ORDER_HEADER_IN-INCOTERMS2 = GT_FT_SALES-INCOTERMS2 . "'HAMBURG'
        GT_ORDER_HEADER_IN-PMNTTRMS = GT_FT_SALES-PMNTTRMS .    "'0001'
        GT_ORDER_HEADER_IN-PRICE_DATE = GT_FT_SALES-PRICE_DATE ."'20060818'
        GT_ORDER_HEADER_IN-PURCH_NO_C =  '32'.
        GT_ORDER_HEADER_IN-PURCH_NO_S =   '32'.
        GT_ORDER_HEADER_IN-EXCHG_RATE =  GT_FT_SALES-EXCHG_RATE ."'1.00000'
        GT_ORDER_HEADER_IN-CURRENCY = GT_FT_SALES-CURRENCY . " 'EUR'
    ********<<<Checkbox Fields for Sales and Distribution Document Header>>>>>>>>>
        GT_ORDER_HEADER_INX-DOC_TYPE   = 'X'.
        GT_ORDER_HEADER_INX-SALES_ORG  = 'X'.
        GT_ORDER_HEADER_INX-DISTR_CHAN = 'X'.
        GT_ORDER_HEADER_INX-DIVISION   = 'X'.
        GT_ORDER_HEADER_INX-SALES_DIST = 'X'.
        GT_ORDER_HEADER_INX-INCOTERMS1 = 'X'.
        GT_ORDER_HEADER_INX-INCOTERMS2 = 'X'.
        GT_ORDER_HEADER_INX-PMNTTRMS =   'X'.
        GT_ORDER_HEADER_INX-PRICE_DATE = 'X'.
        GT_ORDER_HEADER_INX-PURCH_NO_C = 'X'.
        GT_ORDER_HEADER_INX-PURCH_NO_S = 'X'.
        GT_ORDER_HEADER_INX-EXCHG_RATE =  'X'.
        GT_ORDER_HEADER_INX-CURRENCY = 'X'.
    *****<<<<<<Communication Fields: Sales and Distribution Document Item>>>
        GT_ORDER_ITEMS_IN-ITM_NUMBER = '000010'.
        GT_ORDER_ITEMS_IN-MATERIAL  =  GT_FT_SALES-MATERIAL .
        GT_ORDER_ITEMS_IN-PO_ITM_NO = '32'.
        GT_ORDER_ITEMS_IN-CUST_MAT22 = 'AGNI-IV'.
        GT_ORDER_ITEMS_IN-BILL_DATE = '20060808'.
        GT_ORDER_ITEMS_IN-PLANT = '0001'.
    *GT_ORDER_ITEMS_IN-STORE_LOC = '0001'.
        GT_ORDER_ITEMS_IN-TARGET_QTY = GT_FT_SALES-TARGET_QTY . "'1000'
        GT_ORDER_ITEMS_IN-ITEM_CATEG = GT_FT_SALES-ITEM_CATEG . "'TAN'
        GT_ORDER_ITEMS_IN-MATL_GROUP = GT_FT_SALES-MATL_GROUP . "'01'
        GT_ORDER_ITEMS_IN-PURCH_NO_C = GT_FT_SALES-PURCH_NO_C . "'32'
        GT_ORDER_ITEMS_IN-SALES_DIST = GT_FT_SALES-SALES_DIST . "'000001'
        GT_ORDER_ITEMS_IN-INCOTERMS1 = GT_FT_SALES-INCOTERMS1 . "'CFR'
        GT_ORDER_ITEMS_IN-INCOTERMS2 = GT_FT_SALES-INCOTERMS2 . "'HAMBURG'
        GT_ORDER_ITEMS_IN-PMNTTRMS = GT_FT_SALES-PMNTTRMS  .    "'0001'.
        GT_ORDER_ITEMS_IN-EXCHG_RATE = GT_FT_SALES-EXCHG_RATE . "'1.00000'
        GT_ORDER_ITEMS_IN-PRICE_DATE = GT_FT_SALES-PRICE_DATE . "'20060808'
    *GT_ORDER_ITEMS_IN-SALES_UNIT = 'DZ'.
        GT_ORDER_ITEMS_IN-TRG_QTY_NO = GT_FT_SALES-TRG_QTY_NO . "'23'
        GT_ORDER_ITEMS_IN-DIVISION = GT_FT_SALES-DIVISION   .   "'01'
        GT_ORDER_ITEMS_IN-SALQTYNUM = GT_FT_SALES-SALQTYNUM .   "'32'
        GT_ORDER_ITEMS_IN-GROSS_WGHT = GT_FT_SALES-GROSS_WGHT.  " ' 25272000'
        GT_ORDER_ITEMS_IN-NET_WEIGHT = GT_FT_SALES-NET_WEIGHT.  "'24464000'
        GT_ORDER_ITEMS_IN-UNTOF_WGHT = GT_FT_SALES-UNTOF_WGHT . " 'KG'
    *GT_ORDER_ITEMS_IN-CURRENCY = 'EUR'.
        APPEND  GT_ORDER_ITEMS_IN.
    ****<<<<<<Communication Fields: Sales and Distribution Document Item>>>
        GT_ORDER_ITEMS_INX-ITM_NUMBER = '000010'.
        GT_ORDER_ITEMS_INX-MATERIAL = 'X'.
    *GT_ORDER_ITEMS_INX-PO_ITM_NO = 'X'.
        GT_ORDER_ITEMS_INX-CUST_MAT22 = 'X'.
        GT_ORDER_ITEMS_INX-BILL_DATE = 'X'.
        GT_ORDER_ITEMS_INX-PLANT = 'X'.
    *GT_ORDER_ITEMS_INX-STORE_LOC = 'X'.
        GT_ORDER_ITEMS_INX-TARGET_QTY = 'X'.
        GT_ORDER_ITEMS_INX-ITEM_CATEG = 'X'.
        GT_ORDER_ITEMS_INX-MATL_GROUP = 'X'.
        GT_ORDER_ITEMS_INX-PURCH_NO_C = 'X'.
        GT_ORDER_ITEMS_INX-SALES_DIST = 'X'.
        GT_ORDER_ITEMS_INX-INCOTERMS1 = 'X'.
        GT_ORDER_ITEMS_INX-INCOTERMS2 = 'X'.
        GT_ORDER_ITEMS_INX-PMNTTRMS = 'X'.
        GT_ORDER_ITEMS_INX-EXCHG_RATE = 'X'.
        GT_ORDER_ITEMS_INX-PRICE_DATE = 'X'.
    *GT_ORDER_ITEMS_INX-SALES_UNIT = 'X'.
        GT_ORDER_ITEMS_INX-TRG_QTY_NO = 'X'.
        GT_ORDER_ITEMS_INX-DIVISION = 'X'.
        GT_ORDER_ITEMS_INX-SALQTYNUM = 'X'.
        GT_ORDER_ITEMS_INX-GROSS_WGHT =  'X'.
        GT_ORDER_ITEMS_INX-NET_WEIGHT = 'X'.
        GT_ORDER_ITEMS_INX-UNTOF_WGHT = 'X'.
    *GT_ORDER_ITEMS_IN-CURRENCY = 'x'.
        APPEND  GT_ORDER_ITEMS_INX.
    *****<<<<<<Communications Fields: SD Document Partner: WWW
        GT_ORDER_PARTNERS-PARTN_ROLE =   'WE'.
        GT_ORDER_PARTNERS-PARTN_NUMB =  '0000000057'.
    ***GT_ORDER_PARTNERS-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER . " '000010'.
        APPEND  GT_ORDER_PARTNERS.
    *********<<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>
        GT_ORDER_SCHEDULES_IN-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER." '000010'
        GT_ORDER_SCHEDULES_IN-REQ_QTY = GT_FT_SALES-REQ_QTY .   "'234'
        GT_ORDER_SCHEDULES_IN-DLV_DATE = GT_FT_SALES-DLV_DATE  ."  '20060824'.
        GT_ORDER_SCHEDULES_IN-MS_DATE =  GT_FT_SALES-MS_DATE .  "'20060808'
        GT_ORDER_SCHEDULES_IN-LOAD_DATE = GT_FT_SALES-LOAD_DATE.  " '20060822'
        GT_ORDER_SCHEDULES_IN-GI_DATE = GT_FT_SALES-GI_DATE . " '20060823'
        GT_ORDER_SCHEDULES_IN-TP_DATE = GT_FT_SALES-TP_DATE .   "'20060821'
        APPEND  gt_ORDER_SCHEDULES_IN.
    *********<<<<Communications Fields: SD Document Partner: WWW FLAG>>>>>>>>>>>>>>>>>>
        GT_ORDER_SCHEDULES_INX-ITM_NUMBER = '000010'.
        GT_ORDER_SCHEDULES_INX-REQ_QTY = 'X'.
        GT_ORDER_SCHEDULES_INX-DLV_DATE = 'X'.
        GT_ORDER_SCHEDULES_INX-MS_DATE = 'X'.
        GT_ORDER_SCHEDULES_INX-LOAD_DATE = 'X'.
        GT_ORDER_SCHEDULES_INX-GI_DATE = 'X'.
        GT_ORDER_SCHEDULES_INX-DLV_DATE = 'X'.
        APPEND  gt_ORDER_SCHEDULES_INX.
    ********Communication Fields for Maintaining Conditions in the Order
        GT_ORDER_CONDITIONS_IN-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER ." '000010'
        APPEND GT_ORDER_CONDITIONS_IN.
    ***Communication Fields for Maintaining Conditions in the Order
        GT_ORDER_CONDITIONS_INX-ITM_NUMBER = '000010'.
        APPEND GT_ORDER_CONDITIONS_INX.
        CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
          EXPORTING
       SALESDOCUMENTIN               =
            ORDER_HEADER_IN               = GT_ORDER_HEADER_IN
            ORDER_HEADER_INX              = GT_ORDER_HEADER_INX
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
         IMPORTING
           SALESDOCUMENT                  = GT_SALESDOCUMENT
          TABLES
           RETURN                         = GT_RETURN
            ORDER_ITEMS_IN                = GT_ORDER_ITEMS_IN
            ORDER_ITEMS_INX               = GT_ORDER_ITEMS_INX
            ORDER_PARTNERS                = GT_ORDER_PARTNERS
           ORDER_SCHEDULES_IN            =  GT_ORDER_SCHEDULES_IN
           ORDER_SCHEDULES_INX           =  GT_ORDER_SCHEDULES_INX
           ORDER_CONDITIONS_IN           =  GT_ORDER_CONDITIONS_IN
           ORDER_CONDITIONS_INX          =  GT_ORDER_CONDITIONS_INX
      ORDER_CFGS_REF                =
      ORDER_CFGS_INST               =
      ORDER_CFGS_PART_OF            =
      ORDER_CFGS_VALUE              =
      ORDER_CFGS_BLOB               =
      ORDER_CFGS_VK                 =
      ORDER_CFGS_REFINST            =
      ORDER_CCARD                   =
      ORDER_TEXT                    =
      ORDER_KEYS                    =
      EXTENSIONIN                   =
      PARTNERADDRESSES              =
        IF GT_RETURN-TYPE EQ 'E' .
          E_REC = E_REC + 1.
          READ TABLE GT_RETURN WITH KEY ID = 'V1'.
          FORMAT COLOR COL_NEGATIVE INVERSE ON.
          REC_NO = E_REC + S_REC.
              CONCATENATE TEXT-006 REC_NO ':'
              GT_RETURN-MESSAGE INTO MSG SEPARATED BY SPACE .
              CONDENSE MSG.
              WRITE: / MSG.
          FORMAT COLOR COL_NEGATIVE INVERSE OFF.
      ELSEIF GT_RETURN-TYPE EQ 'S'.
          S_REC = S_REC + 1.
          FORMAT COLOR COL_POSITIVE INVERSE ON.
              MSG = GT_RETURN-MESSAGE.
              CONDENSE MSG.
              WRITE: / MSG .
          FORMAT COLOR COL_POSITIVE INVERSE OFF.
         PERFORM COMMIT_MM.
    ENDIF.
          CLEAR:  GT_RETURN[], MSG.
    ENDFORM.                    " SLALE_UPLOAD_DATA
    *&      Form  COMMIT_MM
          text
    -->  p1        text
    <--  p2        text
    FORM COMMIT_MM .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            WAIT   = 'X'
          IMPORTING
            RETURN = GT_RETURN.
      clear:      GT_ORDER_ITEMS_IN[],GT_ORDER_CONDITIONS_IN[].
    ENDFORM.                    " COMMIT_MM

  • Sales Order Creation with reference to Contract

    Hi all ,
    Existing Setup in the System:
    1)  I have a contract created with a validity period of 30 days. When i create sales order with reference to contract, then i get a pop-up box, from the box i can select my contract.
    2) I have a Lead time configured as 5 days for the Sales document type , I,e when I create sales order I can see my Requested delivery date is always system date + 5 days.
    3) I have a Pricing date configured as Today’s date. Therefore when I create sales order I can see pricing date becomes the system date.
    Execution of Sales Order:
    4) When I create Sales Order with reference to contract document. Always Requested Delivery date is compared with Contract Validity Dates.
    Example: Contract Validity 01/03/2008   -    31/03/2008
    Sales Order: Sales Order Creation date -> 19/03/2008, Pricing Date: 19/03/2008 Requested delivery date 24/03/2008.
    REQUIREMENT IS:
    But my requirement is when i create Sales Order it should consider System date or Pricing Date( since pricing date is today date)  for to compare with contract validity dates.
    Can it be done with standard config or do we need to some type of custom?  Appreciate your help
    Thanks

    Hi ,
    As said when I create Sales Order with reference to contract document. Always Requested Delivery date on Sales Order is checked against Contract Validity Dates.
    But i want Pricing date  in Sales Order should be checked against Contract Validity Dates.
    Can someone suggest me on this?

  • Sales order creation with respect to contracts

    Hi Guys,
    I am trying to create a saleorders with referece to contract for which in the background I configured so that during my sales order creation I see the pop-up box with all existing contracts for a specified sold-to party.
    This process is so painful that order entry people have to manually select from the big list (pop up box consisting of huge list).
    Is there any way so that I can automate this process insetead of selecting contracts from that list.
    Regards
    Krishna

    Hi Ravi,
    Thanks for your solution and could you please give me some more details what is the neame of the user exit.
    and welcome for some more suggestions.
    Thanks
    Krishna
    One way is to create the order with reference to the Contract and then the system will not give the pop up for the existing contracts.
    The other way to automate the process is by using a userexit. Here the system should check all the existing valid contracts for this sold to party and should select the oldest or latest valid contract, as per the client choice.
    Thanks,
    Ravi

  • LSMW Sales Order creation using Bapi method

    Hi folks ,
    iam doing Lsmw bapimethod ,sales order creation .In the step start idoc processing iam getting error "Has Not been Accepted for Processing ",why iam not getting plz let me know points will be awarded for all answers .

    Hi,
              You need to set the IDOC settings in the initial LSMW screen. It will be there in menu path.
           Award points if helpful
    Regards,
    RamaKrishna C

  • Sales order creation using BAPI in LSMW

    Hi ABAPers,
    I am trying to create Sales orders using the BAPI SALESORDER_CREATEFROMDAT2.
    I am supplying the item target quantity in sale units to the field
    E1BPSDITM-- TARGET_QTY. my documents are getting posted but when i go to VA03 to display my documents, the quantity is showing up as 0 for all items. and the document is incomplete.
    please any suggestions on this.
    Regards,
    Raj

    HI Raj M 
    jus refer the following link it has step by step procedure
    http://sapbrain.com/TUTORIALS/TECHNICAL/LSMW_tutorial.html

  • Sales order creation with reference to quote using BAPI

    Hi All,
    I am trying to create a sales order with reference to quote using BAPI BAPI_SALESORDER_CREATEFROMDAT2.
    I am passing the Quote number and preceding doc.category (B) at the header level and
    at item level I am passing the quote number and the line item number in the quote for REF_DOC and REF_DOC_IT.
    The order is created but there seems to be some issue with the document flow.
    I do not see the Reference Doc number at the header level from the Sales order document flow whereas I can see the Reference Doc for each line item.
    In VBFA I can see the Ref.Doc number at the header level along with the Ref.Doc at the line item level.
    Why do you think it is not showing at the header level from Sales Document Document Flow?
    Is there any bug in the standard BAPI or is there any OSS note?
    Any answer would be greatly appreciated.
    Thanks
    Sandeep

    hi,
    Are you giving different quotation numbers in the different line items, if that is the case you will not get that in the header document flow, as it cann't point to all the quotations.
    Thanks,
    Mahesh.

  • BAPI for sales order creation with Reference

    Hello Experts,
    I have a order, with its reference I have to create a new sales order.
    Am looking for BAPi, with which I can create a sales order with a Reference order (which is in my hand), so I checked SE37 with wild cards, but I did not find any!!
    1) Pls. let me know a BAPI
    2) And just like that I do not want to create a new order with the reference(existing) order, I have to change the PO number & order Reason(2 fileds) in newley creationg order, pls. let me know How to do it
    Thank you

    Hi,
    First try to pass these two parameters to BAPI_SALESORDER_CREATEFROMDAT2
    ORDER_HEADER_IN-REFDOCTYPE = Your Sch. Agreement No. (Please Check) and
    ORDER_HEADER_IN-SD_DOC_CAT = 'E'.
    If the above doesnt work ,than try using BAPI "BAPI_SALESDOCUMENT_COPY"
    I hope you are working in SAP R/3 4.6C and above version because i am not sure whether this BAPI is available in lower version.
    Let us know if this helps you..
    Rgds,
    Mayank

  • Is there any BAPI available for sales order creation with reference?

    Hi Experts,
    My requirement is to create sales order with reference for order type.
    Now my billing document number already contains the two items
    one is correct and another is zero quantity.
    I want to create order with reference of billing document but not with zero quantity item.
    Which BAPI I should use and what to pass to ignore zero quantity item?
    Regards,
    RH

    Hi Ronny,
    Try using BAPI_SALESORDER_CREATEFROMDAT2
    Regards,
    Shraddha

  • Problem in lock Sales order create with BAPI BAPI_SALESORDER_CREATEFROMDAT2

    Hi All,
    i have the z program to create the sales order with reff  quotation in SD With BAPI BAPI_SALESORDER_CREATEFROMDAT2.
    this program will  excute every 30 mins .
    Problem: Some times if i excute the program in background it is taking morethan 30mins so second batch excution also gets starting to create the sales order for same quotation then it is creating 2 sales orders at atime with 1 quotation.
    here i am getting duplicate sales orders so i want to lock the creation of duplicate sales order.

    Some solutions
    - Just lock (ENQUEUE) any object at the start of the job(*), if not locked, you can exit or wait in a loop, will be released at end of job (use a _SCOPE '3' so commit work wont release the lock)
    -> This will insure the job runs only once at a time
    - Lock the quotation before calling the BAPI, will be released by the COMMIT_WORK (from where do you fetch the quotation, if it is a customer Z_table, you can use the lock object that you have surely created ?) (use a _scope '2')
    -> This will insure that at most one job will convert a quotation (i suppose you set a "done" flag or status  in the quotation record)
    Read [SAP Locks |http://help.sap.com/abapdocu_70/en/ABENSAP_LOCK.htm] if you are not familiar with the concept of lock in SAP.
    Regards,
    Raymond
    (*) E_TABLEE for table, E_TRDIR for program, anything not required by another process

Maybe you are looking for