Wednesday, 15 January 2014

Query To Find Coverage Details in Oracle Service Contracts

/* Formatted on 2014/01/15 18:47 (Formatter Plus v4.8.8) */
SELECT DECODE (coverage1, NULL, 'No Coverage', coverage1) service_coverage,
       DECODE (warranty1, NULL, 'No', warranty1) warranty
  FROM (SELECT MAX (DECODE (cov.NAME,
                            'Servicepass Complete', DECODE (cle.sts_code,
                                                            'ACTIVE', cov.NAME,
                                                            NULL
                                                           ),
                            'Servicepass Standard', DECODE (cle.sts_code,
                                                            'ACTIVE', cov.NAME,
                                                            NULL
                                                           ),
                            'Qualitypass', DECODE (cle.sts_code,
                                                   'ACTIVE', cov.NAME,
                                                   NULL
                                                  ),
                            NULL
                           )
                   ) coverage1,
               MAX (DECODE (cov.NAME,
                            'WARRANTY', DECODE (cle.sts_code,
                                                'ACTIVE', 'Yes',
                                                'No'
                                               ),
                            NULL
                           )
                   ) warranty1
          FROM okc_k_lines_b cle,
               oks_k_lines_b kln,
               okc_k_lines_tl cov,
               okc_line_styles_tl lse,
               okc_statuses_tl sts,
               okc_k_items cit,
               oks_auth_lines_v x
         WHERE cle.cle_id IS NULL
           AND kln.cle_id = cle.ID
           AND lse.ID = cle.lse_id
           AND lse.LANGUAGE = USERENV ('LANG')
           AND cit.cle_id = cle.ID
           AND cit.jtot_object1_code IN
                  ('OKX_SERVICE', 'OKX_WARRANTY', 'OKX_USAGE',
                   'OKS_SUBSCRIPTION')
           AND sts.code = cle.sts_code
--AND sts.meaning NOT IN ('Terminated')
           AND sts.LANGUAGE = USERENV ('LANG')
           AND cov.ID(+) = kln.coverage_id
           AND cov.LANGUAGE(+) = USERENV ('LANG')
           AND x.cle_id = cle.ID
           AND (x.ID IN (
                   SELECT cle_id
                     FROM okc_k_items
                    WHERE dnz_chr_id = cit.dnz_chr_id
                      AND object1_id1 IN (
                             SELECT instance_id
                               FROM csi_item_instances
                              WHERE 1 = 1
                                AND serial_number = NVL (:1, serial_number)))
               ))

Thursday, 9 January 2014

Query to Find Responsibility Attached to Request

SELECT UNIQUE frt.responsibility_name, frg.request_group_name,
              fcpt.user_concurrent_program_name
         FROM fnd_responsibility fr,
              fnd_responsibility_tl frt,
              fnd_request_groups frg,
              fnd_request_group_units frgu,
              fnd_concurrent_programs_tl fcpt
        WHERE fr.responsibility_id = frt.responsibility_id
          AND fr.request_group_id = frg.request_group_id
          AND frgu.request_group_id = frg.request_group_id
          AND frgu.request_unit_id = fcpt.concurrent_program_id
          AND fcpt.LANGUAGE = 'US'
          AND frt.LANGUAGE = 'US'
          AND fcpt.user_concurrent_program_name LIKE
                                                '' 

Friday, 3 January 2014

Query to Find Renewed Contracts

Query To Find the Contracts that have been Renewed

/* Formatted on 2014/01/03 14:58 (Formatter Plus v4.8.8) */
SELECT   a.contract_number, a.contract_number_modifier, a.date_renewed,
         a.start_date, a.end_date, a.sts_code,
         DECODE (a.renewal_type_code,
                 'DNR', 'DO NOT RENEW',
                 'NSR', 'MANNUAL'
                ) "RENEWAL TYPE"
    FROM okc_k_headers_all_b a
   WHERE sts_code = 'ACTIVE' AND a.end_date = TRUNC (SYSDATE) + 119
      OR a.start_date = TRUNC (SYSDATE) + 120
ORDER BY contract_number ASC

Wednesday, 1 January 2014

Query To Find Scheduled Concurrent Request

/*##############################################################################
#        SCHEDULED REQUESTS-
/*############################################################################*/
SELECT r.request_id
     , CASE
          WHEN pt.user_concurrent_program_name = 'Report Set'
             THEN DECODE(
                    r.description
                  , NULL, pt.user_concurrent_program_name
                  ,    r.description
                    || ' ('
                    || pt.user_concurrent_program_name
                    || ')'
                 )
          ELSE pt.user_concurrent_program_name
       END job_name
     , u.user_name requestor
     , u.description requested_by
     , u.email_address
     , frt.responsibility_name requested_by_resp
     , r.request_date
     , r.requested_start_date
     , DECODE(
          r.hold_flag
        , 'Y', 'Yes'
        , 'N', 'No'
       ) on_hold
     , CASE
          WHEN r.hold_flag = 'Y'
             THEN SUBSTR(
                    u2.description
                  , 0
                  , 40
                 )
       END last_update_by
     , CASE
          WHEN r.hold_flag = 'Y'
             THEN r.last_update_date
       END last_update_date
     , r.printer
     , r.number_of_copies print_count
     , r.argument_text PARAMETERS
     , NVL2(
          r.resubmit_interval
        , 'Periodically'
        , NVL2(
             r.release_class_id
           , 'On specific days'
           , 'Once'
          )
       ) AS schedule_type
     , r.resubmit_interval resubmit_every
     , r.resubmit_interval_unit_code resubmit_time_period
     , DECODE(
          r.resubmit_interval_type_code
        , 'START', 'From the start of the prior run'
        , 'END', 'From the Completion of the prior run'
       ) apply_the_update_option
     , r.increment_dates
     , TO_CHAR((r.requested_start_date), 'HH24:MI:SS') start_time
  FROM applsys.fnd_concurrent_programs_tl pt
     , applsys.fnd_concurrent_programs pb
     , applsys.fnd_user u
     , applsys.fnd_user u2
     , applsys.fnd_printer_styles_tl s
     , applsys.fnd_concurrent_requests r
     , applsys.fnd_responsibility_tl frt
 WHERE pb.application_id = r.program_application_id
   AND pb.concurrent_program_id = r.concurrent_program_id
   AND pb.application_id = pt.application_id
   AND r.responsibility_id = frt.responsibility_id
   AND pb.concurrent_program_id = pt.concurrent_program_id
   AND u.user_id = r.requested_by
   AND u2.user_id = r.last_updated_by
   AND s.printer_style_name(+) = r.print_style
   AND r.phase_code = 'P'
   AND 1 = 1;

Wednesday, 11 December 2013

Service Contracts Multiple Billing Through Order Management

The Below code Describes The multiple Billing Schedule for contract that is created through Order Management.

Issue : When we create service Contract from Order management we cant use the Multiple billing schedule option of Service Contracts Module.

Solution :

Refrences :http://www.oraclebusinessapps.com/2008/07/26/r12-service-contract-from-order-management-part-iii/

1. Create a temp Table
------------------------------------------------------------------------------------------------------------
/*<Temprory Table to Store Order Details  Service LIne >*/
CREATE TABLE XX_OKS_OM_TST_TBL
(
  FROM_INTEGRATION  VARCHAR2(300 BYTE),
  TRANSACTION_TYPE  VARCHAR2(100 BYTE),
  TRANSACTION_DATE  DATE,
  ORDER_LINE_ID     NUMBER,
  OLD_INSTANCE_ID   NUMBER,
  NEW_INSTANCE_ID   NUMBER,
  CHR_ID            NUMBER,
  TOPLINE_ID        NUMBER,
  SUBLINE_ID        NUMBER
);
/
------------------------------------------------------------------------------------------------------------

2.
CREATE OR REPLACE PACKAGE APPS.xx_alter_contract_from_om
IS
   PROCEDURE prepare_contract (
      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
   );
END xx_alter_contract_from_om;
/
------------------------------------------------------------------------------------------------------------

CREATE OR REPLACE PACKAGE BODY APPS.xx_alter_contract_from_om
IS
   PROCEDURE prepare_contract (
      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
      l_bclv_rec_type      oks_billcontline_pub.bclv_rec_type;
      l_bslv_rec_type      oks_billsubline_pub.bslv_rec_type;
      x_bill_cont_status   VARCHAR2 (1);
      x_sub_line_status    VARCHAR2 (1);
      x_rgp_id             NUMBER;
      x_status             VARCHAR2 (1);
      l_top_months         NUMBER;
      l_sub_months         NUMBER;
      l_order_uom          VARCHAR2 (10);
   BEGIN
      okc_context.set_okc_org_context (p_chr_id => p_chr_id);
      fnd_global.apps_initialize (1005902, 21708, 515);

/*==========================================================================
|select order UOM. This logic is to create billing schedules with UOM month.|
|So create an order for the service item with MTH has UOM or create item    |
|with UOM of MTH so that it defaults into order line. This UOM will used in |
|updating the stream headers later                                          |
+==========================================================================*/
      BEGIN
         SELECT order_quantity_uom
           INTO l_order_uom
           FROM oe_order_lines
          WHERE line_id = p_order_line_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            NULL;
      END;

/*==========================================================================
|Since our intention is to create multiple schedules compared to what OKS   |
|Contract Order Capture Program creates, we need to select number of months |
|between start date and End Date. This logic gets harder if you do not      |
|populate the same. It is not required to be populated because the start    |
|date can be calculated based on warranty start date or fulfillment date    |
+==========================================================================*/
      BEGIN
         SELECT CEIL (MONTHS_BETWEEN (end_date, start_date))
           INTO l_top_months
           FROM okc_k_lines_b
          WHERE ID = p_topline_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            NULL;
      END;

      BEGIN
         SELECT CEIL (MONTHS_BETWEEN (end_date, start_date))
           INTO l_sub_months
           FROM okc_k_lines_b
          WHERE ID = p_subline_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            NULL;
      END;

      BEGIN
         SELECT ID
           INTO l_bslv_rec_type.ID
           FROM oks_bill_sub_lines
          WHERE cle_id = p_subline_id;

/*==========================================================================
|Now delete the billing tables. This table is populated to avoid billing for|
|these contracts. This needs to be deleted.Subline here.                    |
+==========================================================================*/
         oks_billsubline_pub.delete_bill_subline_pub (p_api_version        => 1.0
                                                    , p_init_msg_list      => okc_api.g_false
                                                    , x_return_status      => x_sub_line_status
                                                    , x_msg_count          => x_msg_count
                                                    , x_msg_data           => x_msg_data
                                                    , p_bslv_rec           => l_bslv_rec_type
                                                     );
         x_return_status := x_sub_line_status;
         DBMS_OUTPUT.put_line ('Return Status of deleting subline billing record :' || x_sub_line_status);
         DBMS_OUTPUT.put_line ('msg count of deleting sub line billing record:' || x_msg_count);

         IF x_sub_line_status = 'S'
         THEN
/*==========================================================================
|Delete existing billing schedules as we have to recreate them. Blind delete|
|is OK as this schedule comes with completed date and never got billed before|
+==========================================================================*/
            DELETE      oks_level_elements
                  WHERE cle_id = p_subline_id;

/*============================================================================
|Update the number of level periods to the number of periods in months so that|
|billing can happen monthly.Update UOM too!!                                  |
+==========================================================================*/
            UPDATE oks_stream_levels_b
               SET level_periods = l_sub_months
                 , uom_code = l_order_uom
                 , uom_per_period=1
             WHERE cle_id = p_subline_id;

            x_status := 'S';
            --oks_bill_util_pub.refresh_bill_sch (p_cle_id => i.ID, x_rgp_id => x_rgp_id, x_status => x_status);
            DBMS_OUTPUT.put_line ('Return Status of refreshing bill schedules is:' || x_status);
            x_msg_data := NULL;
            x_msg_count := NULL;
            x_return_status := NULL;
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            NULL;
      END;

      BEGIN
         SELECT ID
           INTO l_bclv_rec_type.ID
           FROM oks_bill_cont_lines
          WHERE cle_id = p_topline_id;

/*==========================================================================
|Now delete the billing tables. This table is populated to avoid billing for|
|these contracts. This needs to be deleted.Top Linehere.                    |
+==========================================================================*/
         oks_billcontline_pub.delete_bill_cont_line (p_api_version        => 1.0
                                                   , p_init_msg_list      => okc_api.g_false
                                                   , x_return_status      => x_bill_cont_status
                                                   , x_msg_count          => x_msg_count
                                                   , x_msg_data           => x_msg_data
                                                   , p_bclv_rec           => l_bclv_rec_type
                                                    );
         x_return_status := x_bill_cont_status;
         DBMS_OUTPUT.put_line ('Return Status of deleting contractline billing record:' || x_bill_cont_status);
         DBMS_OUTPUT.put_line ('msg count of deleting contractline billing record:' || x_msg_count);

         IF x_bill_cont_status = 'S'
         THEN
/*==========================================================================
|Delete existing billing schedules as we have to recreate them. Blind delete|
|is OK as this schedule comes with completed date and never got billed before|
+==========================================================================*/
            DELETE      oks_level_elements
                  WHERE cle_id = p_topline_id;

/*============================================================================
|Update the number of level periods to the number of periods in months so that|
|billing can happen monthly.Update UOM too!!                                  |
+==========================================================================*/
            UPDATE oks_stream_levels_b
               SET level_periods = l_top_months
                 , uom_code = l_order_uom
                 , uom_per_period=1
             WHERE cle_id = p_topline_id;

            x_status := 'S';
            DBMS_OUTPUT.put_line ('Return Status of refreshing bill schedules is:' || x_status);
            x_msg_data := NULL;
            x_msg_count := NULL;
            x_return_status := NULL;
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            NULL;
      END;

      IF (x_bill_cont_status <> 'S' OR x_sub_line_status <> 'S' OR x_status <> 'S')
      THEN
         ROLLBACK;
      END IF;

/*============================================================================
|Now create new billing schedules                                            |
+==========================================================================*/
      oks_bill_sch.create_bill_sch_cp (p_top_line_id        => p_topline_id
                                     , p_cp_line_id         => p_subline_id
                                     , p_cp_new             => 'Y'
                                     , x_return_status      => x_return_status
                                     , x_msg_count          => x_msg_count
                                     , x_msg_data           => x_msg_data
                                      );
      DBMS_OUTPUT.put_line ('Return Status of refreshing bill schedules is:' || x_return_status);
      DBMS_OUTPUT.put_line ('msg count of refreshing bill sch:' || x_msg_count);

/*=================================================================================
|Finally update the related objects table so that this contract line can be billed!|
+==================================================================================*/
      UPDATE okc_k_rel_objs
         SET cle_id = -1
       WHERE cle_id = p_subline_id;
   END;
END xx_alter_contract_from_om;
/
------------------------------------------------------------------------------------------------------------

Friday, 6 December 2013

How to get OAF Page Trace File

1.Click the 'Diagnostics' link in top right of screen

2. From the Diagnostic drop down select 'Set Trace Level' and click 'Go'

3.There will be Six Options In the LOV

4. Select The appropriate option

5. Note down the Trace ID Numbers returned and click 'Save'

6 . Perform The Search/Operation.

7. Select "Disable Trace " after Operation.

8. The trace files should be output to the directory returned by the following query

SELECT value
FROM v$parameter
WHERE name = 'user_dump_dest';

Wednesday, 4 December 2013

Find Workflow Email Notification Disabled for whihh User

select * from wf_roles where notification_preference in ('DISABLED','QUERY')
and orig_system='PER'

Query to find submitted Concurrent requests

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