Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Home arrow Sample Code arrow ABAP Reports arrow Program to create test sales order
Program to create test sales order PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Anon.   
Thursday, 22 February 2007
Test program that creates a sales order using BAPI_SALESORDER_CREATEFROMDAT2 REPORT ztest .

DATA: zorder_header_in LIKE bapisdhd1,
      zorder_items_in LIKE bapisditm OCCURS 0 WITH
HEADER LINE,
      zorder_partners LIKE bapiparnr OCCURS 0 WITH
HEADER LINE,
      zorder_conditions_in LIKE bapicond OCCURS 0 WITH
HEADER LINE,
      zorder_ccard LIKE bapiccard OCCURS 0 WITH HEADER
LINE,
      zorder_schedules_in LIKE bapischdl OCCURS 0 WITH
HEADER LINE,
      t_belnr LIKE bapivbeln-vbeln,
      return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

* Header Data - REQUIRED
-----------------------------------------------
*** REQUIRED ***
zorder_header_in-doc_type = 'ZN'.       "Document type
zorder_header_in-sales_org = '0010'.    "Sales Org
zorder_header_in-distr_chan = '10'.     "Distribution
Chanel
zorder_header_in-division = '10'.       "Division
zorder_header_in-purch_no_c = sy-uzeit. "PO Number
*** END REQUIRED ***

zorder_header_in-sales_grp = '030'.     "Sales Group
zorder_header_in-sales_off = '0010'.    "Sales Office
zorder_header_in-purch_date = sy-datum. "Purchase
Order Date
zorder_header_in-incoterms1 = 'C&F'.                  
     "Incoterms1
zorder_header_in-pmnttrms = 'CODK'.     "Payment Terms
zorder_header_in-dlv_block = '01'.      "Delivery
Block
zorder_header_in-ship_cond = '02'.      "Shipping
Conditions

* Item Data Loop - REQUIRED
--------------------------------------------
*** REQUIRED ***
zorder_items_in-itm_number = '000010'.
zorder_items_in-material = '000000000010000017'.
*** END REQUIRED ***
zorder_items_in-dlv_prio = '02'.
zorder_items_in-val_type = ''.
APPEND zorder_items_in.

zorder_items_in-itm_number = '000020'.
zorder_items_in-material = '000000000010000019'.
APPEND zorder_items_in.

zorder_items_in-itm_number = '000030'.
zorder_items_in-material = '000000000010026949'.
APPEND zorder_items_in.
* End Item Data Loop
---------------------------------------------------

* Schedule Loop - REQUIRED FOR QUANTITY
--------------------------------
*** REQUIRED ***
zorder_schedules_in-itm_number = '000010'.
zorder_schedules_in-req_qty = '1'.
*** END REQUIRED ***
APPEND zorder_schedules_in.

zorder_schedules_in-itm_number = '000020'.
zorder_schedules_in-req_qty = '1'.
APPEND zorder_schedules_in.

zorder_schedules_in-itm_number = '000030'.
zorder_schedules_in-req_qty = '1'.
APPEND zorder_schedules_in.
* End Schedule Loop
----------------------------------------------------

* Partner Loop - REQUIRED
----------------------------------------------
* Partner AG is required. If WE is not specified then
WE = AG.
*** REQUIRED ***
zorder_partners-partn_role = 'AG'.
zorder_partners-partn_numb = '0000010105'.
*** END REQUIRED ***
APPEND zorder_partners.

* One Time Ship to
zorder_partners-partn_role = 'WE'.
zorder_partners-partn_numb = '0000010000'.
zorder_partners-title      = 'Mr.'.
zorder_partners-name       = 'Kevin'.
zorder_partners-name_2     = 'Wilson'.
zorder_partners-street     = 'There Street'.
zorder_partners-city       = 'New York'.
zorder_partners-region     = 'NY'.
zorder_partners-postl_code = '10004'.
zorder_partners-country    = 'US'.
zorder_partners-telephone  = '123-123-1234'.
APPEND zorder_partners.

clear zorder_partners.
zorder_partners-partn_role = 'CR'.
zorder_partners-partn_numb = '0000005030'.
APPEND zorder_partners.
* End Partner Loop
-----------------------------------------------------

* Condition Loop
-------------------------------------------------------
* If itm_number='000000' then the condition applies at
the header level
zorder_conditions_in-itm_number = '000010'.
*** REQUIRED ***
zorder_conditions_in-cond_type = 'PN00'.
zorder_conditions_in-cond_value = '100'.
*** END REQUIRED ***
APPEND zorder_conditions_in.

* Credit card
----------------------------------------------------------
*** REQUIRED ***
zorder_ccard-cc_type = 'VISA'.
zorder_ccard-cc_number = '4111111111111111'.
*** END REQUIRED ***
zorder_ccard-cc_valid_t = '20010303'.
zorder_ccard-cc_name = 'Kevin'.
APPEND zorder_ccard.

* Call the BAPI to create the sales order.
* The BAPI is called without issuing a commit to the
database
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
     EXPORTING
          order_header_in     = zorder_header_in
     IMPORTING
          salesdocument       = t_belnr
     TABLES
          return              = return
          order_items_in      = zorder_items_in
          order_partners      = zorder_partners
          order_schedules_in  = zorder_schedules_in
          order_conditions_in = zorder_conditions_in
          order_ccard         = zorder_ccard.

* Loop through the return messages
LOOP AT return.
  WRITE: /1 return-message.
ENDLOOP.

* Issue commit to database
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

* Write out order number
WRITE: /1 'Order Number', t_belnr.

Related Items:

 
< Prev   Next >

Google Search

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor