SAMPLE SCRIPT TO CREATE SALES ORDER USING OE_ORDER_PUB.PROCESS_ORDER

来源:互联网 发布:杭州摄影俱乐部 知乎 编辑:程序博客网 时间:2024/06/02 05:43

Use Of Oe_Order_Pub.Process_Order To Create Sale Order
Process Order API is a PL/SQL packaged procedure which can be used to manipulate the sales order data by performing Insert, update or delete operation on the following sales Order business object entities.
Analogous to other public API’s, Process Order API also validates the data before inserting them into the application tables.
Though Process Order API has packaged procedures which will insert, update, delete data into the tables, they can not be run on their own. Either they need to be called from another package procedure or can be executed as PL/SQL block via the sql*plus.

  1. DECLARE  
  2.   l_api_version_number NUMBER := 1;  
  3.   l_return_status      VARCHAR2(2000);  
  4.   l_msg_count          NUMBER;  
  5.   l_msg_data           VARCHAR2(2000);  
  6.   -- PARAMETERS  
  7.   l_debug_level NUMBER := 5;   -- OM DEBUG LEVEL (MAX 5)  
  8.   l_org         NUMBER := 308; -- OPERATING UNIT  
  9.   l_no_orders   NUMBER := 1;   -- NO OF ORDERS  
  10.   -- INPUT VARIABLES FOR PROCESS_ORDER API  
  11.   l_header_rec oe_order_pub.header_rec_type;  
  12.   l_line_tbl oe_order_pub.line_tbl_type;  
  13.   l_action_request_tbl oe_order_pub.Request_Tbl_Type;  
  14.   -- OUT VARIABLES FOR PROCESS_ORDER API  
  15.   l_header_rec_out oe_order_pub.header_rec_type;  
  16.   l_header_val_rec_out oe_order_pub.header_val_rec_type;  
  17.   l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;  
  18.   l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;  
  19.   l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;  
  20.   l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;  
  21.   l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;  
  22.   l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;  
  23.   l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;  
  24.   l_line_tbl_out oe_order_pub.line_tbl_type;  
  25.   l_line_val_tbl_out oe_order_pub.line_val_tbl_type;  
  26.   l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;  
  27.   l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;  
  28.   l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;  
  29.   l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;  
  30.   l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;  
  31.   l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;  
  32.   l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;  
  33.   l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;  
  34.   l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;  
  35.   l_action_request_tbl_out oe_order_pub.request_tbl_type;  
  36.   l_msg_index  NUMBER;  
  37.   l_data       VARCHAR2(2000);  
  38.   l_loop_count NUMBER;  
  39.   l_debug_file VARCHAR2(200);  
  40. BEGIN  
  41.   -- INITIALIZATION REQUIRED FOR R12  
  42.   mo_global.set_policy_context ('S', l_org);  
  43.   mo_global.init('ONT');  
  44.   -- INITIALIZE DEBUG INFO  
  45.   IF (l_debug_level > 0) THEN  
  46.     l_debug_file   := OE_DEBUG_PUB.Set_Debug_Mode('FILE');  
  47.     oe_debug_pub.initialize;  
  48.     oe_debug_pub.setdebuglevel(l_debug_level);  
  49.     Oe_Msg_Pub.initialize;  
  50.   END IF;  
  51.   -- INITIALIZE ENVIRONMENT  
  52.   fnd_global.apps_initialize (user_id => 2083, resp_id => 21623, resp_appl_id => 660);  
  53.   -- INITIALIZE HEADER RECORD  
  54.   l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;  
  55.   -- POPULATE REQUIRED ATTRIBUTES  
  56.   l_header_rec.operation               := OE_GLOBALS.G_OPR_CREATE;  
  57.   l_header_rec.TRANSACTIONAL_CURR_CODE := 'AUD';  
  58.   l_header_rec.pricing_date            := SYSDATE;  
  59.   l_header_rec.cust_po_number          := 'TSTPO30';  
  60.   l_header_rec.sold_to_org_id          := 1006685;  
  61.   l_header_rec.price_list_id           := 33019;  
  62.   l_header_rec.ordered_date            := SYSDATE;  
  63.   l_header_rec.shipping_method_code    := '000001_Toll IPEC_T_2T5DGRD';  
  64.   l_header_rec.sold_from_org_id        := 308;  
  65.   l_header_rec.ship_from_org_id        := 381;  
  66.   l_header_rec.ship_to_org_id          := 2005460;  
  67.   l_header_rec.salesrep_id             := 100000069;  
  68.   l_header_rec.flow_status_code        :='ENTERED';  
  69.   l_header_rec.order_type_id           := 5389;  
  70.   -- REQUIRED HEADER DFF INFORMATIONS  
  71.   l_header_rec.attribute1  :=193;        -- Entering Branch  
  72.   l_header_rec.attribute3  := 'Y';       -- Indexation applicable  
  73.   l_header_rec.attribute5  := '2.5';     -- Indexation Tolerance percentage  
  74.   l_header_rec.attribute7  := 100000045; -- Field Sales representative  
  75.   l_header_rec.attribute11 := '100';     -- Indexation Applicability  
  76.   -- INITIALIZE ACTION REQUEST RECORD  
  77.   l_action_request_tbl(1) := OE_ORDER_PUB.G_MISS_REQUEST_REC;  
  78.   -- INITIALIZE LINE RECORD  
  79.   l_line_tbl(1)                   := OE_ORDER_PUB.G_MISS_LINE_REC;  
  80.   l_line_tbl(1).operation         := OE_GLOBALS.G_OPR_CREATE; -- Mandatory Operation to Pass  
  81.   l_line_tbl(1).inventory_item_id := 102775;  
  82.   l_line_tbl(1).ordered_quantity  := 1;  
  83.   l_line_tbl(1).ship_from_org_id  := 381;  
  84.   l_line_tbl(1).subinventory      := 'SELLABLE';  
  85.   -- REQUIRED LINE DFF INFORMATIONS  
  86.   l_line_tbl(1).attribute2  := '20.99998'-- Gross Margin  
  87.   l_line_tbl(1).attribute3  := '2.493288'-- Business Cost  
  88.   l_line_tbl(1).attribute10 := '1000';     -- Original Cust Requested Qty  
  89.   l_line_tbl(1).attribute11 := '662.772';  -- Baseline Margin  
  90.   l_line_tbl(1).attribute16 := 'DBP';      -- Buy Price Basis  
  91.   FOR i IN 1..l_no_orders  
  92.   LOOP -- BEGIN LOOP  
  93.     -- CALLTO PROCESS ORDER API  
  94.     oe_order_pub.process_order( p_org_id => l_org, p_operating_unit => NULL, p_api_version_number => l_api_version_number, p_header_rec => l_header_rec, p_line_tbl => l_line_tbl, p_action_request_tbl => l_action_request_tbl,  
  95.     -- OUT variables  
  96.     x_header_rec => l_header_rec_out, x_header_val_rec => l_header_val_rec_out, x_header_adj_tbl => l_header_adj_tbl_out, x_header_adj_val_tbl => l_header_adj_val_tbl_out, x_header_price_att_tbl => l_header_price_att_tbl_out, x_header_adj_att_tbl => l_header_adj_att_tbl_out, x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out, x_header_scredit_tbl => l_header_scredit_tbl_out, x_header_scredit_val_tbl => l_header_scredit_val_tbl_out, x_line_tbl => l_line_tbl_out, x_line_val_tbl => l_line_val_tbl_out, x_line_adj_tbl => l_line_adj_tbl_out, x_line_adj_val_tbl => l_line_adj_val_tbl_out, x_line_price_att_tbl => l_line_price_att_tbl_out, x_line_adj_att_tbl => l_line_adj_att_tbl_out, x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out, x_line_scredit_tbl => l_line_scredit_tbl_out, x_line_scredit_val_tbl => l_line_scredit_val_tbl_out, x_lot_serial_tbl => l_lot_serial_tbl_out, x_lot_serial_val_tbl => l_lot_serial_val_tbl_out, x_action_request_tbl => l_action_request_tbl_out, x_return_status =>  
  97.     l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data);  
  98.     -- CHECK RETURN STATUS  
  99.     IF l_return_status  = FND_API.G_RET_STS_SUCCESS THEN  
  100.       IF (l_debug_level > 0) THEN  
  101.         DBMS_OUTPUT.PUT_LINE('Sales Order Successfully Created');  
  102.       END IF;  
  103.       COMMIT;  
  104.     ELSE  
  105.       IF (l_debug_level > 0) THEN  
  106.         DBMS_OUTPUT.PUT_LINE('Failed to Create Sales Order');  
  107.       END IF;  
  108.       ROLLBACK;  
  109.     END IF;  
  110.   END LOOP;  
  111.   -- DISPLAY RETURN STATUS FLAGS  
  112.   IF (l_debug_level > 0) THEN  
  113.     DBMS_OUTPUT.PUT_LINE('Process Order Return Status is: ========>' l_return_status);  
  114.     DBMS_OUTPUT.PUT_LINE('Process Order msg data is: ===========>' l_msg_data);  
  115.     DBMS_OUTPUT.PUT_LINE('Process Order Message Count is:=======>' l_msg_count);  
  116.     DBMS_OUTPUT.PUT_LINE('Sales Order Created is:===============>' TO_CHAR(l_header_rec_out.order_number));  
  117.     DBMS_OUTPUT.PUT_LINE('Booked Flag for the Sales Order is:======>' l_header_rec_out.booked_flag);  
  118.     DBMS_OUTPUT.PUT_LINE('Header_id for the Sales Order is:========>' l_header_rec_out.header_id);  
  119.     DBMS_OUTPUT.PUT_LINE('Flow_Status_Code For the Sales Order is=>:' l_header_rec_out.flow_status_code);  
  120.   END IF;  
  121.   -- DISPLAY ERROR MSGS  
  122.   IF (l_debug_level > 0) THEN  
  123.     FOR i IN 1 .. l_msg_count  
  124.     LOOP  
  125.       oe_msg_pub.get( p_msg_index => i ,p_encoded => Fnd_Api.G_FALSE ,p_data => l_data ,p_msg_index_out => l_msg_index);  
  126.       DBMS_OUTPUT.PUT_LINE('message is:' l_data);  
  127.       DBMS_OUTPUT.PUT_LINE('message index is:' l_msg_index);  
  128.     END LOOP;  
  129.   END IF;  
  130.   IF (l_debug_level > 0) THEN  
  131.     DBMS_OUTPUT.PUT_LINE( 'Debug = ' OE_DEBUG_PUB.G_DEBUG);  
  132.     DBMS_OUTPUT.PUT_LINE( 'Debug Level = ' TO_CHAR(OE_DEBUG_PUB.G_DEBUG_LEVEL));  
  133.     DBMS_OUTPUT.PUT_LINE( 'Debug File =' OE_DEBUG_PUB.G_DIR'/'OE_DEBUG_PUB.G_FILE);  
  134.     OE_DEBUG_PUB.DEBUG_OFF;  
  135.   END IF;  
  136. END;  

Related Data ===Table Names

    Order Header===> OE_ORDER_HEADERS_ALL
    Order Line===> OE_ORDER_LINES_ALL
    Order Price Adjustments===> OE_PRICE_ADJUSTMENTS
    Order Sales Credits===> OE_SALES_CREDITS
    Order Pricing Attributes===> OE_ORDER_PRICE_ATTRIBS
    Order Adjustment Attributes===> OE_PRICE_ADJ_ATTRIBS
    Order Adjustment Associations===> OE_PRICE_ADJ_ASSOCS
    Line Sales Credits===> OE_SALES_CREDITS
    Line Price Adjustments> OE_PRICE_ADJUSTMENTS
    Line Pricing Attributes===> OE_ORDER_PRICE_ATTRIBS
    Line Adjustment Attributes===> OE_PRICE_ADJ_ATTRIBS
    Line Adjustment Associations===> OE_PRICE_ADJ_ASSOCS
    Lot Serial Numbers ===>OE_LOT_SERIAL_NUMBERS
0 0
原创粉丝点击