Friday 30 November 2012

Concurrent Request All

Concurrent jobs Details

===============================
Find Specific Completed Request
===============================
set lines 200 pages 200
column start_time format a16
column "REQUESTED BY" for a35
column "Status" for a15
column "Phase" for a15
column USER_CONCURRENT_PROGRAM_NAME format a40
spool notification2.log;
select  c.USER_NAME||'('||b.REQUESTED_BY||')' as "REQUESTED BY",
    b.REQUEST_ID, a.USER_CONCURRENT_PROGRAM_NAME
    --, b.phase_code as "Phase",b.status_code "Status",
    ,d.MEANING "Phase"
    ,e.MEANING "Status", -- nvl(meaning, 'UNKNOWN') status,
        (sysdate - b.actual_start_date) * 24 "Running Hrs",
        to_char(b.request_date, 'mm/dd/yyyy hh24:mi') "request_date",
        to_char(b.actual_start_date, 'mm/dd/yyyy hh24:mi') "start_time"
from    APPS.FND_CONCURRENT_PROGRAMS_VL a,
        APPS.FND_CONCURRENT_REQUESTS b,
        APPS.FND_USER c,
        APPS.fnd_lookups d,
    APPS.fnd_lookups e
where   a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
and     a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
and    b.REQUESTED_BY= c.USER_ID
and    d.LOOKUP_TYPE = 'CP_PHASE_CODE'  and d.LOOKUP_CODE = b.phase_code
and    e.LOOKUP_TYPE = 'CP_STATUS_CODE' and e.LOOKUP_CODE = b.status_code
and     a.USER_CONCURRENT_PROGRAM_NAME like 'VW%HR%AD%'
and     b.actual_start_date between sysdate-10 and sysdate
order by b.actual_start_date;



========================
List of Running Requests
========================

set lines 200
set pages 200
col os form A7 head AppProc
col spid form a6 head SPID
col program form A50 trunc
set pages 200
col time form 99999.99 head Elapsed
col "Req Id" form 99999999
col "Parent" form a8
col "Prg Id" form 9999999
col serial# form 999999 head Serial#
col qname head "Manager" format a10 trunc
col sid format 9999 head SID
col user_name form A12 head User trunc
set recsep off

select     q.concurrent_queue_name qname
    ,f.user_name
    ,a.request_id "Req Id"
    ,decode(a.parent_request_id,-1,NULL,a.parent_request_id) "Parent"
    ,a.concurrent_program_id "Prg Id"
    ,a.phase_code,a.status_code
    ,b.os_process_id "OS"
    ,vs.sid
    ,vs.serial# "Serial#"
    ,vp.spid
    ,a.oracle_process_id "spid"
    ,(nvl(a.actual_completion_date,sysdate)-a.actual_start_date)*1440 "Time"
    ,c.concurrent_program_name||' - '||
    c2.user_concurrent_program_name||' '||a.description "Program"
from     APPLSYS.fnd_Concurrent_requests a
    ,APPLSYS.fnd_concurrent_processes b
    ,applsys.fnd_concurrent_queues q
    ,APPLSYS.fnd_concurrent_programs_tl c2
    ,APPLSYS.fnd_concurrent_programs c
    ,APPLSYS.fnd_user f
    ,v$session vs
    ,v$process vp
where a.controlling_manager = b.concurrent_process_id
and a.concurrent_program_id = c.concurrent_program_id
and a.program_application_id = c.application_id
and c2.concurrent_program_id = c.concurrent_program_id
and c2.application_id = c.application_id
and a.phase_code in ('I','P','R','T')
and a.requested_by = f.user_id
and b.queue_application_id = q.application_id
and b.concurrent_queue_id = q.concurrent_queue_id
and c2.language = 'US'
and vs.process (+) = b.os_process_id
and vs.paddr = vp.addr (+)
and vp.spid in (11234)                -- Provide DB Node OS PID
order by 9 desc;


=====================
Long Running Requests (over 4 hours)
=====================

set lines 200 pages 200
column start_time format a16
column USER_CONCURRENT_PROGRAM_NAME format a40

select     b.REQUEST_ID, a.USER_CONCURRENT_PROGRAM_NAME, b.phase_code,
    (sysdate - b.actual_start_date) * 24 "Running Hrs",
    to_char(b.request_date, 'mm/dd/yyyy hh24:mi') "request_date",
    to_char(b.actual_start_date, 'mm/dd/yyyy hh24:mi') "start_time"
from    APPS.FND_CONCURRENT_PROGRAMS_VL a,
    APPS.FND_CONCURRENT_REQUESTS b
where     a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
and     a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
and     b.STATUS_CODE = 'R'
and     b.PHASE_CODE = 'R'
and     ((sysdate - b.actual_start_date) * 24) > 4
and     a.CONCURRENT_PROGRAM_ID NOT IN(36887,43393,38121,42789,31556);



Find The SQL Behind Concurrent Request
--------------------------------------
set lines 200 pages 200
column USERNAME for a14
column OSUSER for a12
column MACHINE for a18
column SID|SERIAL for a12
column SPID|PID for a12
column COMMAND for a14
column SQL_TEXT for a80
SELECT s.username, s.osuser, s.machine, s.sid||'|'||s.serial# "SID|SERIAL", p.spid||'|'||p.pid "SPID|PID",
ct.NAME COMMAND,q.SQL_TEXT
FROM v$session s, v$process p, v$sql q, audit_actions ct
WHERE s.paddr = p.addr
AND q.SQL_ID = s.SQL_ID
AND q.COMMAND_TYPE = ct.ACTION
AND p.background is null
AND s.username IS NOT NULL
AND p.spid=&os_pid;


=========================================
List of pending Jobs waiting for managers:
=========================================

set lines 130
col USER_CONCURRENT_QUEUE_NAME format a39

SELECT b.USER_CONCURRENT_QUEUE_NAME , count(*)
FROM apps.FND_CONCURRENT_WORKER_REQUESTS a,apps.FND_CONCURRENT_QUEUES_VL b
WHERE     (Phase_Code = 'P' )
AND     a.hold_flag != 'Y'
AND     a.Requested_Start_Date <= SYSDATE
AND     ('' IS NULL OR ('' = 'B' AND PHASE_CODE = 'R' AND STATUS_CODE IN ('I')))
AND     a.CONCURRENT_QUEUE_ID!=1003
AND     a.CONCURRENT_QUEUE_ID=b.CONCURRENT_QUEUE_ID  
GROUP BY b.USER_CONCURRENT_QUEUE_NAME ,status_code;

AND

set lines 200 pages 200
col program_description format a80
col user_concurrent_queue_name format a40

SELECT     count(b.request_id) count, b.program_description, a.user_concurrent_queue_name
FROM     apps.FND_CONCURRENT_QUEUES_VL a, apps.FND_CONCURRENT_WORKER_REQUESTS b
WHERE    a.enabled_flag='Y'
AND      a.concurrent_queue_id = b.concurrent_queue_id
AND      (b.Phase_Code = 'P' OR b.Phase_Code = 'R') AND b.hold_flag != 'Y'
AND      b.Requested_Start_Date <= SYSDATE
AND      1=1
--AND a.user_concurrent_queue_name like 'Inventory%'
group by a.user_concurrent_queue_name, b.program_description order by 3,1 asc;





========================
Total scheduled requests
========================

To find all of the scheduled requests, run the SQL statement below: Doc ID 170107.1

select request_id from apps.fnd_concurrent_requests
where status_code in ('Q','I')                -- 'I' indicates a status of Normal
and requested_start_date > SYSDATE
and hold_flag = 'N';


set lines 200 pages 200
select 'Scheduled requests:' schedt, count(*) schedcnt
from APPS.fnd_concurrent_requests
WHERE (requested_start_date > sysdate -- OR -status_code = 'P'
)
AND phase_code = 'P';


set lines 200 pages 200
column program_name for a80
column status for a20
SELECT request_id id,
nvl(meaning, 'UNKNOWN') status,
user_concurrent_program_name program_name,
to_char(request_date, 'DD-MON-RR HH24:MI:SS') submitd,
to_char(requested_start_date, 'DD-MON-RR HH24:MI:SS') requestd
FROM     APPS.fnd_concurrent_requests fcr,
    APPS.fnd_lookups fl,
    APPS.fnd_concurrent_programs_vl fcpv
WHERE     phase_code = 'P'
AND     (fcr.requested_start_date >= sysdate OR status_code = 'P')
AND     LOOKUP_TYPE = 'CP_STATUS_CODE'
AND     lookup_code = status_code
AND     fcr.concurrent_program_id = fcpv.concurrent_program_id
AND     fcr.program_application_id = fcpv.application_id
--AND    user_concurrent_program_name like '%WMIS%'
ORDER BY program_name, request_date;


=====================
pending requests Kept (on hold)
=====================

set lines 130
select     'Requests on hold:' schedt, count(*) schedcnt
from     APPS.fnd_concurrent_requests
WHERE     hold_flag = 'Y'
AND     phase_code = 'P';


set lines 200 pages 200
column pname for a80
column STATUS for a20
SELECT     request_id id,
    nvl(meaning, 'UNKNOWN') status,
    user_concurrent_program_name pname,
    to_char(request_date, 'DD-MON-RR HH24:MI:SS') submitd
FROM     APPS.fnd_concurrent_requests fcr,
    APPS.fnd_lookups fl,
    APPS.fnd_concurrent_programs_vl fcpv
WHERE     phase_code = 'P'
AND     hold_flag = 'Y'
AND     fcr.requested_start_date <= sysdate
AND     status_code != 'P'
AND     LOOKUP_TYPE = 'CP_STATUS_CODE'
AND     lookup_code = status_code
AND     fcr.concurrent_program_id = fcpv.concurrent_program_id
AND     fcr.program_application_id = fcpv.application_id
ORDER BY request_date, request_id;


========================
List of pending Requests (used for Pending jobs threshold Monitor)
========================

set lines 130
set pages 200
column REQUEST heading 'Request' format 9999999999
column PHASE heading 'Phase' format A8
column STATUS heading 'Status' format A8
column PROGRAM heading 'Program Name' format A40
column SHORT heading 'Short Name' format A15
column REQUESTOR heading 'Requestor' format A15
column START_TIME heading 'Start Time' format A15
column RUN_TIME justify left heading 'Time(m)' format 999999.9
column description format a75

select  b.REQUEST_ID "Request", a.description,
       to_char(b.request_date, 'mm/dd/yyyy hh:mi:ss') "request_date",
       to_char(b.requested_start_date, 'mm/dd/yyyy hh:mi:ss') "request_start"
  from APPS.FND_CONCURRENT_PROGRAMS_VL a,
       APPS.FND_CONCURRENT_REQUESTS b
where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
   and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
   and b.PHASE_CODE = 'P'
   and b.HOLD_FLAG !='Y'
   and b.requested_start_date <= sysdate;
  
  


Steps to terminate a Concurrent request from backend
====================================================

select     oracle_process_id ,
    decode(status_code,'R','Running','D','Canceled','E','Error','X','Terminated','G','Warning','T','Terminating')"Status_code",
    phase_code, to_char(actual_start_date,'DD-MON-YYYY=>hh24:mi:ss') "Login Time"
from     apps.fnd_concurrent_requests
where request_id in ('2806397','2806398');    -- Enter_REQUESTID



select s.sid,s.serial#,module,s.status from v$session s,v$process p
where s.paddr=p.addr
and p.spid=&oracle_process_id;            -- oracle_process_id



update     APPS.fnd_concurrent_requests
set      phase_code='C',
    status_code='X'
where     request_id=2806398;            -- Enter_REQUESTID
commit;




Query to find out list of NLS installed in Applications
=======================================================

set lines 130
select LANGUAGE_CODE from APPS.fnd_languages where INSTALLED_FLAG='I';

select NLS_LANGUAGE,LANGUAGE_CODE ,INSTALLED_FLAG from APPS.fnd_languages
where INSTALLED_FLAG in ('I','B');



select REQUEST_ID,PHASE_CODE,STATUS_CODE from APPS.FND_CONCURRENT_REQUESTS
where STATUS_CODE ='Q'
and PHASE_CODE ='P'
And requested_start_date < sysdate;

####################################################################################

What are the meaning of the codes in the status_code and phase_code columns of the FND_CONCURRENT_REQUESTS table?
Doc ID 152209.1

STATUS_CODE Column: (select * from APPS.fnd_lookups where LOOKUP_TYPE='CP_STATUS_CODE')

A Waiting
B Resuming
C Normal
D Cancelled
E Error
F Scheduled
G Warning
H On Hold
I Normal
M No Manager
Q Standby
R Normal    (R = RUNNING in FND_CONC_REQ_SUMMARY_V table)
S Suspended
T Terminating
U Disabled
W Paused
X Terminated
Z Waiting


PHASE_CODE column (select * from APPS.fnd_lookups where LOOKUP_TYPE='CP_PHASE_CODE')

C Completed
I Inactive
P Pending
R Running


All CODE Details can be Found From FND_LOOKUPS Tables ::- FND_LOOKUPS contains the LOV (List Of Values) for Froms And Reports

select * from APPS.fnd_lookups where LOOKUP_TYPE in ('CP_STATUS_CODE','CP_STATUS_CODE_SEARCH')

select * from APPS.fnd_lookups where LOOKUP_TYPE like 'CP%CODE%' order by 1;

LOOKUP_TYPE
------------------------------
CP_ARGUMENT_METHOD_CODE
CP_CONTROL_CODE
CP_EXECUTION_METHOD_CODE
CP_PHASE_CODE
CP_PROCESS_STATUS_CODE
CP_QUEUE_METHOD_CODE
CP_STATUS_CODE
CP_STATUS_CODE_SEARCH
CP_TM_EVENT_CODE
Oracle Profile