SAMPLE SCRIPT TO CREATE SALES ORDER USING OE_ORDER_PUB.PROCESS_ORDER

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.

DECLARE
  l_api_version_number NUMBER := 1;
  l_return_status      VARCHAR2(2000);
  l_msg_count          NUMBER;
  l_msg_data           VARCHAR2(2000);
  -- PARAMETERS
  l_debug_level NUMBER := 5;   -- OM DEBUG LEVEL (MAX 5)
  l_org         NUMBER := 308; -- OPERATING UNIT
  l_no_orders   NUMBER := 1;   -- NO OF ORDERS
  -- INPUT VARIABLES FOR PROCESS_ORDER API
  l_header_rec oe_order_pub.header_rec_type;
  l_line_tbl oe_order_pub.line_tbl_type;
  l_action_request_tbl oe_order_pub.Request_Tbl_Type;
  -- OUT VARIABLES FOR PROCESS_ORDER API
  l_header_rec_out oe_order_pub.header_rec_type;
  l_header_val_rec_out oe_order_pub.header_val_rec_type;
  l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
  l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
  l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
  l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
  l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
  l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
  l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
  l_line_tbl_out oe_order_pub.line_tbl_type;
  l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
  l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
  l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
  l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
  l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
  l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
  l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
  l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
  l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
  l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
  l_action_request_tbl_out oe_order_pub.request_tbl_type;
  l_msg_index  NUMBER;
  l_data       VARCHAR2(2000);
  l_loop_count NUMBER;
  l_debug_file VARCHAR2(200);
BEGIN
  -- INITIALIZATION REQUIRED FOR R12
  mo_global.set_policy_context ('S', l_org);
  mo_global.init('ONT');
  -- INITIALIZE DEBUG INFO
  IF (l_debug_level > 0) THEN
    l_debug_file   := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
    oe_debug_pub.initialize;
    oe_debug_pub.setdebuglevel(l_debug_level);
    Oe_Msg_Pub.initialize;
  END IF;
  -- INITIALIZE ENVIRONMENT
  fnd_global.apps_initialize (user_id => 2083, resp_id => 21623, resp_appl_id => 660);
  -- INITIALIZE HEADER RECORD
  l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
  -- POPULATE REQUIRED ATTRIBUTES
  l_header_rec.operation               := OE_GLOBALS.G_OPR_CREATE;
  l_header_rec.TRANSACTIONAL_CURR_CODE := 'AUD';
  l_header_rec.pricing_date            := SYSDATE;
  l_header_rec.cust_po_number          := 'TSTPO30';
  l_header_rec.sold_to_org_id          := 1006685;
  l_header_rec.price_list_id           := 33019;
  l_header_rec.ordered_date            := SYSDATE;
  l_header_rec.shipping_method_code    := '000001_Toll IPEC_T_2T5DGRD';
  l_header_rec.sold_from_org_id        := 308;
  l_header_rec.ship_from_org_id        := 381;
  l_header_rec.ship_to_org_id          := 2005460;
  l_header_rec.salesrep_id             := 100000069;
  l_header_rec.flow_status_code        :='ENTERED';
  l_header_rec.order_type_id           := 5389;
  -- REQUIRED HEADER DFF INFORMATIONS
  l_header_rec.attribute1  :=193;        -- Entering Branch
  l_header_rec.attribute3  := 'Y';       -- Indexation applicable
  l_header_rec.attribute5  := '2.5';     -- Indexation Tolerance percentage
  l_header_rec.attribute7  := 100000045; -- Field Sales representative
  l_header_rec.attribute11 := '100';     -- Indexation Applicability
  -- INITIALIZE ACTION REQUEST RECORD
  l_action_request_tbl(1) := OE_ORDER_PUB.G_MISS_REQUEST_REC;
  -- INITIALIZE LINE RECORD
  l_line_tbl(1)                   := OE_ORDER_PUB.G_MISS_LINE_REC;
  l_line_tbl(1).operation         := OE_GLOBALS.G_OPR_CREATE; -- Mandatory Operation to Pass
  l_line_tbl(1).inventory_item_id := 102775;
  l_line_tbl(1).ordered_quantity  := 1;
  l_line_tbl(1).ship_from_org_id  := 381;
  l_line_tbl(1).subinventory      := 'SELLABLE';
  -- REQUIRED LINE DFF INFORMATIONS
  l_line_tbl(1).attribute2  := '20.99998'; -- Gross Margin
  l_line_tbl(1).attribute3  := '2.493288'; -- Business Cost
  l_line_tbl(1).attribute10 := '1000';     -- Original Cust Requested Qty
  l_line_tbl(1).attribute11 := '662.772';  -- Baseline Margin
  l_line_tbl(1).attribute16 := 'DBP';      -- Buy Price Basis
  FOR i IN 1..l_no_orders
  LOOP -- BEGIN LOOP
    -- CALLTO PROCESS ORDER API
    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,
    -- OUT variables
    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 =>
    l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data);
    -- CHECK RETURN STATUS
    IF l_return_status  = FND_API.G_RET_STS_SUCCESS THEN
      IF (l_debug_level > 0) THEN
        DBMS_OUTPUT.PUT_LINE('Sales Order Successfully Created');
      END IF;
      COMMIT;
    ELSE
      IF (l_debug_level > 0) THEN
        DBMS_OUTPUT.PUT_LINE('Failed to Create Sales Order');
      END IF;
      ROLLBACK;
    END IF;
  END LOOP;
  -- DISPLAY RETURN STATUS FLAGS
  IF (l_debug_level > 0) THEN
    DBMS_OUTPUT.PUT_LINE('Process Order Return Status is: ========>' l_return_status);
    DBMS_OUTPUT.PUT_LINE('Process Order msg data is: ===========>' l_msg_data);
    DBMS_OUTPUT.PUT_LINE('Process Order Message Count is:=======>' l_msg_count);
    DBMS_OUTPUT.PUT_LINE('Sales Order Created is:===============>' TO_CHAR(l_header_rec_out.order_number));
    DBMS_OUTPUT.PUT_LINE('Booked Flag for the Sales Order is:======>' l_header_rec_out.booked_flag);
    DBMS_OUTPUT.PUT_LINE('Header_id for the Sales Order is:========>' l_header_rec_out.header_id);
    DBMS_OUTPUT.PUT_LINE('Flow_Status_Code For the Sales Order is=>:' l_header_rec_out.flow_status_code);
  END IF;
  -- DISPLAY ERROR MSGS
  IF (l_debug_level > 0) THEN
    FOR i IN 1 .. l_msg_count
    LOOP
      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);
      DBMS_OUTPUT.PUT_LINE('message is:' l_data);
      DBMS_OUTPUT.PUT_LINE('message index is:' l_msg_index);
    END LOOP;
  END IF;
  IF (l_debug_level > 0) THEN
    DBMS_OUTPUT.PUT_LINE( 'Debug = ' OE_DEBUG_PUB.G_DEBUG);
    DBMS_OUTPUT.PUT_LINE( 'Debug Level = ' TO_CHAR(OE_DEBUG_PUB.G_DEBUG_LEVEL));
    DBMS_OUTPUT.PUT_LINE( 'Debug File =' OE_DEBUG_PUB.G_DIR'/'OE_DEBUG_PUB.G_FILE);
    OE_DEBUG_PUB.DEBUG_OFF;
  END IF;
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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SELECT bs.sample_id, bs.item_id, bs.report_id, bs.order_no, bs.order_id, bs.order_business_type, bs.commission_date, bs.customer_name, bs.applicant, bs.phone, bs.receive_user_name, bs.contract_no, bs.special_requirements, bs.report_org_name, bs.report_org_address, bs.sample_name, bs.standard_instrument_name, bs.complete_day, bs.sample_remark AS remark, bs.standard_instrument_id, bs.sample_no, bs.factory_number, bs.item_name, /*bs.item_quantity,*/ bs.inspection_type, bs.mandatory_flag, bs.test_quantity, bs.sample_state, bs.current_site, bs.plan_complete_date, bs.affix, bs.ranges, bs.grade, bs.factory, bs.calibrat_point, bs.apply_dept, bs.specification, bs.final_fee, bs.service_type, CASE WHEN bs.actual_complete_date IS NOT NULL THEN DATEDIFF( bs.plan_complete_date, bs.actual_complete_date ) ELSE datediff( bs.plan_complete_date, now()) END AS surplus_days, bs.report_no, bs.is_report_back, bs.back_reason AS report_back_reason, bs.is_just_certificate, bs.report_state, bs.temper, bs.humidity, bs.test_result, bs.test_date, bs.next_test_date, bs.test_cycle, bs.test_address, bs.generate_time, bs.point_report_id, bs.is_merge, bs.circulation_flag, bs.item_proposal_fee AS proposal_fee, bs.change_price_reason, bs.test_user_name, bs.group_id, bs.group_name, bs.charging_num, bs.other_fee, bs.receivable_fee, bs.affix_quantity, bs.test_org, bs.out_org_order_no, bs.out_org_sample_no, bs.business_user_name, bs.pdf_path, bs.settlement_state, bs.result_describe, bsa.attach_id FROM view_sample_info bs JOIN bus_sample_report bsr ON bs.report_id = bsr.id JOIN bus_sample sa ON bsr.sample_id = sa.id JOIN bus_sample_attr bsa ON sa.id = bsa.id 根据bs.commission_date 进行排序最近的排上面 bs.commission_date
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值