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;

Wednesday, August 6, 2014

Receipt Method Query (with maximum details)

How to get Receipt Methods information in Oracle Receivables


select           arma.receipt_method_id,
       arc.name,
       arc.creation_method_code creation_method,
       arm.name                 as receipt_method_name,
       arm.printed_name,
       bv.bank_name,
       bv.bank_branch_name,
       cba.bank_account_name,
       cba.bank_account_num,
       cba.currency_code        currency,
       gcc.segment1             as cash,
       gcc.segment2             as cash,
       gcc.segment3             as cash,
       gcc.segment4             as cash,
       gcc.segment5             as cash,
       gcc.segment6             as cash,
       gcc.segment7             as cash,
       gcc.segment8             as cash,
       gccrc.segment1           as receiptcon,
       gccrc.segment2           as receipt,
       gccrc.segment3           as receipt,
       gccrc.segment4           as receipt,
       gccrc.segment5           as receipt,
       gccrc.segment6           as receipt,
       gccrc.segment7           as receipt,
       gccrc.segment8           as receipt,
       gccrem.segment1          as remittance,
       gccrem.segment2          as remittance,
       gccrem.segment3          as remittance,
       gccrem.segment4          as remittance,
       gccrem.segment5          as remittance,
       gccrem.segment6          as remittance,
       gccrem.segment7          as remittance,
       gccrem.segment8          as remittance,
       gccfactor.segment1       as factoring,
       gccfactor.segment2       as factoring,
       gccfactor.segment3       as factoring,
       gccfactor.segment4       as factoring,
       gccfactor.segment5       as factoring,
       gccfactor.segment6       as factoring,
       gccfactor.segment7       as factoring,
       gccfactor.segment8       as factoring,
       gccdebt.segment1         as stdebt,
       gccdebt.segment2         as stdebt,
       gccdebt.segment3         as stdebt,
       gccdebt.segment4         as stdebt,
       gccdebt.segment5         as stdebt,
       gccdebt.segment6         as stdebt,
       gccdebt.segment7         as stdebt,
       gccdebt.segment8         as stdebt,
       gccbchrg.segment1        as bankcharge,
       gccbchrg.segment2        as bankcharge,
       gccbchrg.segment3        as bankcharge,
       gccbchrg.segment4        as bankcharge,
       gccbchrg.segment5        as bankcharge,
       gccbchrg.segment6        as bankcharge,
       gccbchrg.segment7        as bankcharge,
       gccbchrg.segment8        as bankcharge,
       gccunappl.segment1       as unapplied,
       gccunappl.segment2       as unapplied,
       gccunappl.segment3       as unapplied,
       gccunappl.segment4       as unapplied,
       gccunappl.segment5       as unapplied,
       gccunappl.segment6       as unapplied,
       gccunappl.segment7       as unapplied,
       gccunappl.segment8       as unapplied,
       gccunident.segment1      as unidentified,
       gccunident.segment2      as unidentified,
       gccunident.segment3      as unidentified,
       gccunident.segment4      as unidentified,
       gccunident.segment5      as unidentified,
       gccunident.segment6      as unidentified,
       gccunident.segment7      as unidentified,
       gccunident.segment8      as unidentified,
       gcconact.segment1        as on_account,
       gcconact.segment2        as on_account,
       gcconact.segment3        as on_account,
       gcconact.segment4        as on_account,
       gcconact.segment5        as on_account,
       gcconact.segment6        as on_account,
       gcconact.segment7        as on_account,
       gcconact.segment8        as on_account,
       gccunearn.segment1       as unearned,
       gccunearn.segment2       as unearned,
       gccunearn.segment3       as unearned,
       gccunearn.segment4       as unearned,
       gccunearn.segment5       as unearned,
       gccunearn.segment6       as unearned,
       gccunearn.segment7       as unearned,
       gccunearn.segment8       as unearned,
       gccearn.segment1         as earned,
       gccearn.segment2         as earned,
       gccearn.segment3         as earned,
       gccearn.segment4         as earned,
       gccearn.segment5         as earned,
       gccearn.segment6         as earned,
       gccearn.segment7         as earned,
       gccearn.segment8         as earned
  from ar_receipt_method_accounts_all arma
 inner join ar_receipt_methods arm on arm.receipt_method_id = arma.receipt_method_id
 inner join ar_receipt_classes arc on arc.receipt_class_id = arm.receipt_class_id
 inner join ce_bank_acct_uses_all cbau on cbau.bank_acct_use_id = arma.remit_bank_acct_use_id
 inner join ce_bank_accounts cba on cba.bank_account_id = cbau.bank_account_id
 inner join ce_bank_branches_v bv  on bv.branch_party_id = cba.bank_branch_id
 left outer join gl_code_combinations gcc on gcc.code_combination_id = arma.cash_ccid
 left outer join gl_code_combinations gccrc on gccrc.code_combination_id = arma.receipt_clearing_ccid
left outer join gl_code_combinations gccrem  on gccrem.code_combination_id = arma.remittance_ccid
left outer join gl_code_combinations gccfactor on gccfactor.code_combination_id = arma.factor_ccid
left outer join gl_code_combinations gccdebt on gccdebt.code_combination_id = arma.short_term_debt_ccid
left outer join gl_code_combinations gccbchrg on gccbchrg.code_combination_id = arma.bank_charges_ccid
left outer join gl_code_combinations gccunappl on gccunappl.code_combination_id = arma.unapplied_ccid
left outer join gl_code_combinations gccunident on gccunident.code_combination_id = arma.unidentified_ccid
left outer join gl_code_combinations gcconact on gcconact.code_combination_id = arma.on_account_ccid
left outer join gl_code_combinations gccunearn on gccunearn.code_combination_id = arma.unearned_ccid
left outer join gl_code_combinations gccearn on gccearn.code_combination_id = arma.earned_ccid
 where arma.end_date is null
--and arc.receipt_class_id = 1000
--and printed_name like '%34%'
-- arma.receipt_method_id = 3030