• OM模块功能&API详解


    (一)销售订单概述

    1.1   与车间模块关系

    当使用ATO类型订单时,订单管理模块会直接在车间模块中产生任务

    1.2   与库存模块关系

    在销售订单中使用的物料,单位等信息均来自库存模块,在订单执行过程中,按订单保留及销售发运等功能也会对库存模块起作用

    1.3   与应收模块关系

    销售完成后,订单管理模块会在应收接口中产生INVOICE信息,影响应收模块中销售订单对应的应收INVOICE处理操作

    1.4   与采购模块关系

    在直发流程,背对背等销售流程中,订单模块会在采购模块中产生对应的采购需求和请购信息,供采购模块导入,影响后续采购操作

    1.5   与CRM模块关系

    在CRM中,如sale online等许多模块,营销流程执行结束后都会在订单管理模块接口中产生销售订单信息,供订单管理模块导入

    1.5   与物料清单模块关系

    在ATO类型和PTO类型的销售订单中,进行配置时销售模块都将引用物料设置于物料清单模块的物料清单信息进行配置

    1.6   与主计划/MRP模块关系

    当对销售订单进行计划后,订单管理模块会将需求信息传递给MRP模块

    1.7   与外部系统关系

    订单管理模块通过调用高级定价模块产生销售订单中的销售价格信息

    1.8  与发运模块的关系

    对于需要从库存发运物品的销售订单,订单会将需要发运的信息传递给发运模块,在发运模块中完成对此物品的挑库,发货等操作。完成后发运模块会将发运状态回写到订单管理模块中。

    1.9  销售订单模块主要功能

    创建客户,维护客户信息及客户关系,进行客户合并操作

    销售及退货单的录入,登记

    对于销售和退货单的复制,修改,取消,暂挂,释放等操作

    查询销售订单执行状况及与之关联的价格调整,库存,交货,发运,INVOICE信息、

    根据客户的信用额度进行控制销售订单的挑库及发货

    对销售价格的记录和使用控制

    与高级定价模块集成,调用高级定价功能结合价目表产生销售价格

    与发运模块集成,通过发运模块进行库存类物品的挑库,发货操作

    自动产生应收INVOICE/贷项通知单接口记录,供应收模块导入

    处理复杂公司销售业务流程,如直发,内部销售,公司间交易,ATO订单,PTO订单


    二)标准销售订单流程

    2.1   基本流程

    Ebs标准销售流程比较简单清晰,如图,但是过程中夹杂着许多东西,例如信用控制等,相对来说还是比较复杂的



    2.2  创建订单(界面)

    1.填写订单头信息



    2.填写订单行信息



    2.3  创建订单(API)

    DECLARE
      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;
    
      i                        NUMBER := 1;
      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;  
      x_Return_Status          VARCHAR2(1);
      x_Msg_Count              NUMBER;
      x_Msg_Data               VARCHAR2(255);
    
    BEGIN
      fnd_global.APPS_INITIALIZE(user_id => 1143,resp_id => 50877,resp_appl_id => 20004);
      Mo_Global.init('CUX');
      oe_msg_pub.initialize;
      
      l_Header_Rec                := Oe_Order_Pub.g_Miss_Header_Rec;
      l_Header_Rec.Operation      := Oe_Globals.g_Opr_Create;
      l_Header_Rec.Org_Id         := &Org_Id;
      l_Header_Rec.Sold_To_Org_Id := &Customer_Id;
      l_header_rec.order_type_id  := &order_type_id;
      
      l_Line_Tbl.Delete;
      l_Line_Tbl(i)                      := Oe_Order_Pub.g_Miss_Line_Rec;
      l_Line_Tbl(i).Operation            := Oe_Globals.g_Opr_Create;
      l_Line_Tbl(i).Inventory_Item_Id    := &Inventory_Item_Id;
      l_Line_Tbl(i).Ordered_Quantity     := &Quantity;
      l_Line_Tbl(i).Unit_Selling_Price   := &unit_price;
      l_Line_Tbl(i).Unit_List_Price      := &unit_price;
      l_Line_Tbl(i).Calculate_Price_Flag := 'N';
      --如果没使用修改量或者运费作为价格,通过API导入价格必须导入冻结的价格
      Oe_Order_Pub.Process_Order(p_Org_Id                 => &org_id,
                                 p_Api_Version_Number     => 1.0,
                                 p_Init_Msg_List          => NULL,
                                 p_Return_Values          => NULL,
                                 p_Header_Rec             => l_Header_Rec,
                                 p_Action_Request_Tbl     => l_Action_Request_Tbl,
                                 p_Line_Tbl               => l_Line_Tbl,
                                 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 => x_Return_Status,
                                 x_Msg_Count     => x_Msg_Count,
                                 x_Msg_Data      => x_Msg_Data);
    
      IF x_Return_Status = Fnd_Api.g_Ret_Sts_Success THEN
        Dbms_Output.Put_Line('订单导入成功!');
        Dbms_Output.Put_Line('订单编号:'||x_Header_Rec.order_number);
      ELSE    
        FOR l_index IN 1 .. x_Msg_Count LOOP
          Dbms_Output.Put_Line(oe_msg_pub.get(p_msg_index => l_index, p_encoded => 'F'));
        END LOOP;
      END IF;
    END;
    

    ²  说明:导入已登记订单,一般不建议通过头的booked_flag的标记去导入,结果会只是行状态为已登记状态,但是头的状态为已输入状态。

    ²  如果需要导入期初价格的订单,且无修改量及运费计算的,则设置行上的Calculate_Price_Flag='N'

    2.4 登记订单

    DECLARE
      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;
    
      i                    NUMBER := 1;
      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;
      x_Return_Status      VARCHAR2(1);
      x_Msg_Count          NUMBER;
      x_Msg_Data           VARCHAR2(255);
    
    BEGIN
    
      Fnd_Global.Apps_Initialize(User_Id => 1143,Resp_Id => 50877,Resp_Appl_Id => 20004);
      Mo_Global.init('CUX');--必须初始化MOAC,否则无法完成OU验证
      mo_global.set_policy_context('S',88);
      
      Oe_Msg_Pub.Initialize;
      
      i := 1; 
      l_action_request_tbl(i).request_type := oe_globals.g_book_order; 
      l_action_request_tbl(i).entity_code  := oe_globals.g_entity_header; 
      l_action_request_tbl(i).entity_id    := &header_id;
      
      /*如果有多个订单增加record记录
      i := i+1;
      l_action_request_tbl(i).request_type := oe_globals.g_book_order; 
      l_action_request_tbl(i).entity_code  := oe_globals.g_entity_header; 
      l_action_request_tbl(i).entity_id    := &header_id1;*/
      
      Oe_Order_Pub.Process_Order(p_Api_Version_Number     => 1.0,
                                 p_Init_Msg_List          => NULL,
                                 p_Return_Values          => NULL,
                                 p_Action_Request_Tbl     => l_Action_Request_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 => x_Return_Status,
                                 x_Msg_Count     => x_Msg_Count,
                                 x_Msg_Data      => x_Msg_Data);
        
       IF (x_Msg_Count>0) THEN--这里不能按x_return_status的状态判断
         FOR l_Index IN 1 .. x_Msg_Count LOOP
          Dbms_Output.Put_Line(Oe_Msg_Pub.Get(p_Msg_Index => l_Index,p_Encoded   => 'F'));
         END LOOP;
       ELSE
         Dbms_Output.Put_Line('登记成功!');
       END IF;
    END;
    

    2.5 创建保留(界面)


    2.6 创建保留(API)

    PROCEDURE create_reservation(p_init_msg_list IN VARCHAR2,
                                    x_return_status OUT NOCOPY VARCHAR2,
                                    x_msg_count     OUT NOCOPY NUMBER,
                                    x_msg_data      OUT NOCOPY VARCHAR2,
                                    p_rsv_rec       inv_reservation_global.mtl_reservation_rec_type) IS
          l_sub_program VARCHAR2(100) := 'create_reservation';
          l_process     VARCHAR2(4000);
          l_api_name       CONSTANT VARCHAR2(30) := 'create_reservation';
          l_savepoint_name CONSTANT VARCHAR2(30) := 'create_reservation01';
       
          l_rsv_rec       inv_reservation_global.mtl_reservation_rec_type;
          l_serial_number inv_reservation_global.serial_number_tbl_type;
       
          x_reservation_id           NUMBER;
          l_partial_reservation_flag VARCHAR2(1);
          x_quantity_reserved        NUMBER;
       
       BEGIN
       
          x_return_status := cux_api.start_activity(p_pkg_name       => g_pkg_name,
                                                    p_api_name       => l_api_name,
                                                    p_savepoint_name => l_savepoint_name,
                                                    p_init_msg_list  => p_init_msg_list);
          IF x_return_status = fnd_api.g_ret_sts_error THEN
             RAISE fnd_api.g_exc_error;
          ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
             RAISE fnd_api.g_exc_unexpected_error;
          END IF;
       
          l_process := l_sub_program || 'Step:1 .开始创建INV保留.';
          IF g_debug = 'Y' THEN
             cux_conc_utl.log_msg(p_msg => l_process);
          END IF;
       
          l_rsv_rec := p_rsv_rec;
       
          --create reservation
          BEGIN
             inv_reservation_pub.create_reservation(p_api_version_number       => 1.0,
                                                    p_init_msg_lst             => fnd_api.g_false,
                                                    x_return_status            => x_return_status,
                                                    x_msg_count                => x_msg_count,
                                                    x_msg_data                 => x_msg_data,
                                                    p_rsv_rec                  => l_rsv_rec,
                                                    p_serial_number            => l_serial_number,
                                                    x_serial_number            => l_serial_number,
                                                    p_partial_reservation_flag => l_partial_reservation_flag,
                                                    p_force_reservation_flag   => fnd_api.g_false,
                                                    p_validation_flag          => fnd_api.g_true,
                                                    x_quantity_reserved        => x_quantity_reserved,
                                                    x_reservation_id           => x_reservation_id);
          
             IF x_return_status <> fnd_api.g_ret_sts_success THEN
                raise_exception(x_return_status);
             END IF;
          EXCEPTION
             WHEN OTHERS THEN
                fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
                                          p_count   => x_msg_count,
                                          p_data    => x_msg_data);
                IF x_msg_count > 1 THEN
                   x_msg_data := fnd_msg_pub.get_detail(p_msg_index => fnd_msg_pub.g_first,
                                                        p_encoded   => fnd_api.g_false);
                END IF;
                x_return_status := fnd_api.g_ret_sts_error;
                x_msg_data      := '创建保留出错.' || x_msg_data;
                init_message(x_msg_data);
                raise_exception(x_return_status);
          END;
       
          l_process := l_sub_program || 'Step:2 .结束创建订单保留.';
          IF g_debug = 'Y' THEN
             cux_conc_utl.log_msg(p_msg => l_process);
          END IF;
       
          x_return_status := cux_api.end_activity(p_pkg_name  => g_pkg_name,
                                                  p_api_name  => l_api_name,
                                                  p_commit    => fnd_api.g_true,
                                                  x_msg_count => x_msg_count,
                                                  x_msg_data  => x_msg_data);
       
       EXCEPTION
          WHEN fnd_api.g_exc_error THEN
             x_return_status := cux_api.handle_exceptions(p_pkg_name       => g_pkg_name,
                                                          p_api_name       => l_api_name,
                                                          p_savepoint_name => l_savepoint_name,
                                                          p_exc_name       => cux_api.g_exc_name_error,
                                                          x_msg_count      => x_msg_count,
                                                          x_msg_data       => x_msg_data);
          WHEN fnd_api.g_exc_unexpected_error THEN
             x_return_status := cux_api.handle_exceptions(p_pkg_name       => g_pkg_name,
                                                          p_api_name       => l_api_name,
                                                          p_savepoint_name => l_savepoint_name,
                                                          p_exc_name       => cux_api.g_exc_name_unexp,
                                                          x_msg_count      => x_msg_count,
                                                          x_msg_data       => x_msg_data);
          WHEN OTHERS THEN
             x_return_status := cux_api.handle_exceptions(p_pkg_name       => g_pkg_name,
                                                          p_api_name       => l_api_name,
                                                          p_savepoint_name => l_savepoint_name,
                                                          p_exc_name       => cux_api.g_exc_name_others,
                                                          x_msg_count      => x_msg_count,
                                                          x_msg_data       => x_msg_data);
       END create_reservation;
    

    2.7 挑库发放(界面)

    挑库发放可以细分为2个步骤,第一创建挑库批次,第二启用挑库;

    在挑库参数里面有三个参数通常情况上是我们比较关注的值

    自动创建交货

    自动确认挑库

    自动创建分配


    2.8 挑库发放(API)

    DECLARE
      CURSOR Csr_Detail IS
        SELECT Wdd.Delivery_Detail_Id
          FROM Wsh_Delivery_Details Wdd
         WHERE Wdd.Released_Status IN ('R', 'B', 'X')
           AND Wdd.Source_Header_Id = 1;
      x_Return_Status  VARCHAR2(1);
      x_Msg_Count      NUMBER;
      x_Msg_Data       VARCHAR2(2000);
      l_Batch_Info_Rec Wsh_Picking_Batches_Pub.Batch_Info_Rec;
      l_Batch_Id       NUMBER;
      l_Batch_Name     VARCHAR2(2000);
      x_Request_Id     NUMBER;
      l_Log_Level      NUMBER;
    BEGIN
      fnd_global.APPS_INITIALIZE(user_id => 1143,resp_id => 50877,resp_appl_id => 20004);
      Mo_Global.Init('CUX');
      Mo_Global.Set_Policy_Context('S', 88);
    
      --FOR Rec_Detail IN Csr_Detail LOOP
      l_Batch_Info_Rec                      := NULL;
      l_Batch_Info_Rec.Order_Type_Id        := 1326;
      l_Batch_Info_Rec.Order_Number         := 2900012911;
      l_Batch_Info_Rec.Backorders_Only_Flag := 'O';
      --l_Batch_Info_Rec.Delivery_Detail_Id     := -460639;
      l_Batch_Info_Rec.Append_Flag           := 'N';
      l_Batch_Info_Rec.Organization_Id       := 95;
      l_Batch_Info_Rec.Pick_Grouping_Rule_Id := 1006;
      l_Batch_Info_Rec.AUTO_PICK_CONFIRM_FLAG := 'N';
      l_Batch_Info_Rec.AUTODETAIL_PR_FLAG     := 'N';
    
      Wsh_Picking_Batches_Pub.Create_Batch(p_Api_Version   => 1.0,
                                           p_Init_Msg_List => Fnd_Api.g_True,
                                           p_Commit        => Fnd_Api.g_false,
                                           x_Return_Status => x_Return_Status,
                                           x_Msg_Count     => x_Msg_Count,
                                           x_Msg_Data      => x_Msg_Data,
                                           p_Batch_Rec     => l_Batch_Info_Rec,
                                           x_Batch_Id      => l_Batch_Id);
    
      IF (x_Return_Status = Wsh_Util_Core.g_Ret_Sts_Success) THEN
        Wsh_Picking_Batches_Pub.Release_Batch(p_Api_Version   => 1.0,
                                              p_Init_Msg_List => Fnd_Api.g_False,
                                              p_Commit        => fnd_api.g_false,
                                              x_Msg_Count     => x_Msg_Count,
                                              x_Return_Status => x_Return_Status,
                                              x_Msg_Data      => x_Msg_Data,
                                              p_Batch_Id      => l_Batch_Id,
                                              p_Batch_Name    => l_Batch_Name,
                                              p_Log_Level     => l_Log_Level,
                                              p_Release_Mode  => 'CONCURRENT',
                                              x_Request_Id    => x_Request_Id);
    
        IF (x_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
    COMMIT;
    dbms_output.put_line('Return Status= '|| SUBSTR (x_return_status,1,255));
    dbms_output.put_line('Request_id= '|| x_request_id);		
    ELSE    
    dbms_output.put_line('Msg Data= '|| SUBSTR (x_msg_data,1,255));
    END IF;
      ELSE
        Dbms_Output.Put_Line('Return Status= ' || Substr(x_Return_Status, 1, 255));
        Dbms_Output.Put_Line('Msg Count=' || To_Char(x_Msg_Count));
        Dbms_Output.Put_Line('Msg Data= ' || x_Msg_Data);
      END IF;
    END;
    

    2.9挑库确认(界面)

    2.10 挑库确认(API)

    分配物料搬运单

    DECLARE
      x_Return_Status VARCHAR2(2);
      x_Msg_Count     NUMBER := 0;
      x_Msg_Data      VARCHAR2(255);
      -- for detail 
      l_Move_Order_Type      Mtl_Txn_Request_Headers.Move_Order_Type%TYPE := 3;
      x_Detailed_Qty         NUMBER := 5;
      x_Number_Of_Rows       NUMBER := 0;
      x_Revision             VARCHAR2(3);
      x_Locator_Id           NUMBER := 0;
      x_Transfer_To_Location NUMBER := 0;
      x_Lot_Number           VARCHAR2(30);
      x_Expiration_Date      DATE;
      x_Transaction_Temp_Id  NUMBER := 0;
    
      CURSOR csr_mo_line IS
      SELECT Tl.Line_Id Mo_Line_Id,
             tl.quantity
        FROM Wsh_Delivery_Details  Wdd,
             Mtl_Txn_Request_Lines Tl,
             Mtl_Txn_Request_Headers th
       WHERE Wdd.Released_Status = 'S'
         AND Wdd.Move_Order_Line_Id = Tl.Line_Id
         AND Nvl(Tl.Quantity_Detailed, 0) < Tl.Quantity
         AND Wdd.Source_Header_Id = &Oe_Header_Id
         AND tl.header_id = th.header_id
       GROUP BY Tl.Line_Id,tl.quantity
      ORDER BY tl.line_id;
        
    BEGIN
    
      fnd_global.APPS_INITIALIZE(user_id => 1143,resp_id => 50877,resp_appl_id => 20004); 
      
      -- Allocate each line of the Move Order
      FOR rec_line in csr_mo_line LOOP
        Inv_Replenish_Detail_Pub.Line_Details_Pub(p_Line_Id               => rec_line.mo_Line_Id,
                                                  x_Number_Of_Rows        => x_Number_Of_Rows,
                                                  x_Detailed_Qty          => x_Detailed_Qty,
                                                  x_Return_Status         => x_Return_Status,
                                                  x_Msg_Count             => x_Msg_Count,
                                                  x_Msg_Data              => x_Msg_Data,
                                                  x_Revision              => x_Revision,
                                                  x_Locator_Id            => x_Locator_Id,
                                                  x_Transfer_To_Location  => x_Transfer_To_Location,
                                                  x_Lot_Number            => x_Lot_Number,
                                                  x_Expiration_Date       => x_Expiration_Date,
                                                  x_Transaction_Temp_Id   => x_Transaction_Temp_Id,
                                                  p_Transaction_Header_Id => NULL,
                                                  p_Transaction_Mode      => NULL,
                                                  p_Move_Order_Type       => l_Move_Order_Type,
                                                  p_Serial_Flag           => Fnd_Api.g_False,
                                                  p_Plan_Tasks            => FALSE, --FND_API.G_FALSE
                                                  p_Auto_Pick_Confirm     => FALSE, --FND_API.G_FALSE 
                                                  p_Commit                => FALSE --FND_API.G_FALSE
                                                  );
    
        Dbms_Output.Put_Line('==========================================================');
        Dbms_Output.Put_Line('Return Status: ' || x_Return_Status);
    
        IF (x_Return_Status <> Fnd_Api.g_Ret_Sts_Success) THEN
          Dbms_Output.Put_Line('Error Message :'||x_Msg_Data);
          FOR i IN 1 .. fnd_msg_pub.count_msg LOOP
            Dbms_Output.Put_Line(fnd_msg_pub.Get(i,'F'));      
          END LOOP;
        ELSE
          IF x_number_of_rows = 0 OR nvl(x_detailed_qty,0)< rec_line.quantity THEN
            dbms_output.put_line('not enough onhand quantity!');
          END IF;
        END IF;
        Dbms_Output.Put_Line('==========================================================');
      END LOOP;
      
    EXCEPTION
      WHEN OTHERS THEN
        Dbms_Output.Put_Line('Exception Occured :');
        Dbms_Output.Put_Line(SQLCODE || ':' || SQLERRM);
        Dbms_Output.Put_Line('=======================================================');
    END;
    

    处理物料搬运单

    DECLARE
      -- Common Declarations
      l_Api_Version   NUMBER := 1.0;
      l_Init_Msg_List VARCHAR2(2) := Fnd_Api.g_True;
      l_Commit        VARCHAR2(2) := Fnd_Api.g_False;
      x_Return_Status VARCHAR2(2);
      x_Msg_Count     NUMBER := 0;
      x_Msg_Data      VARCHAR2(255);
      -- API specific declarations          
      l_Move_Order_Type  NUMBER := 1;
      l_Transaction_Mode NUMBER := 1;
      l_Trolin_Tbl       Inv_Move_Order_Pub.Trolin_Tbl_Type;
      l_Mold_Tbl         Inv_Mo_Line_Detail_Util.g_Mmtt_Tbl_Type;
      x_Mmtt_Tbl         Inv_Mo_Line_Detail_Util.g_Mmtt_Tbl_Type;
      x_Trolin_Tbl       Inv_Move_Order_Pub.Trolin_Tbl_Type;
      l_Transaction_Date DATE := SYSDATE;
      -- WHO columns
      l_User_Id        NUMBER := -1;
      l_Resp_Id        NUMBER := -1;
      l_Application_Id NUMBER := -1;
      l_Row_Cnt        NUMBER := 1;
      l_User_Name      VARCHAR2(30) := 'MFG';
      l_Resp_Name      VARCHAR2(30) := 'MFG_AND_DIST_SUPER_USER_APS';
    
    BEGIN
    
      Fnd_Global.Apps_Initialize(User_Id => 1143,Resp_Id => 50877,Resp_Appl_Id => 20004);
      l_Trolin_Tbl(1).Line_Id := &mo_Line_Id;
      -- call API to create move order header
      Dbms_Output.Put_Line('=======================================================');
      Dbms_Output.Put_Line('Calling INV_Pick_Wave_Pick_Confirm_PUB.Pick_Confirm API');
    
      Inv_Pick_Wave_Pick_Confirm_Pub.Pick_Confirm(p_Api_Version_Number => l_Api_Version,
                                                  p_Init_Msg_List      => l_Init_Msg_List,
                                                  p_Commit             => l_Commit,
                                                  x_Return_Status      => x_Return_Status,
                                                  x_Msg_Count          => x_Msg_Count,
                                                  x_Msg_Data           => x_Msg_Data,
                                                  p_Move_Order_Type    => l_Move_Order_Type,
                                                  p_Transaction_Mode   => l_Transaction_Mode,
                                                  p_Trolin_Tbl         => l_Trolin_Tbl,
                                                  p_Mold_Tbl           => l_Mold_Tbl,
                                                  x_Mmtt_Tbl           => x_Mmtt_Tbl,
                                                  x_Trolin_Tbl         => x_Trolin_Tbl,
                                                  p_Transaction_Date   => l_Transaction_Date);
    
      Dbms_Output.Put_Line('=======================================================');
      Dbms_Output.Put_Line('Return Status: ' || x_Return_Status);
    
      IF (x_Return_Status <> Fnd_Api.g_Ret_Sts_Success) THEN
        Dbms_Output.Put_Line('Error Message :' || x_Msg_Data);
      END IF;
    
      Dbms_Output.Put_Line('=======================================================');
    
    EXCEPTION
      WHEN OTHERS THEN
        Dbms_Output.Put_Line('Exception Occured :');
        Dbms_Output.Put_Line(SQLCODE || ':' || SQLERRM);
        Dbms_Output.Put_Line('=======================================================');
    END;
    

    2.11 创建交货(界面)

    2.12创建交货(API)

    DECLARE
      Tbl_Line_Rows   Wsh_Util_Core.Id_Tab_Type;
      Tbl_Del_Rows    Wsh_Util_Core.Id_Tab_Type;
      x_Return_Status VARCHAR2(1);
      x_Msg_Count     NUMBER;
      x_Msg_Data      VARCHAR2(2000);
      l_Api_Version   NUMBER := 1;
    BEGIN
      Fnd_Global.Apps_Initialize(User_Id => 1143,Resp_Id => 50877,Resp_Appl_Id => 20004);
      
      Tbl_Line_Rows(1) := &Delivery_Detail_Id1;
      Tbl_Line_Rows(2) := &Delivery_Detail_Id2;
      Wsh_Delivery_Details_Pub.Autocreate_Deliveries(p_Api_Version_Number => l_Api_Version,
                                                     p_Init_Msg_List      => Fnd_Api.g_True,
                                                     p_Commit             => Fnd_Api.g_False,
                                                     x_Return_Status      => x_Return_Status,
                                                     x_Msg_Count          => x_Msg_Count,
                                                     x_Msg_Data           => x_Msg_Data,
                                                     p_Line_Rows          => Tbl_Line_Rows,
                                                     x_Del_Rows           => Tbl_Del_Rows);
      Dbms_Output.Put_Line('=======================================================');
      Dbms_Output.Put_Line('Return Status: ' || x_Return_Status);
    
      IF (x_Return_Status <> Fnd_Api.g_Ret_Sts_Success) THEN
        Dbms_Output.Put_Line('Error Message :' || x_Msg_Data);
      END IF;
      Dbms_Output.Put_Line('=======================================================');
    END;
    

    2.13 发运确认

    DECLARE
      x_Return_Status VARCHAR2(1);
      x_Msg_Count     NUMBER;
      x_Msg_Data      VARCHAR2(2000);
    
      l_Sc_Action_Flag          VARCHAR2(2);
      l_Sc_Intransit_Flag       VARCHAR2(2);
      l_Sc_Close_Trip_Flag      VARCHAR2(2);
      l_Sc_Create_Bol_Flag      VARCHAR2(2);
      l_Sc_Stage_Del_Flag       VARCHAR2(2);
      l_Sc_Trip_Ship_Method     VARCHAR2(30);
      l_Sc_Actual_Dep_Date      DATE;
      l_Sc_Report_Set_Id        NUMBER;
      l_Sc_Report_Set_Name      VARCHAR2(100);
      l_Sc_Defer_Interface_Flag VARCHAR2(2);
      l_Sc_Send_945_Flag        VARCHAR2(2);
      l_Wv_Override_Flag        VARCHAR2(2);
      x_Trip_Id                 VARCHAR2(30);
      x_Trip_Name               VARCHAR2(30);
      l_Organization_Id         NUMBER;
      l_Delivery_Name           VARCHAR2(30);
    BEGIN
      BEGIN
        SELECT Wnd.Organization_Id,
               Wnd.Name
          INTO l_Organization_Id,
               l_Delivery_Name
          FROM Wsh_New_Deliveries Wnd
         WHERE Wnd.Delivery_Id = &Delivery_Id;
      END;
    
      BEGIN
        SELECT Cr.Action_Flag,
               Cr.Ac_Intransit_Flag,
               Cr.Ac_Close_Trip_Flag,
               Cr.Mc_Bol_Flag,
               Cr.Stage_Del_Flag,
               Cr.Ship_Method_Code,
               &l_Transaction_Date, --SYSDATE,
               Cr.Report_Set_Id,
               Cr.Ac_Defer_Interface_Flag,
               Cr.Send_945_Flag
          INTO l_Sc_Action_Flag,
               l_Sc_Intransit_Flag,
               l_Sc_Close_Trip_Flag,
               l_Sc_Create_Bol_Flag,
               l_Sc_Stage_Del_Flag,
               l_Sc_Trip_Ship_Method,
               l_Sc_Actual_Dep_Date,
               l_Sc_Report_Set_Id,
               l_Sc_Defer_Interface_Flag,
               l_Sc_Send_945_Flag
          FROM Wsh_Shipping_Parameters Wsp,
               Wsh_Ship_Confirm_Rules  Cr
         WHERE Wsp.Organization_Id = l_Organization_Id
           AND Wsp.Ship_Confirm_Rule_Id = Cr.Ship_Confirm_Rule_Id;
      END;
    
      Wsh_Deliveries_Pub.Delivery_Action(p_Api_Version_Number      => 1.0,
                                         p_Init_Msg_List           => Fnd_Api.g_True,
                                         x_Return_Status           => x_Return_Status,
                                         x_Msg_Count               => x_Msg_Count,
                                         x_Msg_Data                => x_Msg_Data,
                                         p_Action_Code             => 'CONFIRM',
                                         p_Delivery_Id             => &Delivery_Id,
                                         p_Delivery_Name           => l_Delivery_Name,
                                         p_Sc_Action_Flag          => l_Sc_Action_Flag,
                                         p_Sc_Intransit_Flag       => l_Sc_Intransit_Flag,
                                         p_Sc_Close_Trip_Flag      => l_Sc_Close_Trip_Flag,
                                         p_Sc_Create_Bol_Flag      => l_Sc_Create_Bol_Flag,
                                         p_Sc_Stage_Del_Flag       => l_Sc_Stage_Del_Flag,
                                         p_Sc_Trip_Ship_Method     => l_Sc_Trip_Ship_Method,
                                         p_Sc_Actual_Dep_Date      => l_Sc_Actual_Dep_Date,
                                         p_Sc_Report_Set_Id        => l_Sc_Report_Set_Id,
                                         p_Sc_Report_Set_Name      => l_Sc_Report_Set_Name,
                                         p_Sc_Defer_Interface_Flag => l_Sc_Defer_Interface_Flag,
                                         p_Sc_Send_945_Flag        => l_Sc_Send_945_Flag,
                                         p_Wv_Override_Flag        => l_Wv_Override_Flag,
                                         x_Trip_Id                 => x_Trip_Id,
                                         x_Trip_Name               => x_Trip_Name);
    
      Dbms_Output.Put_Line('=======================================================');
      Dbms_Output.Put_Line('Return Status: ' || x_Return_Status);
    
      IF (x_Return_Status <> Fnd_Api.g_Ret_Sts_Success) THEN
        Dbms_Output.Put_Line('Error Message :' || x_Msg_Data);
        FOR i IN 1..fnd_msg_pub.Count_Msg LOOP
          Dbms_Output.Put_Line('Error Message :' || fnd_msg_pub.Get(i,'F'));
        END LOOP;
      END IF;
      Dbms_Output.Put_Line('=======================================================');
    
    END;
    

    2.14 链接行程停靠站


    Interface Trip Stop实际上包含两部分:Order Management Interface  SRS(更新发运行状态、以准备生成ARINVOICE)和 Inventory Interface  SRS(产生库存出货事务)

    Order Management Interface - SRS是在Inventory Interface  SRS之前运行的,这个Request更新发运行状态、以准备生成ARINVOICE,OM Interface运行结束后会更新WSH_DELIVERY_DETAILS表的OE_INTERFACED_FLAG为Y。

    Inventory Interface  SRS会根据Shipping Transaction来插入记录到MTI,进而INV Manager会把这条MTI记录转到MMT表中,一条Sales Order Issue的transaction记录就产生了,并完成库存数量的扣减和Reservation的删除。Inventory Interface  SRS运行完之后,会更新WSH_DELIVERY_DETAILS表的INV_INTERFACED_FLAG字段为Y。


    DECLARE
      CURSOR Csr_Wdd IS
        SELECT Wnd.Delivery_Id
          FROM Wsh_New_Deliveries Wnd
         WHERE EXISTS (SELECT 1
                  FROM Wsh_Delivery_Details     Wdd,
                       Wsh_Delivery_Assignments Wda
                 WHERE Wdd.Released_Status = 'C'
                   AND Wdd.Delivery_Detail_Id = Wda.Delivery_Detail_Id
                   AND Wda.Delivery_Id = Wnd.Delivery_Id
                   AND Wdd.Source_Line_Id = &Order_Line_Id);
      l_Error_Message VARCHAR2(20000);
      l_Retcode       VARCHAR2(2);
    BEGIN
      FOR Rec_d IN Csr_Wdd LOOP
        Wsh_Ship_Confirm_Actions.Interface_All_Wrp(Errbuf        => l_Error_Message,
                                                   Retcode       => l_Retcode,
                                                   p_Mode        => 'ALL',
                                                   p_Delivery_Id => Rec_d.Delivery_Id,
                                                   p_Log_Level   => 0);
        IF (l_retcode <> '0') THEN
          dbms_output.put_line(l_Error_Message);
        ELSE
          dbms_output.put_line('成功!');     
        END IF;
      END LOOP;
    END;
    

    2.15 工作流后台引擎


    这个program用于处理Deffered状态的workflow,Workflow Background Process运行后,相关数据就会从Order表导入到RA Interface表中去(RA_INTERFACE_LINES_ALL,RA_INTERFACE_SALESCREDITS_ALL,RA_Interface_distribution)

    你可以通过下边的SQL来查看RA Interface信息:

    1.SELECT * FROM RA_INTERFACE_LINES_ALL WHEREsales_order = '65961';

    2.SELECT * FROMRA_INTERFACE_SALESCREDITS_ALL 

    WHERE INTERFACE_LINE_ID IN (SELECTINTERFACE_LINE_ID FROM RA_INTERFACE_LINES_ALL WHERE sales_order = '65961' );

    3.SELECT * FROM RA_INTERFACE_DISTRIBUTIONS_ALL 

    WHERE INTERFACE_LINE_ID IN (SELECTINTERFACE_LINE_ID FROM RA_INTERFACE_LINES_ALL WHERE sales_order = '65961' );

    数据插入到RA Interface之后,再看OE_ORDER_LINES_ALL的INVOICE_INTERFACE_STATUS_CODE字段变成了Yes,INVOICED_QUANTITY变为了订单行的数量。并且你会发现订单行的状态变成了Closed,订单头的状态仍为Booked。


    2.16 自动开票主程序(生成ARINVOICE)


    三)销售相关其他API

    3.1   暂挂/释放暂挂

    方法一:

    DECLARE
      l_Return_Status   VARCHAR2(30);
      l_Msg_Data        VARCHAR2(4000);
      l_Msg_Count       NUMBER;
      l_Hold_Source_Rec Oe_Holds_Pvt.Hold_Source_Rec_Type;
    BEGIN
      
      Fnd_Global.Apps_Initialize(User_Id => 1143,Resp_Id => 50877,Resp_Appl_Id => 20004);
      mo_global.init('CUX');
      mo_global.set_policy_context('S',88);
      oe_msg_pub.Initialize;
      
      l_Hold_Source_Rec                  := Oe_Holds_Pvt.g_Miss_Hold_Source_Rec;
      l_Hold_Source_Rec.Hold_Id          := &Hold_Id; 
      l_Hold_Source_Rec.Hold_Entity_Code := 'O'; -- order level hold 
      l_Hold_Source_Rec.Hold_Entity_Id   := &header_id; -- header_id of the order 
      l_Hold_Source_Rec.Header_Id        := &header_id; -- header_id of the order 
      --l_Hold_Source_Rec.line_id          := &line_id;--如果是暂挂订单行,否则无需赋值
    
      Oe_Holds_Pub.Apply_Holds(p_Api_Version     => 1.0,
                               p_Init_Msg_List   => Fnd_Api.g_True,
                               p_Commit          => Fnd_Api.g_True,
                               p_Hold_Source_Rec => l_Hold_Source_Rec,
                               x_Return_Status   => l_Return_Status,
                               x_Msg_Count       => l_Msg_Count,
                               x_Msg_Data        => l_Msg_Data);
    
      IF l_Return_Status = Fnd_Api.g_Ret_Sts_Success THEN
        Dbms_Output.Put_Line('应用暂挂成功!');
        COMMIT;
      ELSE
        FOR l_Index IN 1 .. l_Msg_Count LOOP
          Dbms_Output.Put_Line(oe_Msg_Pub.Get(p_Msg_Index => l_Index,p_Encoded   => 'F'));
         END LOOP;
        ROLLBACK;
      END IF;  
    END;
    

    方法二:

    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;
    
      i                    NUMBER := 1;
      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;
      x_Return_Status      VARCHAR2(1);
      x_Msg_Count          NUMBER;
      x_Msg_Data           VARCHAR2(255);
    
    BEGIN
    
      Fnd_Global.Apps_Initialize(User_Id => 1143,Resp_Id => 50877,Resp_Appl_Id => 20004);
      Mo_Global.init('CUX');--必须初始化职责的应用,否则无法完成OU验证
      mo_global.set_policy_context('S',88);
      Oe_Msg_Pub.Initialize;  
      /***************************
      --应用暂挂
      ***************************/
      /*i := 1;
      l_action_request_tbl(i).request_type := oe_globals.G_APPLY_HOLD; 
      l_action_request_tbl(i).entity_code  := oe_globals.G_ENTITY_HEADER;
      l_action_request_tbl(i).entity_id    := &header_id;
      l_action_request_tbl(i).param1       := &Hold_ID;--暂挂名称标记
      l_action_request_tbl(i).param2       := 'O';--暂挂来源:“O”表示来自订单的暂挂  
    
      --选填字段
      *l_action_request_tbl(i).Param3       := --暂挂来源的ID*
      *l_action_request_tbl(i).param4       := '';  --暂挂备注*
      *l_action_request_tbl(i).date_param1  := sysdate+7;--暂挂截止日*
      *l_action_request_tbl(i).parm6-param20  attribute1-15**/
      /***************************
      ---释放暂挂
      ***************************/
      i := 1;
      l_action_request_tbl(i).request_type := oe_globals.G_RELEASE_HOLD; 
      l_action_request_tbl(i).entity_code  := oe_globals.G_ENTITY_HEADER;
      l_action_request_tbl(i).entity_id    := &header_id;
      l_action_request_tbl(i).param1       := &Hold_ID;--暂挂名称标记
      l_action_request_tbl(i).param4       := '&reason_code';--释放原因  
    
      /*--选填字段
       param2和param3这两个参数只是为了更精准的定位一个暂估名称
      l_action_request_tbl(i).param2       := 'O'; --暂挂来源:“O”表示来自订单
      l_action_request_tbl(i).Param3       := ''   --暂挂来源的ID
      /*l_action_request_tbl(i).param5     := '手工取消';--释放备注*/
      
      Oe_Order_Pub.Process_Order(p_Api_Version_Number     => 1.0,
                                 p_Init_Msg_List          => NULL,
                                 p_Return_Values          => NULL,
                                 p_Action_Request_Tbl     => l_Action_Request_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,
                                 x_Return_Status => x_Return_Status,
                                 x_Msg_Count     => x_Msg_Count,
                                 x_Msg_Data      => x_Msg_Data);
        
       IF (x_Msg_Count>0) THEN--这里不能按x_return_status的状态判断
         FOR l_Index IN 1 .. x_Msg_Count LOOP
          Dbms_Output.Put_Line(Oe_Msg_Pub.Get(p_Msg_Index => l_Index,p_Encoded   => 'F'));
         END LOOP;
       ELSE
         Dbms_Output.Put_Line('暂挂成功!');
       END IF;
    END;
    

    3.2  修改量(创建/更新)

    DECLARE
      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;
      --OUT var
      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;
        
      CURSOR csr_modify IS
      SELECT ql.*
        FROM qp_list_lines       ql
       WHERE ql.list_line_id = &modify_list_line_id;
           
      l_return_status       VARCHAR2(1);
      l_msg_count           NUMBER;
      l_msg_data            VARCHAR2(2000);
      l_price_adjustment_id NUMBER;
    BEGIN
      
      fnd_global.apps_initialize(user_id => 1143,resp_id => 50877,resp_appl_id => 20004);
      Mo_Global.init('CUX');
      oe_msg_pub.initialize;
    
      l_header_rec           := oe_order_pub.g_miss_header_rec;
      l_header_rec.header_id := &header_id;
      l_header_rec.operation := oe_globals.g_opr_update;
          
      l_line_tbl.delete;
      l_line_tbl(1)                      := oe_order_pub.g_miss_line_rec;
      l_line_tbl(1).header_id            := l_header_rec.header_id;
      l_line_tbl(1).operation            := oe_globals.g_opr_update;
      l_line_tbl(1).calculate_price_flag := 'Y';
      l_line_tbl(1).line_id              := &line_id;
      
      --/*判断是否存在相同名称的修改量*/
      BEGIN
        SELECT opa.price_adjustment_id
          INTO l_price_adjustment_id
          FROM oe_price_adjustments opa
         WHERE opa.list_line_id = &modify_list_line_id
           AND opa.line_id = &line_id
           AND opa.applied_flag = 'Y'
           AND ROWNUM =1;
      EXCEPTION
        WHEN OTHERS THEN NULL;
      END;
      
      IF (l_price_adjustment_id IS NULL) THEN--创建修改量
        FOR rec_mod IN csr_modify LOOP
          l_line_adj_tbl(1)                       := oe_order_pub.g_miss_line_adj_rec;
          l_line_adj_tbl(1).operation             := oe_globals.g_opr_create;
          l_line_adj_tbl(1).header_id             := l_header_rec.header_id;
          l_line_adj_tbl(1).line_id               := l_line_tbl(1).line_id;
          l_line_adj_tbl(1).list_header_id        := rec_mod.list_header_id;
          l_line_adj_tbl(1).list_line_id          := rec_mod.list_line_id;
          l_line_adj_tbl(1).applied_flag          := 'Y';--applied_flag该字段是表示修改量是否应用,如果为否或为空,修改量不会应用到销售定价上.在界面查不到
          l_line_adj_tbl(1).updated_flag          := 'Y';
          l_line_adj_tbl(1).operand               := &operand;
        END LOOP;
      ELSE--更新修改量
          l_line_adj_tbl(1)                       := oe_order_pub.G_MISS_LINE_ADJ_REC;
          l_line_adj_tbl(1).operation             := oe_globals.g_opr_update;
          l_line_adj_tbl(1).price_adjustment_id   := l_price_adjustment_id;
          l_line_adj_tbl(1).operand               := &operand;
          l_Line_Adj_Tbl(1).Updated_Flag          := 'Y';                  
          l_line_adj_tbl(1).change_reason_code    := 'MANUAL';    
      END IF;
      
      OE_Order_PUB.process_order(p_org_id             => &org_id,
                                 p_api_version_number => 1.0,
                                 p_init_msg_list      => NULL,
                                 p_return_values      => NULL,
                                 p_header_rec         => l_header_rec,
                                 p_line_tbl           => l_line_tbl,
                                 p_Line_Adj_tbl       => l_line_adj_tbl,
                                 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,
                                 x_return_status          => l_return_status,
                                 x_msg_count              => l_msg_count,
                                 x_msg_data               => l_msg_data);
         IF (l_return_status <> 'S') THEN
             FOR l_index IN 1 .. l_msg_count LOOP
               dbms_output.put_line(oe_msg_pub.get(p_msg_index => l_index,p_encoded=>'F'));
             END LOOP;
         ELSE
           COMMIT;
           dbms_output.put_line('创建/修改修改量成功!');
         END IF;
    END;
    

    3.3  重订价

    DECLARE
       l_sel_rec_tbl   oe_globals.selected_record_tbl;
       l_return_status VARCHAR2(100);
       l_msg_count     NUMBER;
       l_msg_data      VARCHAR2(100);
       x_msg_data      VARCHAR2(1000);
    
    BEGIN
       mo_global.init('ONT');
       oe_msg_pub.initialize;
       oe_debug_pub.initialize;
       fnd_global.apps_initialize(user_id      => 1170,
                                  resp_id      => 50717,
                                  resp_appl_id => 20005);
       l_sel_rec_tbl(1).id1 := 3012; --LINE_ID/HEADER_ID
       l_sel_rec_tbl(1).org_id := 82;
       oe_order_adj_pvt.price_action(p_selected_records => l_sel_rec_tbl,
                                     p_price_level      => 'LINE' --'LINE'/'ORDER'
                                    ,
                                     x_return_status    => l_return_status,
                                     x_msg_count        => l_msg_count,
                                     x_msg_data         => l_msg_data);
    
       IF l_msg_count > 0 THEN
          FOR l_index IN 1 .. l_msg_count LOOP
             l_msg_data := oe_msg_pub.get(p_msg_index => l_index,
                                          p_encoded   => 'F');
             x_msg_data := x_msg_data || '-' || l_msg_data;
          END LOOP;
       
          dbms_output.put_line('E');
          dbms_output.put_line('l_return_status:' || l_return_status);
          dbms_output.put_line('l_msg_count:' || l_msg_count);
          dbms_output.put_line('x_msg_data:' || x_msg_data);
       
       ELSE
          dbms_output.put_line('S');
          dbms_output.put_line('l_return_status:' || l_return_status);
          dbms_output.put_line('l_msg_count:' || l_msg_count);
          dbms_output.put_line('x_msg_data:' || x_msg_data);
       END IF; -- IF l_msg_count > 0 THEN
    END;
    
    /*SELECT * FROM OE_PRICE_ADJUSTMENTS;*/
    

    3.4  更多API参考

    Note Number

    Script Description

    Document 364316.1

    How does one import Credit Card Payments using Process Order API ?

    Document 427947.1

    How does one process orders from different operating units using Process Order API ?

    Document 470741.1

    How Does One Book An Order Using Process Order API ?

    Document 745369.1

    How Does One Update Order Header Details Using Process Order API For R12 ?

    Document 746783.1

    Script To Create An Order With One Line

    Document 746787.1

    Process Order API In Order Management

    Document 746796.1

    Script To Add A New Line To An Existing Order

    Document 746797.1

    Script To Cancel An Existing Order

    Document 746798.1

    Script To Cancel An Existing Order Line

    Document 746802.1

    Script To Update An Existing Order Line

    Document 746803.1

    Script To Reserve an Order Line

    Document 746804.1

    Script To Unreserve An Order Line

    Document 746808.1

    Script To Split An Order Line

    Document 746809.1

    Script To Delete An Order

    Document 746810.1

    Script To Delete An Order Line

    Document 746811.1

    Script To Apply Hold in Sales Order

    Document 746812.1

    Script To Release Hold In A Sales Order

    Document 755135.1

    How does one update Unit Price using Process Order API?

    Document 811264.1

    How Does One Book An Order Using OE_INBOUND_INT.PROCESS_ORDER() ?

    Document 869085.1

    Process Order API In Order Management - R12 Updates

    Document 1128445.1

    Need Script To Apply Hold using Process Order API in R12 ?

    Document 1907954.1

    Seeded API Not Generating Trxn_Extension_id In Oe_payments Table For ACH Payment Type Information

    客户信用限

    http://blog.csdn.net/caixingyun/article/category/2587183


    5.1   高级定价知识&应用

    可参考我的博客

    http://blog.csdn.net/cai_xingyun/article/details/41009943

    http://blog.csdn.net/cai_xingyun/article/details/41010189

    更多:

    http://blog.csdn.net/cai_xingyun/article/category/2701797

    更多,参考其他我的博客









  • 相关阅读:
    ASP扫盲学习班第六课 添加新保存的数据
    三级联动菜单免刷新加载
    ASP按定制格式导出word文件的完美解决思路
    通用客户资源管理系统(客户资料保护库)
    SmR 通用信息采集系统(新闻小偷)
    ASP扫盲学习班第三课 程序界面的设计
    我的新作品(单身贵族网全站)
    《将博客搬至CSDN》
    我的新作品
    asp函数大全
  • 原文地址:https://www.cnblogs.com/wanghang/p/6298995.html
Copyright © 2020-2023  润新知