Wednesday, January 22, 2014

Script to Calculate the Price details of the Product Line in the Service Contract (oks_qp_pkg.calc_price)

DECLARE
   l_input_details                                   oks_qp_pkg.input_details;
   l_output_details                                  oks_qp_pkg.price_details;
   l_modif_details                                   qp_preq_grp.line_detail_tbl_type;
   l_pb_details                                      oks_qp_pkg.g_price_break_tbl_type;
   l_return_status                                   VARCHAR2(20);
   l_msg_count                                       NUMBER;
   l_msg_data                                        VARCHAR2(2000);
   l_status_tbl                                      oks_qp_int_pvt.pricing_status_tbl;
   l_final_status_tbl                                oks_qp_int_pvt.pricing_status_tbl;
   l_count                                           NUMBER;
   l_msg_index_out                                   NUMBER;
   l_num                                             NUMBER;
   l_error_message                                   VARCHAR2(2000);
BEGIN
   l_num                                          := 10;
   l_input_details.intent                         := 'SP';  --> Subline
   l_input_details.chr_id                         := 1549063; -->Contract Id
   l_input_details.currency                       := 'USD';
   l_input_details.line_id                        := 364326736554344799961890872824534166768;--> Service Line id
   l_input_details.subline_id                     := 364326736554364142775004706891329465584;   --> Product Line id
   l_num                                          := 20;
   oks_qp_pkg.calc_price(p_detail_rec                  => l_input_details
                       , x_price_details               => l_output_details
                       , x_modifier_details            => l_modif_details
                       , x_price_break_details         => l_pb_details
                       , x_return_status               => l_return_status
                       , x_msg_count                   => l_msg_count
                       , x_msg_data                    => l_msg_data
                        );
   l_num                                          := 30;

   IF l_return_status <> fnd_api.g_ret_sts_success
   THEN
      l_num                                          := 40;

      IF l_msg_count > 0
      THEN
         FOR i IN 1 .. l_msg_count
         LOOP
            l_num                                          := 50;
            apps.fnd_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);

            IF l_error_message IS NULL
            THEN
               l_error_message                                := SUBSTR(l_msg_data, 1, 250);
            ELSE
               l_error_message                                := l_error_message || ' /' || SUBSTR(l_msg_data, 1, 250);
            END IF;
         END LOOP;

         DBMS_OUTPUT.put_line('*****************************************');
         DBMS_OUTPUT.put_line('API Error : ' || l_error_message);
         DBMS_OUTPUT.put_line('*****************************************');
      ELSE
         apps.fnd_msg_pub.get(p_msg_index                   => 1, p_encoded => fnd_api.g_false, p_data => l_msg_data
                            , p_msg_index_out               => l_msg_index_out);
         DBMS_OUTPUT.put_line('*****************************************');
         DBMS_OUTPUT.put_line('API Error : ' || l_msg_data);
         DBMS_OUTPUT.put_line('*****************************************');
      END IF;
   ELSE
      l_num                                          := 60;
      DBMS_OUTPUT.put_line('API Success');
      DBMS_OUTPUT.put_line('******************************************************************************************************');
      DBMS_OUTPUT.put_line('Product Quantity : ' || l_output_details.prod_qty);
      DBMS_OUTPUT.put_line('Product Quantity UOM : ' || l_output_details.prod_qty_uom);
      DBMS_OUTPUT.put_line('Service Quantity : ' || l_output_details.serv_qty);
      DBMS_OUTPUT.put_line('Service Quantity UOM : ' || l_output_details.serv_qty_uom);
      DBMS_OUTPUT.put_line('Product Price List Id : ' || l_output_details.prod_price_list_id);
      DBMS_OUTPUT.put_line('Service Price List Id : ' || l_output_details.serv_price_list_id);
      DBMS_OUTPUT.put_line('Product Price List Line Id : ' || l_output_details.prod_price_list_line_id);
      DBMS_OUTPUT.put_line('Service Price List Line Id : ' || l_output_details.serv_price_list_line_id);
      DBMS_OUTPUT.put_line('Product List Unit Price : ' || l_output_details.prod_list_unit_price);
      DBMS_OUTPUT.put_line('Service List Unit Price : ' || l_output_details.serv_list_unit_price);
      DBMS_OUTPUT.put_line('Product Adjustment Unit Price : ' || l_output_details.prod_adj_unit_price);
      DBMS_OUTPUT.put_line('Service Adjustment Unit Price : ' || l_output_details.serv_adj_unit_price);
      DBMS_OUTPUT.put_line('Product Priced Quantity : ' || l_output_details.prod_priced_qty);
      DBMS_OUTPUT.put_line('Product Priced UOM : ' || l_output_details.prod_priced_uom);
      DBMS_OUTPUT.put_line('Product Extension Amount : ' || l_output_details.prod_ext_amount);
      DBMS_OUTPUT.put_line('Service Priced Quantity : ' || l_output_details.serv_priced_qty);
      DBMS_OUTPUT.put_line('Service Priced UOM : ' || l_output_details.serv_priced_uom);
      DBMS_OUTPUT.put_line('Service Extended Amount : ' || l_output_details.serv_ext_amount);
      DBMS_OUTPUT.put_line('Service OPerand : ' || l_output_details.serv_operand);
      DBMS_OUTPUT.put_line('Service Operator : ' || l_output_details.serv_operator);
      DBMS_OUTPUT.put_line('Status Code : ' || l_output_details.status_code);
      DBMS_OUTPUT.put_line('Status Text : ' || l_output_details.status_text);
      DBMS_OUTPUT.put_line('******************************************************************************************************');
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line(l_num || ' Unexpected Error : ' || SUBSTR(SQLERRM, 1, 250));
END;

Output For the Above Script
============================

API Success
******************************************************************************************************
Product Quantity : 1
Product Quantity UOM : Ea
Service Quantity : 1
Service Quantity UOM : QTR
Product Price List Id : 6007
Service Price List Id : 6007
Product Price List Line Id : 153122
Service Price List Line Id : 153138
Product List Unit Price : 0
Service List Unit Price : 6300
Product Adjustment Unit Price : 0
Service Adjustment Unit Price : 5500.53
Product Priced Quantity : 1
Product Priced UOM : Ea
Product Extension Amount : 0
Service Priced Quantity : .4931506849
Service Priced UOM : YR
Service Extended Amount : 2712.590136812997
Service OPerand : 6300
Service Operator : UNIT_PRICE
Status Code : OKS_S
Status Text :
******************************************************************************************************

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.