创建SO

-- Created on 2013-5-13 by ADMINISTRATOR
declare
  -- Local variables here
  i integer;
    l_header_rec         oe_order_pub.header_rec_type;
    l_line_tbl           oe_order_pub.line_tbl_type;
    l_line_adj_tbl       oe_order_pub.line_adj_tbl_type;
    l_header_scredit_tbl oe_order_pub.header_scredit_tbl_type;
    x_header_rec             oe_order_pub.header_rec_type;
    x_header_val_rec         oe_order_pub.header_val_rec_type;
    x_header_adj_tbl         oe_order_pub.header_adj_tbl_type;
    x_header_adj_val_tbl     oe_order_pub.header_adj_val_tbl_type;
    x_header_price_att_tbl   oe_order_pub.header_price_att_tbl_type;
    x_header_adj_att_tbl     oe_order_pub.header_adj_att_tbl_type;
    x_header_adj_assoc_tbl   oe_order_pub.header_adj_assoc_tbl_type;
    x_header_scredit_tbl     oe_order_pub.header_scredit_tbl_type;
    x_header_scredit_val_tbl oe_order_pub.header_scredit_val_tbl_type;
    x_line_tbl               oe_order_pub.line_tbl_type;
    x_line_val_tbl           oe_order_pub.line_val_tbl_type;
    x_line_adj_tbl           oe_order_pub.line_adj_tbl_type;
    x_line_adj_val_tbl       oe_order_pub.line_adj_val_tbl_type;
    x_line_price_att_tbl     oe_order_pub.line_price_att_tbl_type;
    x_line_adj_att_tbl       oe_order_pub.line_adj_att_tbl_type;
    x_line_adj_assoc_tbl     oe_order_pub.line_adj_assoc_tbl_type;
    x_line_scredit_tbl       oe_order_pub.line_scredit_tbl_type;
    x_line_scredit_val_tbl   oe_order_pub.line_scredit_val_tbl_type;
    x_lot_serial_tbl         oe_order_pub.lot_serial_tbl_type;
    x_lot_serial_val_tbl     oe_order_pub.lot_serial_val_tbl_type;
    x_action_request_tbl     oe_order_pub.request_tbl_type;
    po_error_message varchar2(2000);
    po_return_status varchar2(1);
    x_msg_count number;
    x_msg_data varchar2(2000);
    l_msg_index_out number;
begin
  -- Test statements here
  mo_global.init('ONT');
  mo_global.set_policy_context('S',204);
  oe_msg_pub.initialize;
  fnd_global.APPS_INITIALIZE(user_id => 1068,resp_id => 53394,resp_appl_id => 385);
  l_header_rec := oe_order_pub.g_miss_header_rec; --必须要作此初始化
  l_header_rec.org_id := 204;
  l_header_rec.order_type_id := 1000; --订单类型
  l_header_rec.sold_to_org_id := 5455; --客户ID
  l_header_rec.sold_from_org_id := 204;
  l_header_rec.ordered_date := sysdate; --订单日期
  l_header_rec.price_list_id :=  1000;
  l_header_rec.salesrep_id := 1006;
  l_header_rec.transactional_curr_code := 'USD';
  l_header_rec.payment_term_id := 1020; --付款条件
  l_header_rec.operation := 'CREATE';
  i := 1;
  l_line_tbl(i) := oe_order_pub.G_MISS_LINE_REC; --必须要作此初始化
  l_line_tbl(i).line_number := i;
  l_line_tbl(i).ship_from_org_id := 1884; --库存组织
  l_line_tbl(i).inventory_item_id := 209955; --物料ID
  l_line_tbl(i).ordered_quantity := 1; --数量
  l_line_tbl(i).order_quantity_uom := 'Ea';
  l_line_tbl(i).unit_selling_price := 121.5;
  l_line_tbl(i).request_date := SYSDATE;
  l_line_tbl(i).schedule_ship_date := SYSDATE;
  l_line_tbl(i).line_type_id := 1427; --行类型ID
  l_line_tbl(i).operation := 'CREATE';
 
    --价格--   
      l_line_adj_tbl(i) := oe_order_pub.g_miss_line_adj_rec; --必须要作此初始化
      l_line_adj_tbl(i).operation := 'CREATE';
      l_line_adj_tbl(i).line_index := i;
      l_line_adj_tbl(i).automatic_flag := 'N';
      l_line_adj_tbl(i).applied_flag := 'Y';
      l_line_adj_tbl(i).updated_flag := 'Y'; --Optional, this is the fixed flag.
      l_line_adj_tbl(i).list_header_id := 227550; --6012; --list_header_id of the adjustment
      l_line_adj_tbl(i).list_line_id := 257871; --6007; --list_line_id of the adjustment
      l_line_adj_tbl(i).list_line_type_code := 'DIS';
      l_line_adj_tbl(i).operand := -1 * 121.5;
      --价格--
oe_order_pub.process_order(p_api_version_number => 1.0,
                               p_init_msg_list      => NULL,
                               p_return_values      => NULL,
                               -- Passing just the entity records that are a part of this order
                               p_header_rec         => l_header_rec,
                               p_line_tbl           => l_line_tbl,
                               p_line_adj_tbl       => l_line_adj_tbl,
                               p_header_scredit_tbl => l_header_scredit_tbl,
                               -- OUT
                               x_header_rec             => x_header_rec,
                               x_header_val_rec         => x_header_val_rec,
                               x_header_adj_tbl         => x_header_adj_tbl,
                               x_header_adj_val_tbl     => x_header_adj_val_tbl,
                               x_header_price_att_tbl   => x_header_price_att_tbl,
                               x_header_adj_att_tbl     => x_header_adj_att_tbl,
                               x_header_adj_assoc_tbl   => x_header_adj_assoc_tbl,
                               x_header_scredit_tbl     => x_header_scredit_tbl,
                               x_header_scredit_val_tbl => x_header_scredit_val_tbl,
                               x_line_tbl               => x_line_tbl,
                               x_line_val_tbl           => x_line_val_tbl,
                               x_line_adj_tbl           => x_line_adj_tbl,
                               x_line_adj_val_tbl       => x_line_adj_val_tbl,
                               x_line_price_att_tbl     => x_line_price_att_tbl,
                               x_line_adj_att_tbl       => x_line_adj_att_tbl,
                               x_line_adj_assoc_tbl     => x_line_adj_assoc_tbl,
                               x_line_scredit_tbl       => x_line_scredit_tbl,
                               x_line_scredit_val_tbl   => x_line_scredit_val_tbl,
                               x_lot_serial_tbl         => x_lot_serial_tbl,
                               x_lot_serial_val_tbl     => x_lot_serial_val_tbl,
                               x_action_request_tbl     => x_action_request_tbl,
                               --RETURN MSG
                               x_return_status => po_return_status,
                               x_msg_count     => x_msg_count,
                               x_msg_data      => x_msg_data);
 
    IF po_return_status <> 'S'
    THEN
   
      FOR j IN 1 .. x_msg_count
      LOOP
        oe_msg_pub.get(p_msg_index     => j,
                       p_encoded       => fnd_api.g_false,
                       p_data          => x_msg_data,
                       p_msg_index_out => l_msg_index_out);
     
        po_error_message := nvl(po_error_message, '') || nvl(x_msg_data, '');
      END LOOP;
      dbms_output.put_line('错误信息:'||po_error_message);
      --RAISE l_exception;
    END IF; 
end;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13387766/viewspace-765789/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/13387766/viewspace-765789/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值