Showing posts with label QUOTE. Show all posts
Showing posts with label QUOTE. Show all posts

Wednesday, December 5, 2018

Query to Join Order Management Tables with Oracle Quoting tables

SELECT ooh.header_id
         , ooh.order_number
         , ool.line_Id
         , ool.ship_from_org_id organization_id
         , ool.inventory_item_id
         , ool.ordered_quantity
         , ool.order_quantity_uom
         , ool.line_type_id  xx_line_type_id
         , qtl.order_line_type_id
         , ool.request_date
         , ool.creation_date
         , ool.ship_to_org_id
         , ool.sold_to_org_id
         , ool.subinventory

    FROM   aso.aso_quote_headers_all qte
         , aso.aso_quote_lines_all qtl
         , aso.aso_shipments shp
         , ont.oe_order_headers_all ooh
         , ont.oe_order_lines_all ool
    WHERE  qte.quote_header_Id = 382
    AND    qtl.quote_header_id = qte.quote_header_id
    AND    shp.quote_header_id = qtl.quote_header_id
    AND    shp.quote_line_id = qtl.quote_line_id
    AND    ooh.orig_sys_document_ref like qte.quote_number||':%'
    AND    ooh.source_document_id = qte.quote_header_id
    AND    ool.header_id = ooh.header_id
    AND    ool.source_document_line_Id = shp.shipment_id ;

Friday, February 16, 2018

How to Create Quote Anonymous Blocks in Oracle EBS

DECLARE
   l_org_id                        VARCHAR2 (1254);
   li_inventory_item_id            NUMBER;
   li_currency_code                VARCHAR2 (1254);
   li_uom_code                     VARCHAR2 (1254);
   li_quantity                     NUMBER;
   li_quote_category_code          VARCHAR2 (1254);
   li_line_list_price              VARCHAR2 (2000);
   li_order_type_id                VARCHAR2 (2000);
   li_price_list_id                NUMBER;
   li_quote_source_code            VARCHAR2 (2000);
   li_party_id                     NUMBER;
   li_payment_term_id              NUMBER;
   li_cust_account_id              NUMBER;
   li_invoice_to_cust_account_id   NUMBER;
   li_invoice_to_party_site_id     NUMBER;
   li_invoice_to_party_id          NUMBER;
   li_invoice_to_cust_party_id     NUMBER;
   li_total_quote_price            NUMBER;
   li_total_list_price             NUMBER;
   li_total_adjusted_amount        NUMBER;
   ln_line_number                  NUMBER;
   l_quote_line_id                 NUMBER;
   l_ref_line_id                   NUMBER;
   x_relationship_id               NUMBER;
   x_return_status                 VARCHAR2 (2000);
   x_msg_count                     VARCHAR2 (2000);
   x_msg_data                      VARCHAR2 (2000);
   l_px_quote_line_detail_id       NUMBER;
   px_quote_line_detail_id         NUMBER;
---create quote
   l_quote_status_id               NUMBER;
   l_control_rec                   aso_quote_pub.control_rec_type;
   l_qte_header_rec                aso_quote_pub.qte_header_rec_type;
   l_qte_line_rec                  aso_quote_pub.qte_line_rec_type;
   l_qte_line_tbl                  aso_quote_pub.qte_line_tbl_type;
   l_qte_line_dtl_tbl              aso_quote_pub.qte_line_dtl_tbl_type;
   -- l_hd_Price_Attr_Tbl ASO_QUOTE_PUB.Price_Attributes_Tbl_Type;
   l_hd_payment_tbl                aso_quote_pub.payment_tbl_type;
   l_payment_rec                   aso_quote_pub.payment_rec_type;
   l_hd_shipment_rec               aso_quote_pub.shipment_rec_type;
   -- l_hd_freight_charge_tbl ASO_QUOTE_PUB.Freight_Charge_Tbl_Type;
   l_hd_tax_detail_tbl             aso_quote_pub.tax_detail_tbl_type;
   l_tax_detail_rec                aso_quote_pub.tax_detail_rec_type;
   l_tax_control_rec               aso_tax_int.tax_control_rec_type;
   l_line_attr_ext_tbl             aso_quote_pub.line_attribs_ext_tbl_type;
   l_line_rltship_tbl              aso_quote_pub.line_rltship_tbl_type;
   l_price_adjustment_tbl          aso_quote_pub.price_adj_tbl_type;
   l_price_adj_attr_tbl            aso_quote_pub.price_adj_attr_tbl_type;
   l_price_adj_rltship_tbl         aso_quote_pub.price_adj_rltship_tbl_type;
   l_ln_price_attr_tbl             aso_quote_pub.price_attributes_tbl_type;
   l_ln_payment_tbl                aso_quote_pub.payment_tbl_type;
   l_ln_shipment_tbl               aso_quote_pub.shipment_tbl_type;
   l_ln_freight_charge_tbl         aso_quote_pub.freight_charge_tbl_type;
   l_ln_tax_detail_tbl             aso_quote_pub.tax_detail_tbl_type;
   lx_qte_header_rec               aso_quote_pub.qte_header_rec_type;
   lx_qte_line_tbl                 aso_quote_pub.qte_line_tbl_type;
   lx_qte_line_dtl_tbl             aso_quote_pub.qte_line_dtl_tbl_type;
   lx_hd_price_attr_tbl            aso_quote_pub.price_attributes_tbl_type;
   lx_hd_payment_tbl               aso_quote_pub.payment_tbl_type;
   lx_hd_shipment_rec              aso_quote_pub.shipment_rec_type;
   lx_hd_freight_charge_tbl        aso_quote_pub.freight_charge_tbl_type;
   lx_hd_tax_detail_tbl            aso_quote_pub.tax_detail_tbl_type;
   lx_line_attr_ext_tbl            aso_quote_pub.line_attribs_ext_tbl_type;
   lx_line_rltship_tbl             aso_quote_pub.line_rltship_tbl_type;
   lx_price_adjustment_tbl         aso_quote_pub.price_adj_tbl_type;
   lx_price_adj_attr_tbl           aso_quote_pub.price_adj_attr_tbl_type;
   lx_price_adj_rltship_tbl        aso_quote_pub.price_adj_rltship_tbl_type;
   lx_ln_price_attr_tbl            aso_quote_pub.price_attributes_tbl_type;
   lx_ln_payment_tbl               aso_quote_pub.payment_tbl_type;
   lx_ln_shipment_tbl              aso_quote_pub.shipment_tbl_type;
   lx_ln_freight_charge_tbl        aso_quote_pub.freight_charge_tbl_type;
   lx_ln_tax_detail_tbl            aso_quote_pub.tax_detail_tbl_type;
   lx_hd_shipment_tbl              aso_quote_pub.shipment_tbl_type;
   lx_return_status                VARCHAR2 (1);
   lx_msg_count                    NUMBER;
   l_quote_number                  NUMBER;
   lx_msg_data                     VARCHAR2 (2000);
   my_message                      VARCHAR2 (2000);
   l_file                          VARCHAR2 (2000);
   lnx_quote_line_id               NUMBER;
   l_hd_sales_credit_tbl           aso_quote_pub.sales_credit_tbl_type
                                     := aso_quote_pub.g_miss_sales_credit_tbl;
   l_ln_sales_credit_tbl           aso_quote_pub.sales_credit_tbl_type
                                     := aso_quote_pub.g_miss_sales_credit_tbl;
   lx_hd_sales_credit_tbl          aso_quote_pub.sales_credit_tbl_type;
   lx_quote_party_tbl              aso_quote_pub.quote_party_tbl_type;
   lx_ln_sales_credit_tbl          aso_quote_pub.sales_credit_tbl_type;
   lx_ln_quote_party_tbl           aso_quote_pub.quote_party_tbl_type;
--l_payment_rec ASO_QUOTE_PUB.Payment_Rec_Type;
   l_shipment_rec                  aso_quote_pub.shipment_rec_type;
--l_tax_detail_rec ASO_QUOTE_PUB.Tax_Detail_Rec_Type;
   lx_hd_attr_ext_tbl              aso_quote_pub.line_attribs_ext_tbl_type;
   l_qte_line_dtl_rec              aso_quote_pub.qte_line_dtl_rec_type;
   lc_last_update_date             DATE;
---relatioship
   l_line_rtlship_rec              aso_quote_pub.line_rltship_rec_type;
   qte_lin                         NUMBER;
   my_message                      VARCHAR2 (2000);
BEGIN
--l_org_id := fnd_profile.VALUE('ORG_ID');
   l_org_id := 1;
   DBMS_APPLICATION_INFO.set_client_info (1);
   fnd_global.apps_initialize (1066, 50378, 279);
--user_id,responsibility_id,application id
   mo_global.init ('QOT');
   mo_global.set_policy_context ('S', 1);                   --For Multiple OU
--commit;
   l_control_rec.calculate_tax_flag := 'Y';
   l_control_rec.calculate_freight_charge_flag := 'Y';
   l_control_rec.pricing_request_type := 'ASO';
   l_control_rec.header_pricing_event := 'BATCH';
   l_qte_header_rec.quote_name := 'Payload Quote Testing';
   l_qte_header_rec.quote_source_code := 'Order Capture Quotes';
   l_qte_header_rec.currency_code := 'USD';
   l_qte_header_rec.party_id := 1241;
   l_qte_header_rec.price_list_id := 7040991;
----------------- LINES ---------------------------------
   l_qte_line_tbl (1).organization_id := 4;
   l_qte_line_tbl (1).operation_code := 'CREATE';
   l_qte_line_tbl (1).inventory_item_id := 28931;
   l_qte_line_tbl (1).quantity := 1;
   l_qte_line_tbl (1).uom_code := 'EA';
   l_qte_line_tbl (1).org_id := 1;
---------create quote
  dbms_output.put_line('begin for the create quote header id ');
   aso_quote_pub.create_quote
                        (p_api_version_number           => 1.0,
                         p_init_msg_list                => fnd_api.g_true,
                         p_control_rec                  => l_control_rec,
                         p_qte_header_rec               => l_qte_header_rec,
                         p_qte_line_tbl                 => l_qte_line_tbl,
                         p_hd_payment_tbl               => l_hd_payment_tbl,
                         p_hd_tax_detail_tbl            => l_hd_tax_detail_tbl,
                         x_qte_header_rec               => lx_qte_header_rec,
                         x_qte_line_tbl                 => lx_qte_line_tbl,
                         x_qte_line_dtl_tbl             => lx_qte_line_dtl_tbl,
                         x_hd_price_attributes_tbl      => lx_hd_price_attr_tbl,
                         x_hd_payment_tbl               => lx_hd_payment_tbl,
                         x_hd_shipment_rec              => lx_hd_shipment_rec,
                         x_hd_freight_charge_tbl        => lx_hd_freight_charge_tbl,
                         x_hd_tax_detail_tbl            => lx_hd_tax_detail_tbl,
                         x_line_attr_ext_tbl            => lx_line_attr_ext_tbl,
                         x_line_rltship_tbl             => lx_line_rltship_tbl,
                         x_price_adjustment_tbl         => lx_price_adjustment_tbl,
                         x_price_adj_attr_tbl           => lx_price_adj_attr_tbl,
                         x_price_adj_rltship_tbl        => lx_price_adj_rltship_tbl,
                         x_ln_price_attributes_tbl      => lx_ln_price_attr_tbl,
                         x_ln_payment_tbl               => lx_ln_payment_tbl,
                         x_ln_shipment_tbl              => lx_ln_shipment_tbl,
                         x_ln_freight_charge_tbl        => lx_ln_freight_charge_tbl,
                         x_ln_tax_detail_tbl            => lx_ln_tax_detail_tbl,
                         x_return_status                => lx_return_status,
                         x_msg_count                    => lx_msg_count,
                         x_msg_data                     => lx_msg_data
                        );

   fnd_msg_pub.count_and_get (p_encoded      => 'F',
                              p_count        => lx_msg_count,
                              p_data         => lx_msg_data
                             );
--   COMMIT;
   DBMS_OUTPUT.put_line ('no. of FND messages :' || lx_msg_count);

   FOR k IN 1 .. lx_msg_count
   LOOP
      lx_msg_data := fnd_msg_pub.get (p_msg_index => k, p_encoded => 'F');
      DBMS_OUTPUT.put_line ('Error msg: ' || SUBSTR (lx_msg_data, 1, 240));
   END LOOP;

   DBMS_OUTPUT.put_line ('Return Status: ' || lx_return_status);
   DBMS_OUTPUT.put_line ('msg count:' || TO_CHAR (lx_msg_count));
   DBMS_OUTPUT.put_line ('Message Data: ' || lx_msg_data);
   DBMS_OUTPUT.put_line (   'qte_header_id: '
                         || TO_CHAR (lx_qte_header_rec.quote_header_id)
                        );
   DBMS_OUTPUT.put_line ('end');
--   COMMIT;
END;

Monday, January 22, 2018

Join Order Management & Quoting Tables in Oracle | SQL Query

SELECT oha.header_id
             , oha.order_number
             , ola.line_Id
            , ola.ship_from_org_id organization_id
             , ola.inventory_item_id
            , ola.ordered_quantity
           , ola.order_quantity_uom
          , ola.line_type_id  xx_line_type_id
           , aql.order_line_type_id
         , ola.request_date
         , ola.creation_date
         , ola.ship_to_org_id
        , ola.sold_to_org_id
          ,ola.subinventory

    FROM   aso_quote_headers_all aqh
         , aso_quote_lines_all aql
         , aso_shipments shp
         , oe_order_headers_all oha
         , ont.oe_order_lines_all ola
    WHERE  aqh.quote_header_Id = '&quote_header_id'
    AND    aql.quote_header_id = aqh.quote_header_id
    AND    shp.quote_header_id = aql.quote_header_id
    AND    shp.quote_line_id = aql.quote_line_id
    AND    oha.source_document_id = aqh.quote_header_id
    AND    ola.header_id = oha.header_id
    AND    ola.source_document_line_Id = shp.shipment_id ;