ITPub博客

首页 > Linux操作系统 > Linux操作系统 > OM-API生成一个订单

OM-API生成一个订单

原创 Linux操作系统 作者:zuibunan 时间:2009-09-16 15:46:46 0 删除 编辑

DECLARE
  l_header_rec OE_ORDER_PUB.Header_Rec_Type;
  l_line_tbl   OE_ORDER_PUB.Line_Tbl_Type;
  --l_header_adj_tbl           OE_ORDER_PUB.Header_Adj_Tbl_Type;
  --l_line_adj_tbl             OE_ORDER_PUB.line_adj_tbl_Type;
  --l_header_scredit_tbl       OE_ORDER_PUB.Header_Scredit_Tbl_Type;
  --l_line_scredit_tbl         OE_ORDER_PUB.Line_Scredit_Tbl_Type;
  l_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type;

  l_return_status VARCHAR2(1);
  l_msg_count     NUMBER;
  l_msg_data      VARCHAR2(1000);


  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_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_DEBUG_FILE     VARCHAR2(100);
  l_line_tbl_index NUMBER;
  l_msg_index_out  NUMBER(10);


BEGIN
  dbms_output.enable(1000000);
  fnd_global.apps_initialize(1115, 50251, 660); -- pass in user_id,responsibility_id, and application_id
  oe_msg_pub.initialize; --初始化
  oe_debug_pub.initialize; --Debug初始化,清除debug cache
  X_DEBUG_FILE := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
  oe_debug_pub.SetDebugLevel(5); -- Use 5 for the most debuging output, I warn you its a lot of data 设置Debug级别
  --DBMS_APPLICATION_INFO.set_client_info(122);--org_id
  dbms_output.put_line('START OF NEW DEBUG');

  /* The header record is initialized to missing as there would be no header_id exists for the record.
  Once the header_id is generated by the API, the l_header_rec will take the value of the header_id */
  l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
  -- Header Attributes
  l_header_rec.order_type_id  := 1022; --10-标准订单
  l_header_rec.sold_to_org_id := 513961; --关联客户编号
  --l_header_rec.ship_to_org_id        := 23128;--关联收货地点
  -- l_header_rec.cust_po_number          := 'csg2009091607';
  --l_header_rec.transactional_curr_code := 'CNY';
  -- The statement indicates to the process order API that a new header has to be created.
  l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;

  -- Setting index as 1 to indicate that these belong to 1st line record
  l_line_tbl_index := 1;
  -- Initializing the line record to missing
  l_line_tbl(l_line_tbl_index) := OE_ORDER_PUB.G_MISS_LINE_REC;
  -- Line Attributes
  l_line_tbl(l_line_tbl_index).inventory_item_id := 277; --关联物料编号
  l_line_tbl(l_line_tbl_index).ordered_quantity := 17; --订单数量
  --l_line_tbl(l_line_tbl_index).SHIP_FROM_ORG_ID := 130;--发运仓库ID
  --l_line_tbl(l_line_tbl_index).calculate_price_flag := 'Y';--标识价目表是否要输入
  l_line_tbl(l_line_tbl_index).line_type_id := 1001; --行类型
  -- Indicates that this is a create operation for the line record.
  l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_CREATE;

  -- action request订单登记
  /*
  l_action_request_tbl(l_line_tbl_index) := oe_order_pub.g_miss_request_rec;
  l_action_request_tbl(l_line_tbl_index).request_type := oe_globals.g_book_order;
  l_action_request_tbl(l_line_tbl_index).entity_code := oe_globals.g_entity_header;
  l_action_request_tbl(l_line_tbl_index).entity_id := l_header_rec.header_id;
  */
  OE_ORDER_PUB.process_order(p_api_version_number => 1.0, --API版本初始化
                             p_init_msg_list      => fnd_api.g_false,
                             p_return_values      => fnd_api.g_false,
                             p_action_commit      => fnd_api.g_false,
                             x_return_status      => l_return_status,
                             x_msg_count          => l_msg_count,
                             x_msg_data           => l_msg_data,
                             p_header_rec         => l_header_rec,--生成订单头
                             p_line_tbl           => l_line_tbl,--生成订单行
                             p_action_request_tbl => l_action_request_tbl,
                             -- OUT PARAMETERS
                             x_header_rec             => l_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             => l_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 => l_action_request_tbl);

  dbms_output.put_line('OM Debug file: ' || oe_debug_pub.G_DIR || '/' ||
                       oe_debug_pub.G_FILE);
  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_msg_data,
                   p_msg_index_out => l_msg_index_out);
    DBMS_OUTPUT.PUT_LINE('message is: ' || l_msg_data);
    DBMS_OUTPUT.PUT_LINE('message index is: ' || l_msg_index_out);
  END LOOP;
  -- Check the return status
  IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
    dbms_output.put_line('^_^Process Order Success!');
    commit;
  ELSE
    dbms_output.put_line('~_~Process Order Failed!');
    rollback;
  END IF;
  -- debug output
  dbms_output.put_line('Debug Output');
  FOR i in 1 .. OE_DEBUG_PUB.g_debug_count LOOP
    dbms_output.put_line(OE_DEBUG_PUB.G_debug_tbl(i));
  END LOOP;
END;

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

请登录后发表评论 登录
全部评论

注册时间:2009-09-15

  • 博文量
    39
  • 访问量
    92242