Application Development and Automation 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: 
Read only

Sample file data for bapi_salesorder_createfromdat2

Former Member
0 Likes
2,873

Hi all,

I have written a zprogam which calls bapi_salesorder_createfromdat2 to create sales order.

While running it shows the error as

VP Enter Ship-to-party or Sold-to-party

can anyone give me file format with real time data for this bapi

Senthil

3 REPLIES 3
Read only

Former Member
0 Likes
1,034

Hi ,

This is code have a look at it it help you to create a file.

LOOP AT lt_temp1 INTO wa_temp1.
   headerx-doc_type    = 'X'.
    header-sales_org    = wa_temp1-vkorg.
    headerx-sales_org   = 'X'.
    header-purch_no     = wa_temp1-bstnk.
    header-distr_chan   = wa_temp1-vtweg.
    headerx-distr_chan  = 'X'.
    header-division     = wa_temp1-spart.
    header-purch_no_s   = wa_temp1-bstnk.
    headerx-division    = 'X'.
    wa_partner-partn_role = 'AG'.
    wa_partner-partn_numb = wa_temp1-kunnr.
    APPEND wa_partner TO it_partner.
    wa_partner-partn_role = 'WE'.
    wa_partner-partn_numb = wa_temp1-kunnr.
    APPEND wa_partner TO it_partner.
    CLEAR: wa_partner.
    LOOP AT lt_temp2 INTO wa_temp2 WHERE kunnr = wa_temp1-kunnr.
      "AND matnr = wa_temp1-matnr.
*wa_item-itm_number = wa_temp2-posnr .
      wa_item-material   = wa_temp2-matnr.
      wa_item-plant      = wa_temp2-werks.
      wa_item-req_qty    = wa_temp2-fkimg * 1000.
      wa_item-target_qty = wa_temp2-fkimg * 1000.
      APPEND wa_item TO it_item.
    ENDLOOP.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
      EXPORTING
        order_header_in       = header
*   WITHOUT_COMMIT            = ' '
*   CONVERT_PARVW_AUART       = ' '
     IMPORTING
       salesdocument          = v_vbeln
*   SOLD_TO_PARTY             =
*   SHIP_TO_PARTY             =
*   BILLING_PARTY             =
       return                 = return
      TABLES
       order_items_in         = it_item
       order_partners         = it_partner.
    IF v_vbeln ne space.
      wa_vbeln-vbeln = v_vbeln.
      APPEND wa_vbeln TO lt_vbeln.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
      HIDE wa_vbeln-vbeln.
      CLEAR: wa_partner,header,v_vbeln, wa_temp2.
      REFRESH: it_partner,it_item.
    ELSE.
*    LOOP AT return .
      it_error-srno = idx.
      it_error-err_msg = return-message.
      APPEND it_error.
*    ENDLOOP.
    ENDIF.
    idx = idx + 1.
  ENDLOOP.
ENDFORM.                    " CREAT_BAPI

with regards

nilesh

Read only

0 Likes
1,034

hi nilesh,

thanks a lot.

it works

i have one more doubt

regarding partner roles in which table we can find partner role data 'AG' and 'WE'.

senthil

Read only

Former Member
0 Likes
1,034

Hi,

Just have a look at some at the data present in the VBAK and VBAP table. Try to find the correlations and make data out of it.

Give the same data for both Ship to party and Sold to party. These are your partner details here.

You can use the code as given by Nilesh.