<?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: Reg: Sales document creation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902561#M1144836</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sujeel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the Fm - BAPI_SALESORDER_CREATEFROMDAT2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There pass Header, Hearder X , Item and Itemx parameters. and do the sequential testing of &lt;/P&gt;&lt;P&gt;BAPI_SALESORDER_CREATEFROMDAT2 &amp;amp; BAPI_TRANSACTION_COMMIT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Dec 2008 06:55:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-12-26T06:55:47Z</dc:date>
    <item>
      <title>Reg: Sales document creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902557#M1144832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abapers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As i am new to SD Module, would like to get some ideas from your end. My requirement is to create a sales order using Programming. After creation of sales order it should post to finance. Could anyone help me how this can be done.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 06:14:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902557#M1144832</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T06:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Sales document creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902558#M1144833</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 use BAPI to create salesorder through programming.&lt;/P&gt;&lt;P&gt;you search bapi for it in se37 as BAPI&lt;STRONG&gt;SDORDER&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;you will get related bapis for that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 06:33:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902558#M1144833</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T06:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Sales document creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902559#M1144834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use BAPI_SALESORDER_CREATEFROMDAT2 to create a sales order&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sasi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 06:41:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902559#M1144834</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T06:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Sales document creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902560#M1144835</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 can use BAPI_SALESORDER_CREATEFROMDAT2  to create sales order.&lt;/P&gt;&lt;P&gt;you need  the following  details DocType, Material, Qunatity, Partnertype, Partner number .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 06:54:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902560#M1144835</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T06:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Sales document creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902561#M1144836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sujeel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the Fm - BAPI_SALESORDER_CREATEFROMDAT2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There pass Header, Hearder X , Item and Itemx parameters. and do the sequential testing of &lt;/P&gt;&lt;P&gt;BAPI_SALESORDER_CREATEFROMDAT2 &amp;amp; BAPI_TRANSACTION_COMMIT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 06:55:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902561#M1144836</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T06:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reg: Sales document creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902562#M1144837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  ZSALESORDER.

* Parameters
* Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.

* Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.

* Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.

* Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.

SKIP 1.

* Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.

* Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.

SKIP 1.

* Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
SELECTION-SCREEN END OF LINE.

* Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
SELECTION-SCREEN END OF LINE.

* Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d .
SELECTION-SCREEN END OF LINE.

* Complete Deliver
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text10 FOR FIELD p_autlf.
PARAMETERS: p_autlf TYPE autlf DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.

* 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.
 DATA: lt_schedules_ink    TYPE STANDARD TABLE OF bapisdhead1
                         WITH HEADER LINE.

* Initialization.
INITIALIZATION.
v_text   = 'Order type'.
v_text1  = 'Sales Org'.
v_text2  = 'Distribution channel'.
v_text3  = 'Division'.
v_text4  = 'Sold-to'.
v_text5  = 'Ship-to'.
v_text6  = 'Material'.
v_text7  = 'Quantity'.
v_text9  = 'Plant'.
v_text10 = 'Complete delivery'.

* Start-of-selection.
START-OF-SELECTION.

* Header data

* Sales document type
  header-doc_type = p_auart.
  headerx-doc_type = 'X'.

* Sales organization
  header-sales_org = p_vkorg.
  headerx-sales_org = 'X'.

* Distribution channel
  header-distr_chan  = p_vtweg.
  headerx-distr_chan = 'X'.

* Division
  header-division = p_spart.
  headerx-division = 'X'.

  headerx-updateflag = 'I'.
*Complete delivery
    header-COMPL_DLV = p_autlf.
    header-COMPL_DLV = 'X'.

* Partner data
* Sold to
  partner-partn_role = 'AG'.
  partner-partn_numb = p_sold.
  APPEND partner.

* Ship to
  partner-partn_role = 'WE'.
  partner-partn_numb = p_ship.
  APPEND partner.

* ITEM DATA
  itemx-updateflag = 'I'.

* Line item number.
  item-itm_number = '000010'.
  itemx-itm_number = 'X'.

* Material
  item-material = p_matnr.
  itemx-material = 'X'.

* Plant
  item-plant    = p_plant.
  itemx-plant   = 'X'.

* Quantity
  item-target_qty = p_menge.
  itemx-target_qty = 'X'.

* item category
  itemx-ITEM_CATEG = 'X'.
  APPEND item.
  APPEND itemx.

*   ITEM DATA
  itemx-updateflag = 'I'.

* Line item number.
  item-itm_number = '000020'.
  itemx-itm_number = 'X'.

* Material
  item-material = p_matnr.
  itemx-material = 'X'.

* Plant
  item-plant    = p_plant.
  itemx-plant   = 'X'.

* Quantity
  item-target_qty = p_menge.
  itemx-target_qty = '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.

*   Fill schedule lines
  lt_schedules_in-itm_number = '000020'.
  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  = '000020'.
  lt_schedules_inx-sched_line  = '0001'.
  lt_schedules_inx-updateflag  = 'X'.
  lt_schedules_inx-req_qty     = 'X'.
  APPEND lt_schedules_inx.

* Call the BAPI to create the sales order.
  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 the work.
    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;Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 10:58 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2008 09:10:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-sales-document-creation/m-p/4902562#M1144837</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-26T09:10:21Z</dc:date>
    </item>
  </channel>
</rss>

