<?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: Bapi for Sales Order in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970925#M701113</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Satish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is absolutely no need to create a BAPI for such fundamental business objects with SAP because they are already there:&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;BAPI_SALESORDER_CREATEFROMDAT2&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run into trouble using this BAPI with certain &amp;lt;i&amp;gt;document types&amp;lt;/i&amp;gt; you can use the underlying RFC-enabled function module &amp;lt;b&amp;gt;SD_SALESDOCUMENT_CREATE&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 Nov 2007 22:28:56 GMT</pubDate>
    <dc:creator>uwe_schieferstein</dc:creator>
    <dc:date>2007-11-03T22:28:56Z</dc:date>
    <item>
      <title>Bapi for Sales Order</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970924#M701112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi experts,&lt;/P&gt;&lt;P&gt;iam new to this forum.&lt;/P&gt;&lt;P&gt;i have completed  ABAP and now learning XAPPS -&amp;gt; Bapi.&lt;/P&gt;&lt;P&gt;I want to how to &amp;lt;u&amp;gt;create a Bapi to Create a Sales Order (VD01) .&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;please guide me as i am a beginner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bye&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2007 15:46:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970924#M701112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-03T15:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for Sales Order</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970925#M701113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Satish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is absolutely no need to create a BAPI for such fundamental business objects with SAP because they are already there:&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;BAPI_SALESORDER_CREATEFROMDAT2&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run into trouble using this BAPI with certain &amp;lt;i&amp;gt;document types&amp;lt;/i&amp;gt; you can use the underlying RFC-enabled function module &amp;lt;b&amp;gt;SD_SALESDOCUMENT_CREATE&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2007 22:28:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970925#M701113</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-11-03T22:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for Sales Order</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970926#M701114</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;You can use the BAPI BAPI_SALESDOCU_CREATEFROMDATA1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this sample code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PARAMETERS: p_auart TYPE auart OBLIGATORY.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
PARAMETERS: p_spart TYPE vtweg OBLIGATORY.

PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.

*ITEM
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
PARAMETERS: p_itcat TYPE pstyv   OBLIGATORY.

* DATA DECLARATIONS.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item    LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx   LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
DATA: return  LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                         WITH HEADER LINE.
DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                         WITH HEADER LINE.

* HEADER DATA
header-doc_type = p_auart.
headerx-doc_type = 'X'.

header-sales_org = p_vkorg.
headerx-sales_org = 'X'.

header-distr_chan  = p_vtweg.
headerx-distr_chan = 'X'.

header-division = p_spart.
headerx-division = 'X'.

headerx-updateflag = 'I'.

* PARTNER DATA
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.

partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.

* ITEM DATA
itemx-updateflag = 'I'.

item-itm_number = '000010'.
itemx-itm_number = 'X'.


item-material = p_matnr.
itemx-material = 'X'.

item-plant    = p_plant.
itemx-plant   = 'X'.

item-target_qty = p_menge.
itemx-target_qty = 'X'.

item-target_qu = 'EA'.
itemx-target_qu = 'X'.

item-item_categ = p_itcat.
itemx-item_categ = 'X'.

APPEND item.
APPEND itemx.

*   Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty    = p_menge.
APPEND lt_schedules_in.

*   Fill schedule line flags
lt_schedules_inx-itm_number  = '000010'.
lt_schedules_inx-sched_line  = '0001'.
lt_schedules_inx-updateflag  = 'X'.
lt_schedules_inx-req_qty     = 'X'.
APPEND lt_schedules_inx.

* Call the BAPI
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
     EXPORTING
          sales_header_in     = header
          sales_header_inx    = headerx
     IMPORTING
          salesdocument_ex    = v_vbeln
     TABLES
          return              = return
          sales_items_in      = item
          sales_items_inx     = itemx
          sales_schedules_in  = lt_schedules_in
          sales_schedules_inx = lt_schedules_inx
          sales_partners      = partner.

* Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
  EXIT.
ENDLOOP.

IF sy-subrc = 0.

  WRITE: / 'Error in creating document'.

ELSE.

  COMMIT WORK AND WAIT.

  WRITE: / 'Document ', v_vbeln, ' created'.

ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Nov 2007 00:44:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970926#M701114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-04T00:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for Sales Order</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970927#M701115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Satish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are some links for BAPI and code for sales order creation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can get good help form the following links,&lt;/P&gt;&lt;P&gt;BAPI-step by step&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapgenie.com/abap/bapi/example.htm" target="test_blank"&gt;http://www.sapgenie.com/abap/bapi/example.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;list of all bapis&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.planetsap.com/LIST_ALL_BAPIs.htm" target="test_blank"&gt;http://www.planetsap.com/LIST_ALL_BAPIs.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;for BAPI's&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/abap/bapiintro.pdf" target="test_blank"&gt;http://www.sappoint.com/abap/bapiintro.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/abap/bapiprg.pdf" target="test_blank"&gt;http://www.sappoint.com/abap/bapiprg.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/abap/bapiactx.pdf" target="test_blank"&gt;http://www.sappoint.com/abap/bapiactx.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/abap/bapilst.pdf" target="test_blank"&gt;http://www.sappoint.com/abap/bapilst.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/abap/bapiexer.pdf" target="test_blank"&gt;http://www.sappoint.com/abap/bapiexer.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://service.sap.com/ale" target="test_blank"&gt;http://service.sap.com/ale&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://service.sap.com/bapi" target="test_blank"&gt;http://service.sap.com/bapi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf" target="test_blank"&gt;http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf" target="test_blank"&gt;http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf" target="test_blank"&gt;http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.planetsap.com/Bapi_main_page.htm" target="test_blank"&gt;http://www.planetsap.com/Bapi_main_page.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.topxml.com/sap/sap_idoc_xml.asp" target="test_blank"&gt;http://www.topxml.com/sap/sap_idoc_xml.asp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/" target="test_blank"&gt;http://www.sapdevelopment.co.uk/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf" target="test_blank"&gt;http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf&lt;/A&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;&lt;P&gt;Also refer to the following links..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/www.sappoint.com/abap/bapiintro.pdf" target="test_blank"&gt;www.sappoint.com/abap/bapiintro.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/www.sap-img.com/bapi.htm" target="test_blank"&gt;www.sap-img.com/bapi.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/www.sap-img.com/abap/bapi-conventions.htm" target="test_blank"&gt;www.sap-img.com/abap/bapi-conventions.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/www.planetsap.com/Bapi_main_page.htm" target="test_blank"&gt;www.planetsap.com/Bapi_main_page.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/www.sapgenie.com/abap/bapi/index.htm" target="test_blank"&gt;www.sapgenie.com/abap/bapi/index.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.htl" target="test_blank"&gt;http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.htl&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://techrepublic.com.com/5100-6329-1051160.html#" target="test_blank"&gt;http://techrepublic.com.com/5100-6329-1051160.html#&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/bapi.htm" target="test_blank"&gt;http://www.sap-img.com/bapi.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/bapi-conventions.htm" target="test_blank"&gt;http://www.sap-img.com/abap/bapi-conventions.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sappoint.com/abap/bapiintro.pdf" target="test_blank"&gt;http://www.sappoint.com/abap/bapiintro.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://sap-img.com/bapi.htm" target="test_blank"&gt;http://sap-img.com/bapi.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;BAPI_SALESORDER_CREATEFROMDAT1&lt;/P&gt;&lt;P&gt;BAPI_SALESORDER_CREATEFROMDAT2 &lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ZBAPI_SALES.

DATA: order_header_in type bapisdhd1.
DATA: order_partners type table of BAPIPARNR.
data: return type table of BAPIRET2.
data: errmsg type BAPIRET2.

PARAMETER: p_vbeln LIKE vbrk-vbeln OBLIGATORY,
p_kunnr LIKE kuagv-kunnr OBLIGATORY.

START-OF-SELECTION.
order_header_in-doc_type = 'OR'.
order_header_in-sales_org = '1000'.
order_header_in-distr_chan = '30'.
order_header_in-division = '00'.
order_header_in-ref_doc = p_vbeln.
ORDER_HEADER_IN-REFDOCTYPE = 'ZQSR'.
ORDER_HEADER_IN-SD_DOC_CAT = 'C'.
CLEAR order_partners.
order_partners-partn_numb = p_kunnr.
order_partners-partn_role = 'SP'.
APPEND order_partners.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
* SALESDOCUMENTIN =
order_header_in = order_header_in
* ORDER_HEADER_INX =
* SENDER =
* BINARY_RELATIONSHIPTYPE =
* INT_NUMBER_ASSIGNMENT =
* BEHAVE_WHEN_ERROR =
* LOGIC_SWITCH =
* TESTRUN =
* CONVERT = ' '
IMPORTING
salesdocument = sd_vbeln
TABLES
RETURN = return
* ORDER_ITEMS_IN =
* ORDER_ITEMS_INX =
order_partners = order_partners
* ORDER_SCHEDULES_IN =
* ORDER_SCHEDULES_INX =
* ORDER_CONDITIONS_IN =
* 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 =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful,&lt;/P&gt;&lt;P&gt;Aleem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 03:46:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-sales-order/m-p/2970927#M701115</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-05T03:46:08Z</dc:date>
    </item>
  </channel>
</rss>

