ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 自动生成订单,并登记api

自动生成订单,并登记api

原创 Linux操作系统 作者:veyard 时间:2009-05-04 23:03:50 0 删除 编辑

通过API接口,自动生成订单并登记,登记的过程可以独立出来;

declare
  p_header_rec         oe_order_pub.header_rec_type;
  l_header_rec         oe_order_pub.header_rec_type;
  p_line_tbl           oe_order_pub.line_tbl_type;
  l_line_tbl           oe_order_pub.line_tbl_type;
  p_action_request_tbl oe_order_pub.request_tbl_type;
  l_action_request_tbl oe_order_pub.request_tbl_type := oe_order_pub.g_miss_request_tbl;

  x_return_status VARCHAR2(30);
  x_msg_count     NUMBER;
  x_msg_data      VARCHAR2(2000);

  l_header_val_rec         oe_order_pub.header_val_rec_type;
  l_header_adj_tbl         oe_order_pub.header_adj_tbl_type;
  l_header_adj_val_tbl     oe_order_pub.header_adj_val_tbl_type;
  l_header_price_att_tbl   oe_order_pub.header_price_att_tbl_type;
  l_header_adj_att_tbl     oe_order_pub.header_adj_att_tbl_type;
  l_header_adj_assoc_tbl   oe_order_pub.header_adj_assoc_tbl_type;
  l_header_scredit_tbl     oe_order_pub.header_scredit_tbl_type;
  l_header_scredit_val_tbl oe_order_pub.header_scredit_val_tbl_type;
  l_line_val_tbl           oe_order_pub.line_val_tbl_type;
  l_line_adj_tbl           oe_order_pub.line_adj_tbl_type;
  l_line_adj_val_tbl       oe_order_pub.line_adj_val_tbl_type;
  l_line_price_att_tbl     oe_order_pub.line_price_att_tbl_type;
  l_line_adj_att_tbl       oe_order_pub.line_adj_att_tbl_type;
  l_line_adj_assoc_tbl     oe_order_pub.line_adj_assoc_tbl_type;
  l_line_scredit_tbl       oe_order_pub.line_scredit_tbl_type;
  l_line_scredit_val_tbl   oe_order_pub.line_scredit_val_tbl_type;
  l_lot_serial_tbl         oe_order_pub.lot_serial_tbl_type;
  l_lot_serial_val_tbl     oe_order_pub.lot_serial_val_tbl_type;

  api_failure exception;
begin
  dbms_application_info.set_client_info(122);
  fnd_global.APPS_INITIALIZE(1115, 1, 1);

  l_header_rec                         := OE_ORDER_PUB.G_MISS_HEADER_REC;
  l_header_rec.order_type_id           := 1030;
  l_header_rec.order_source_id         := 0; --OE_ORDER_SOURCES
  l_header_rec.sold_to_org_id          := 530941; --customer
  l_header_rec.pricing_date            := sysdate;
  l_header_rec.transactional_curr_code := 'CNY';
  l_header_rec.price_list_id           := 6047;
  l_header_rec.operation               := OE_GLOBALS.G_OPR_CREATE;

  p_header_rec := l_header_rec;

  l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
  l_line_tbl(1).inventory_item_id := 295;
  l_line_tbl(1).ordered_quantity := 2;
  l_line_tbl(1).line_type_id := 1013;
  l_line_tbl(1).SHIP_FROM_ORG_ID := 156;
  l_line_tbl(1).RETURN_REASON_CODE := '10';
  l_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;

  /*l_line_tbl(2) := OE_ORDER_PUB.G_MISS_LINE_REC;
  l_line_tbl(2).inventory_item_id := 277;
  l_line_tbl(2).ordered_quantity := 1;
  l_line_tbl(2).line_type_id := 1013;
  l_line_tbl(2).SHIP_FROM_ORG_ID := 156;
  l_line_tbl(2).RETURN_REASON_CODE := '10';
  l_line_tbl(2).operation := OE_GLOBALS.G_OPR_CREATE;*/

  p_line_tbl := l_line_tbl;

  l_action_request_tbl(1) := oe_order_pub.g_miss_request_rec;
  l_action_request_tbl(1).request_type := oe_globals.g_book_order;
  l_action_request_tbl(1).entity_code := oe_globals.g_entity_header;
  l_action_request_tbl(1).entity_id := p_header_rec.header_id;
  p_action_request_tbl := l_action_request_tbl;

  oe_order_pub.process_order(p_api_version_number     => 1.0,
                             p_init_msg_list          => fnd_api.g_true,
                             p_return_values          => fnd_api.g_false,
                             p_action_commit          => fnd_api.g_false,
                             x_return_status          => x_return_status,
                             x_msg_count              => x_msg_count,
                             x_msg_data               => x_msg_data,
                             p_header_rec             => p_header_rec,
                             p_line_tbl               => p_line_tbl,
                             p_action_request_tbl     => p_action_request_tbl,
                             x_header_rec             => p_header_rec,
                             x_header_val_rec         => l_header_val_rec,
                             x_header_adj_tbl         => l_header_adj_tbl,
                             x_header_adj_val_tbl     => l_header_adj_val_tbl,
                             x_header_price_att_tbl   => l_header_price_att_tbl,
                             x_header_adj_att_tbl     => l_header_adj_att_tbl,
                             x_header_adj_assoc_tbl   => l_header_adj_assoc_tbl,
                             x_header_scredit_tbl     => l_header_scredit_tbl,
                             x_header_scredit_val_tbl => l_header_scredit_val_tbl,
                             x_line_tbl               => p_line_tbl,
                             x_line_val_tbl           => l_line_val_tbl,
                             x_line_adj_tbl           => l_line_adj_tbl,
                             x_line_adj_val_tbl       => l_line_adj_val_tbl,
                             x_line_price_att_tbl     => l_line_price_att_tbl,
                             x_line_adj_att_tbl       => l_line_adj_att_tbl,
                             x_line_adj_assoc_tbl     => l_line_adj_assoc_tbl,
                             x_line_scredit_tbl       => l_line_scredit_tbl,
                             x_line_scredit_val_tbl   => l_line_scredit_val_tbl,
                             x_lot_serial_tbl         => l_lot_serial_tbl,
                             x_lot_serial_val_tbl     => l_lot_serial_val_tbl,
                             x_action_request_tbl     => p_action_request_tbl);
  IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
    raise api_failure;
  else
    dbms_output.PUT_LINE('Success');
    dbms_output.put_line('new order number:' || p_header_rec.order_number);
    commit;
  end if;

exception
  when api_failure then
    dbms_output.PUT_LINE('Error code:' || 'Unexpected Error');
    if x_msg_count > 0 then
      for l_index in 1 .. x_msg_count loop
        x_msg_data := oe_msg_pub.get(p_msg_index => l_index,
                                     p_encoded   => 'F');
      end loop;
      dbms_output.put_line('error message:'||substr(x_msg_data,1,199));
    end if;
    rollback;
  when others then
    dbms_output.PUT_LINE('other Expected Error:' || sqlerrm);
    rollback;
end;

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

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-05-04

  • 博文量
    10
  • 访问量
    13812