Monday 6 June 2016

Multiple Billing for Service contract created through Order management

CREATE OR REPLACE PACKAGE BODY "OKS_OMIB_INT_EXTNS_PUB"
AS
/* $Header: OKSPOIXB.pls 120.1 2005/06/28 23:57:02 upillai noship $ */

   /* GLOBAL Variables for the procedures and functions of this package body */
   g_app_name              CONSTANT VARCHAR2 (200) := 'OKS';
   g_unexpected_error      CONSTANT VARCHAR2 (200) := 'OKC_CONTRACTS_UNEXPECTED_ERROR';
   g_sqlcode_token         CONSTANT VARCHAR2 (200) := 'ERROR_CODE';
   g_sqlerrm_token         CONSTANT VARCHAR2 (200) := 'ERROR_MESSAGE';
   g_ret_sts_unexp_error   CONSTANT VARCHAR2 (200) := fnd_api.g_ret_sts_unexp_error;
   g_pkg_name              CONSTANT VARCHAR2 (200) := 'OKS_OMIB_INT_EXTNS_PUB';
   g_module_current        CONSTANT VARCHAR2 (255) := 'oks.plsql.oks_omib_int_extns_pub';

   PROCEDURE pre_integration (
      p_api_version        IN              NUMBER
    , p_init_msg_list      IN              VARCHAR2
    , p_from_integration   IN              VARCHAR2
    , p_transaction_type   IN              VARCHAR2
    , p_transaction_date   IN              DATE
    , p_order_line_id      IN              NUMBER
    , p_old_instance_id    IN              NUMBER
    , p_new_instance_id    IN              NUMBER
    , x_process_status     OUT NOCOPY      VARCHAR2
    , x_return_status      OUT NOCOPY      VARCHAR2
    , x_msg_count          OUT NOCOPY      NUMBER
    , x_msg_data           OUT NOCOPY      VARCHAR2
   )
   IS
      l_api_name   CONSTANT VARCHAR2 (30) := 'pre_integration';
   BEGIN
      IF fnd_log.level_procedure >= fnd_log.g_current_runtime_level
      THEN
         fnd_log.STRING (fnd_log.level_procedure
                       , g_module_current || '.pre_integration.begin'
                       ,    'p_api_version = '
                         || p_api_version
                         || ' ,p_init_msg_list = '
                         || p_init_msg_list
                         || ' ,p_from_integration = '
                         || p_from_integration
                         || ' ,p_transaction_type = '
                         || p_transaction_type
                         || ' ,p_transaction_date = '
                         || p_transaction_date
                         || ' ,p_order_line_id = '
                         || p_order_line_id
                         || ' ,p_old_instance_id = '
                         || p_old_instance_id
                         || ' ,p_new_instance_id = '
                         || p_new_instance_id
                        );
      END IF;

      IF (fnd_api.to_boolean (p_init_msg_list))
      THEN
         fnd_msg_pub.initialize;
      END IF;

      x_process_status := 'C';                                                    -- C - Continue the existing logic on the caller
      x_return_status := fnd_api.g_ret_sts_success;

      IF fnd_log.level_procedure >= fnd_log.g_current_runtime_level
      THEN
         fnd_log.STRING (fnd_log.level_procedure
                       , g_module_current || '.pre_integration.end'
                       , 'x_process_status = ' || x_process_status || ' ,x_return_status = ' || x_return_status
                        );
      END IF;
   EXCEPTION
      WHEN OTHERS
      THEN
         IF fnd_log.level_unexpected >= fnd_log.g_current_runtime_level
         THEN
            fnd_log.STRING (fnd_log.level_unexpected
                          , g_module_current || '.post_integration.UNEXPECTED'
                          , 'sqlcode = ' || SQLCODE || ' ,sqlerrm = ' || SQLERRM
                           );
         END IF;

         x_return_status := okc_api.g_ret_sts_unexp_error;
         okc_api.set_message (p_app_name          => 'OKC'
                            , p_msg_name          => 'OKC_CONTRACTS_UNEXP_ERROR'
                            , p_token1            => g_sqlcode_token
                            , p_token1_value      => SQLCODE
                            , p_token2            => g_sqlerrm_token
                            , p_token2_value      => SQLERRM
                             );
         fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
         x_process_status := 'U';                                                                          -- U - Unexpected Error
   END pre_integration;

   PROCEDURE post_integration (
      p_api_version        IN              NUMBER
    , p_init_msg_list      IN              VARCHAR2
    , p_from_integration   IN              VARCHAR2
    , p_transaction_type   IN              VARCHAR2
    , p_transaction_date   IN              DATE
    , p_order_line_id      IN              NUMBER
    , p_old_instance_id    IN              NUMBER
    , p_new_instance_id    IN              NUMBER
    , p_chr_id             IN              NUMBER
    , p_topline_id         IN              NUMBER
    , p_subline_id         IN              NUMBER
    , x_return_status      OUT NOCOPY      VARCHAR2
    , x_msg_count          OUT NOCOPY      NUMBER
    , x_msg_data           OUT NOCOPY      VARCHAR2
   )
   IS
   BEGIN
      IF fnd_log.level_procedure >= fnd_log.g_current_runtime_level
      THEN
         fnd_log.STRING (fnd_log.level_procedure
                       , g_module_current || '.post_integration.begin'
                       ,    'p_api_version = '
                         || p_api_version
                         || ' ,p_init_msg_list = '
                         || p_init_msg_list
                         || ' ,p_from_integration = '
                         || p_from_integration
                         || ' ,p_transaction_type = '
                         || p_transaction_type
                         || ' ,p_transaction_date = '
                         || p_transaction_type
                         || ' ,p_order_line_id = '
                         || p_order_line_id
                         || ' ,p_old_instance_id = '
                         || p_old_instance_id
                         || ' ,p_new_instance_id = '
                         || p_new_instance_id
                         || ' ,p_chr_id = '
                         || p_chr_id
                         || ' ,p_topline_id = '
                         || p_topline_id
                         || ' ,p_subline_id = '
                         || p_subline_id
                        );
      END IF;

      IF (fnd_api.to_boolean (p_init_msg_list))
      THEN
         fnd_msg_pub.initialize;
      END IF;

      /*---Here starts custom code */
      BEGIN
         INSERT INTO xx_oks_om_tst_tbl
              VALUES (p_from_integration, p_transaction_type, p_transaction_date, p_order_line_id, p_old_instance_id
                    , p_new_instance_id, p_chr_id, p_topline_id, p_subline_id);

         xx_alter_contract_from_om.prepare_contract (p_from_integration      => p_from_integration
                                                   , p_transaction_type      => NULL
                                                   , p_transaction_date      => NULL
                                                   , p_order_line_id         => p_order_line_id
                                                   , p_old_instance_id       => p_old_instance_id
                                                   , p_new_instance_id       => p_new_instance_id
                                                   , p_chr_id                => p_chr_id
                                                   , p_topline_id            => p_topline_id
                                                   , p_subline_id            => p_subline_id
                                                   , x_return_status         => x_return_status
                                                   , x_msg_count             => x_msg_count
                                                   , x_msg_data              => x_msg_data
                                                    );
      EXCEPTION
         WHEN OTHERS
         THEN
            x_return_status := fnd_api.g_ret_sts_success;
      END;

      /*--Here it ends*/
      x_return_status := fnd_api.g_ret_sts_success;

      IF fnd_log.level_procedure >= fnd_log.g_current_runtime_level
      THEN
         fnd_log.STRING (fnd_log.level_procedure
                       , g_module_current || '.post_integration.end'
                       , 'x_return_status = ' || x_return_status
                        );
      END IF;
   EXCEPTION
      WHEN OTHERS
      THEN
         IF fnd_log.level_unexpected >= fnd_log.g_current_runtime_level
         THEN
            fnd_log.STRING (fnd_log.level_unexpected
                          , g_module_current || '.post_integration.UNEXPECTED'
                          , 'sqlcode = ' || SQLCODE || ' ,sqlerrm = ' || SQLERRM
                           );
         END IF;

         x_return_status := okc_api.g_ret_sts_unexp_error;
         okc_api.set_message (p_app_name          => 'OKC'
                            , p_msg_name          => 'OKC_CONTRACTS_UNEXP_ERROR'
                            , p_token1            => g_sqlcode_token
                            , p_token1_value      => SQLCODE
                            , p_token2            => g_sqlerrm_token
                            , p_token2_value      => SQLERRM
                             );
         fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
   END post_integration;
END oks_omib_int_extns_pub;
/

Query to find submitted Concurrent requests

  Query to find Concurrent Requests SELECT      user_concurrent_program_name,      responsibility_name,      request_date,      argument_tex...