转载

创建销售单 API

PROCEDURE get_so_header(x_return_status    OUT NOCOPY VARCHAR2
                         ,x_msg_count        OUT NOCOPY NUMBER
                         ,x_msg_data         OUT NOCOPY VARCHAR2
                         ,p_cust_number      VARCHAR2
                         ,p_org_id           NUMBER
                         ,p_source_system_id NUMBER
                          
                         ,p_customer_id   NUMBER
                         ,p_bill_site_id  NUMBER
                         ,p_ship_site_id  NUMBER
                         ,p_order_type_id NUMBER
                         ,p_price_list_id NUMBER
                         ,p_term_id       NUMBER
                          
                         ,p_employee_id        NUMBER
                         ,p_currency_code      VARCHAR2
                         ,p_organization_id    NUMBER
                         ,p_sales_channel_code VARCHAR2
                         ,p_ship_method        VARCHAR2
                         ,p_attribute11        VARCHAR2
                         ,p_attribute12        VARCHAR2
                         ,p_attribute13        VARCHAR2
                          
                         ,x_header_rec_type OUT oe_order_pub.header_rec_type
                         ,x_oe_header_id    OUT NUMBER) IS
    l_api_name       CONSTANT VARCHAR2(30) := 'get_so_header';
    l_api_version    CONSTANT NUMBER := 1;
    l_savepoint_name CONSTANT VARCHAR2(30) := 'get_so_header01';
    l_header_rec_type oe_order_pub.header_rec_type;
    l_ou_short_code   VARCHAR2(50);
 
  BEGIN
    SELECT v.short_code INTO l_ou_short_code FROM hr_operating_units v WHERE v.organization_id = fnd_global.org_id;
    --
    --根据 OE_HEADER_ID 获取计料单上的相关数据
 
    l_header_rec_type := oe_order_pub.g_miss_header_rec;
    IF g_order_header_id IS NULL THEN
      SELECT oe_order_headers_s.nextval INTO l_header_rec_type.header_id FROM dual;
    ELSE
      l_header_rec_type.header_id := g_order_header_id;
    END IF;
    x_oe_header_id                    := l_header_rec_type.header_id;
    l_header_rec_type.operation       := oe_globals.g_opr_create;
    l_header_rec_type.order_source_id := p_source_system_id; --订单来源-online
    l_header_rec_type.org_id          := p_org_id;
    IF g_order_number IS NULL THEN
      g_order_number := cux_doc_sequence_utl.next_seq_number(p_doc_type    => 'ORDER',
                                                             p_doc_prefix  => l_ou_short_code || to_char(SYSDATE, 'YYMMDD'),
                                                             p_seq_length  => 6,
                                                             p_pk1_value   => l_ou_short_code || to_char(SYSDATE, 'YYMMDD'),
                                                             p_pk2_value   => NULL,
                                                             p_pk3_value   => NULL,
                                                             p_pk4_value   => NULL,
                                                             p_pk5_value   => NULL,
                                                             p_init_number => 1);
    
    END IF;
    l_header_rec_type.order_number            := g_order_number;
    l_header_rec_type.ordered_date            := g_date;
    l_header_rec_type.order_type_id           := p_order_type_id;
    l_header_rec_type.salesrep_id             := p_employee_id;
    l_header_rec_type.price_list_id           := nvl(p_price_list_id, get_default_list_id(p_order_type_id));
    l_header_rec_type.sold_from_org_id        := p_org_id;
    l_header_rec_type.sold_to_org_id          := p_customer_id;
    l_header_rec_type.ship_from_org_id        := p_organization_id;
    l_header_rec_type.ship_to_org_id          := p_ship_site_id;
    l_header_rec_type.invoice_to_org_id       := p_bill_site_id;
    l_header_rec_type.transactional_curr_code := p_currency_code;
    l_header_rec_type.sales_channel_code      := p_sales_channel_code;
    l_header_rec_type.request_date            := g_date;
    l_header_rec_type.pricing_date            := g_date;
    l_header_rec_type.tax_exempt_flag         := 'S'; --税务处理-标准
    l_header_rec_type.ready_flag              := 'Y';
    l_header_rec_type.cancelled_flag          := 'N';
    l_header_rec_type.booked_flag             := 'N';
    l_header_rec_type.order_category_code     := 'ORDER';
    l_header_rec_type.flow_status_code        := 'ENTERED';
    l_header_rec_type.payment_term_id         := p_term_id;
    l_header_rec_type.freight_carrier_code    := p_ship_method;
    l_header_rec_type.cust_po_number          := p_cust_number;
    l_header_rec_type.attribute10             := g_bgbu;
    l_header_rec_type.attribute11             := p_attribute11;
    l_header_rec_type.attribute12             := p_attribute12;
    l_header_rec_type.attribute13             := p_attribute13;
 
    --who
    l_header_rec_type.created_by        := g_user_id;
    l_header_rec_type.creation_date     := g_date;
    l_header_rec_type.last_updated_by   := g_user_id;
    l_header_rec_type.last_update_date  := g_date;
    l_header_rec_type.last_update_login := fnd_global.login_id;
 
    -------------------------------------------------导入弹性域
 
    x_header_rec_type := l_header_rec_type;
    <<end_process>>
    NULL;
    --end
 
  EXCEPTION
 
    WHEN OTHERS THEN
      NULL;
  END get_so_header;

 PROCEDURE get_so_lines(p_api_version   IN NUMBER
                        ,p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false
                        ,p_commit        IN VARCHAR2 DEFAULT fnd_api.g_false
                        ,x_return_status OUT NOCOPY VARCHAR2
                        ,x_msg_count     OUT NOCOPY NUMBER
                        ,x_msg_data      OUT NOCOPY VARCHAR2
                        ,
                         --p_oe_line_id      IN NUMBER,
                         p_line_num           IN NUMBER
                        ,p_line_type_id       IN NUMBER
                        ,p_delivery_date      IN DATE
                        ,p_item_id            IN VARCHAR2
                        ,p_quantity           IN NUMBER
                        ,p_unit_price         IN NUMBER
                        ,p_item_uom_code      IN VARCHAR2 DEFAULT NULL
                        ,p_subinventory       IN VARCHAR2 DEFAULT NULL
                        ,p_tax_code           IN VARCHAR2
                        ,p_return_reason_code IN VARCHAR2 DEFAULT NULL
                        ,p_attribute8         IN VARCHAR2
                        ,p_attribute9         IN VARCHAR2
                        ,p_attribute10        IN VARCHAR2
                        ,p_attribute11        IN VARCHAR2
                        ,p_attribute12        IN VARCHAR2
                        ,p_attribute13        IN VARCHAR2
                        ,p_attribute14        IN VARCHAR2
                        ,p_header_rec_type    IN oe_order_pub.header_rec_type
                        ,x_line_rec_type      OUT oe_order_pub.line_rec_type) IS
    l_api_name       CONSTANT VARCHAR2(30) := 'get_so_lines';
    l_api_version    CONSTANT NUMBER := 1;
    l_savepoint_name CONSTANT VARCHAR2(30) := 'get_so_lines01';
    l_line_rec_type oe_order_pub.line_rec_type;
    l_detail_flag   VARCHAR2(1);
    l_return_status VARCHAR2(1);
    l_index         NUMBER;
    l_msg_count     NUMBER;
    l_msg_data      VARCHAR2(30000);
 
    l_organization_name org_organization_definitions.organization_name%TYPE;
 
    l_assigned_flag VARCHAR2(1);
  BEGIN
 
    --
    SELECT oe_order_lines_s.nextval INTO l_line_rec_type.line_id FROM dual;
 
    l_line_rec_type.operation := oe_globals.g_opr_create;
    -- l_line_rec_type.line_category_code := 'ORDER';
    l_line_rec_type.order_source_id  := p_header_rec_type.order_source_id;
    l_line_rec_type.org_id           := p_header_rec_type.org_id;
    l_line_rec_type.ship_from_org_id := p_header_rec_type.ship_from_org_id;
    l_line_rec_type.line_number      := p_line_num;
    l_line_rec_type.shipment_number  := 1;
    l_line_rec_type.header_id        := p_header_rec_type.header_id;
 
    l_line_rec_type.line_type_id := p_line_type_id;
 
    l_line_rec_type.inventory_item_id  := p_item_id;
    l_line_rec_type.unit_selling_price := p_unit_price;
    l_line_rec_type.unit_list_price    := p_unit_price;
 
    l_line_rec_type.price_list_id        := p_header_rec_type.price_list_id;
    l_line_rec_type.calculate_price_flag := 'N';
    l_line_rec_type.ordered_item_id      := l_line_rec_type.inventory_item_id;
    l_line_rec_type.request_date         := g_date;
    l_line_rec_type.promise_date         := g_date;
    l_line_rec_type.schedule_ship_date   := p_delivery_date;
    l_line_rec_type.ship_to_org_id       := p_header_rec_type.ship_to_org_id;
    l_line_rec_type.invoice_to_org_id    := p_header_rec_type.invoice_to_org_id;
    l_line_rec_type.sold_to_org_id       := p_header_rec_type.sold_to_org_id;
    l_line_rec_type.tax_date             := g_date;
    l_line_rec_type.payment_term_id      := p_header_rec_type.payment_term_id;
    l_line_rec_type.ordered_quantity     := p_quantity;
    l_line_rec_type.order_quantity_uom   := p_item_uom_code;
    l_line_rec_type.tax_code             := p_tax_code;
    l_line_rec_type.subinventory         := p_subinventory;
    l_line_rec_type.item_type_code       := 'STANDARD';
    l_line_rec_type.flow_status_code     := 'ENTERED';
    --l_line_rec_type.price_list_id         := p_header_rec_type.price_list_id;
    l_line_rec_type.open_flag              := 'Y';
    l_line_rec_type.status_flag            := 'Y';
    l_line_rec_type.return_reason_code     := p_return_reason_code;
    l_line_rec_type.pricing_quantity       := l_line_rec_type.ordered_quantity;
    l_line_rec_type.pricing_quantity_uom   := l_line_rec_type.order_quantity_uom;
    l_line_rec_type.salesrep_id            := p_header_rec_type.salesrep_id;
    l_line_rec_type.shipment_priority_code := p_header_rec_type.shipment_priority_code;
    l_line_rec_type.shipping_method_code   := p_header_rec_type.shipping_method_code;
    l_line_rec_type.freight_carrier_code   := p_header_rec_type.freight_carrier_code;
    l_line_rec_type.cust_po_number         := p_header_rec_type.cust_po_number;
    l_line_rec_type.booked_flag            := 'N';
 
    l_line_rec_type.tax_exempt_flag := 'S';
    l_line_rec_type.item_type_code  := 'STANDARD'; --项目类型
 
    --------------------------------------------------------------
 
    l_line_rec_type.attribute8  := p_attribute8;
    l_line_rec_type.attribute9  := p_attribute9;
    l_line_rec_type.attribute10 := p_attribute10;
    l_line_rec_type.attribute11 := p_attribute11;
    l_line_rec_type.attribute12 := p_attribute12;
    l_line_rec_type.attribute13 := p_attribute13;
    l_line_rec_type.attribute14 := p_attribute14;
    --who
    l_line_rec_type.created_by        := g_user_id;
    l_line_rec_type.creation_date     := g_date;
    l_line_rec_type.last_updated_by   := g_user_id;
    l_line_rec_type.last_update_date  := g_date;
    l_line_rec_type.last_update_login := fnd_global.login_id;
    x_line_rec_type                   := l_line_rec_type;
    <<end_line>>
    NULL;
  EXCEPTION
 
    WHEN OTHERS THEN
      NULL;
  END get_so_lines;

调API
  l_action_request_tbl := oe_order_pub.g_miss_request_tbl;
            l_action_request_tbl(1).request_type := oe_globals.g_book_order;
            l_action_request_tbl(1).entity_code := oe_globals.g_entity_header;
            process_so_data(p_api_version        => 1.0,
                            p_init_msg_list      => fnd_api.g_true,
                            p_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_type    => l_header_rec_type,
                            p_action_request_tbl => l_action_request_tbl,
                            p_line_rec_tbl       => l_line_rec_tbl,
                            x_header_rec         => l_header_result_rec,
                            x_line_tbl           => x_line_tbl);

正文到此结束
Loading...