Search This Blog

Tuesday, September 23, 2014

How to get Active Users

select fu.user_name, papf.employee_number, papf.full_name, haou.name
  from FND_USER                  fu,
       PER_ALL_PEOPLE_F          papf,
       per_all_assignments_f     paaf,
       HR_ALL_ORGANIZATION_UNITS haou
 where 1 = 1
   and fu.employee_id = papf.person_id
   and sysdate between papf.effective_start_date and  papf.effective_end_date
   and paaf.person_id = papf.person_id and sysdate between paaf.effective_start_date and  paaf.effective_end_date
   and haou.organization_id = paaf.organization_id
   order by 4,1

How to get Work Flow action history

SELECT TO_CHAR(ias.begin_date, 'DD-MON-RR HH24:MI:SS') begin_date,
       TO_CHAR(ias.end_date, 'DD-MON-RR HH24:MI:SS') end_date,
       ap.display_name || '/' || pa.instance_label Activity,
       ias.activity_status Status,
       ias.activity_result_code Result,
       ias.assigned_user assigned_user,
       ias.notification_id NID,
       ntf.status "Status",
       ias.action,
       ias.performed_by,
       ias.due_date,
       ias.ERROR_NAME,
       ias.ERROR_MESSAGE
  FROM apps.wf_item_activity_statuses ias,
       apps.wf_process_activities     pa,
       apps.wf_activities             ac,
       apps.wf_activities_vl          ap,
       apps.wf_items                  i,
       apps.wf_notifications          ntf
 WHERE ias.item_type = 'POAPPRV' --  Enter WF Item Type
   AND ias.item_key = '21215' --  Enter WF Item Key
   AND ias.process_activity = pa.instance_id
   AND pa.activity_name = ac.name
   AND pa.activity_item_type = ac.item_type
   AND pa.process_name = ap.name
   AND pa.process_item_type = ap.item_type
   AND pa.process_version = ap.version
   AND i.item_type = ias.item_type
   AND i.item_key = ias.item_key
   AND i.begin_date >= ac.begin_date
   AND i.begin_date < NVL(ac.end_date, i.begin_date + 1)
   AND ntf.notification_id(+) = ias.notification_id
 ORDER BY ias.begin_date, ias.execution_time;

How to find scheduled Concurrent programs

SELECT fcr.request_id,
       fcpt.user_concurrent_program_name ||
       NVL2(fcr.description, ' (' || fcr.description || ')', NULL) conc_prog,
       fu.user_name requestor,
       fu.description requested_by,
       fu.email_address,
       frt.responsibility_name requested_by_resp,
       trim(fl.meaning) status,
       fcr.phase_code,
       fcr.status_code,
       fcr.argument_text "PARAMETERS",
       TO_CHAR(fcr.request_date, 'DD-MON-YYYY HH24:MI:SS') requested,
       TO_CHAR(fcr.requested_start_date, 'DD-MON-YYYY HH24:MI:SS') requested_start,
       TO_CHAR((fcr.requested_start_date), 'HH24:MI:SS') start_time,
       DECODE(fcr.hold_flag, 'Y', 'Yes', 'N', 'No') on_hold,
       CASE
         WHEN fcr.hold_flag = 'Y' Then
          Substr(fu.description, 0, 40)
       END last_update_by,
       CASE
         WHEN fcr.hold_flag = 'Y' THEN
          fcr.last_update_date
       END last_update_date,
       fcr.increment_dates,
       CASE
         WHEN fcrc.CLASS_INFO IS NULL THEN
          'Yes: ' ||
          TO_CHAR(fcr.requested_start_date, 'DD-MON-YYYY HH24:MI:SS')
         ELSE
          'n/a'
       END run_once,
       CASE
         WHEN fcrc.class_type = 'P' THEN
          'Repeat every ' ||
          substr(fcrc.class_info, 1, instr(fcrc.class_info, ':') - 1) ||
          decode(substr(fcrc.class_info,
                        instr(fcrc.class_info, ':', 1, 1) + 1,
                        1),
                 'N',
                 ' minutes',
                 'M',
                 ' months',
                 'H',
                 ' hours',
                 'D',
                 ' days') ||
          decode(substr(fcrc.class_info,
                        instr(fcrc.class_info, ':', 1, 2) + 1,
                        1),
                 'S',
                 ' from the start of the prior run',
                 'C',
                 ' from the completion of the prior run')
         ELSE
          'n/a'
       END set_days_of_week,
       CASE
         WHEN fcrc.class_type = 'S' AND
              instr(substr(fcrc.class_info, 33), '1', 1) > 0 THEN
          'Days of week: ' ||
          decode(substr(fcrc.class_info, 33, 1), '1', 'Sun, ') ||
          decode(substr(fcrc.class_info, 34, 1), '1', 'Mon, ') ||
          decode(substr(fcrc.class_info, 35, 1), '1', 'Tue, ') ||
          decode(substr(fcrc.class_info, 36, 1), '1', 'Wed, ') ||
          decode(substr(fcrc.class_info, 37, 1), '1', 'Thu, ') ||
          decode(substr(fcrc.class_info, 38, 1), '1', 'Fri, ') ||
          decode(substr(fcrc.class_info, 39, 1), '1', 'Sat ')
         ELSE
          'n/a'
       end days_of_week
  FROM fnd_concurrent_requests    fcr,
       fnd_user                   fu,
       fnd_concurrent_programs    fcp,
       fnd_concurrent_programs_tl fcpt,
       fnd_printer_styles_tl      fpst,
       fnd_conc_release_classes   fcrc,
       fnd_responsibility_tl      frt,
       fnd_lookups                fl
 WHERE fcp.application_id = fcpt.application_id
   AND fcr.requested_by = fu.user_id
   AND fcr.concurrent_program_id = fcp.concurrent_program_id
   AND fcr.program_application_id = fcp.application_id
   AND fcr.concurrent_program_id = fcpt.concurrent_program_id
   AND fcr.responsibility_id = frt.responsibility_id
   AND fcr.print_style = fpst.printer_style_name(+)
   AND fcr.release_class_id = fcrc.release_class_id(+)
   AND fcr.status_code = fl.lookup_code
   AND fl.lookup_type = 'CP_STATUS_CODE'
   AND fcr.phase_code = 'P'
   AND 1 = 1
 Order By Fu.Description, Fcr.Requested_Start_Date Asc;