Showing posts with label Concurrent Manager. Show all posts
Showing posts with label Concurrent Manager. Show all posts

Thursday, June 13, 2019

Defragment Concurrent Tables

--DEFRAGMENT
---Defragment the tables periodically to reclaim unused space / improve performance

alter table APPLSYS.FND_CONCURRENT_REQUESTS move;
alter table APPLSYS.FND_CRM_HISTORY move;
alter table APPLSYS.FND_CONCURRENT_PROCESSES move;
alter table APPLSYS.FND_CRM_HISTORY move;
alter table APPLSYS.FND_ENV_CONTEXT move;
alter table APPLSYS.FND_TEMP_FILES move;



--select owner, index_name, status from dba_indexes
--where table_owner = upper('APPLSYS') and
--table_name in ('FND_CONCURRENT_REQUESTS','FND_CRM_HISTORY','FND_CONCURRENT_PROCESSES','FND_CRM_HISTORY','FND_ENV_CONTEXT','FND_TEMP_FILES');


--alter index <owner>.<index_name> rebuild online;

alter index APPLSYS.FND_CONCURRENT_PROCESSES_N2 rebuild online;
alter index APPLSYS.FND_CONCURRENT_PROCESSES_N1 rebuild online;
alter index APPLSYS.FND_CONCURRENT_PROCESSES_U1 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N10 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N11 rebuild online;
alter index APPS.FND_CONCURRENT_REQUESTS_F1 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N9 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N2 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_U1 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N1 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N3 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N4 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N5 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N6 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N7 rebuild online;
alter index APPLSYS.FND_CONCURRENT_REQUESTS_N8 rebuild online;
alter index APPLSYS.FND_CRM_HISTORY_U1 rebuild online;
alter index APPLSYS.FND_CRM_HISTORY_U2 rebuild online;
alter index APPLSYS.FND_ENV_CONTEXT_U1 rebuild online;
alter index APPLSYS.FND_TEMP_FILES_N1 rebuild online;
alter index APPLSYS.FND_TEMP_FILES_N2 rebuild online;


--exec fnd_stats.gather_table_stats ('APPLSYS','FND_CONCURRENT_REQUESTS',PERCENT=>99);

exec fnd_stats.gather_table_stats ('APPLSYS','FND_CONCURRENT_REQUESTS',PERCENT=>99);
exec fnd_stats.gather_table_stats ('APPLSYS','FND_CRM_HISTORY',PERCENT=>99);
exec fnd_stats.gather_table_stats ('APPLSYS','FND_CONCURRENT_PROCESSES',PERCENT=>99);
exec fnd_stats.gather_table_stats ('APPLSYS','FND_CRM_HISTORY',PERCENT=>99);
exec fnd_stats.gather_table_stats ('APPLSYS','FND_ENV_CONTEXT',PERCENT=>99);
exec fnd_stats.gather_table_stats ('APPLSYS','FND_TEMP_FILES',PERCENT=>99);

Cost Manager Datafix

select * from mtl_material_transactions where costed_flag = 'E';


select *
   from org_acct_periods where acct_period_id=13481
   --where period_name like 'JUL-14'

select transaction_id,creation_date,organization_id,transaction_date,acct_period_id
from mtl_material_transactions where costed_flag = 'E';




UPDATE mtl_material_transactions
SET acct_period_id         = 13406,
    costed_flag            = 'N',
    transaction_group_id   = NULL,
    transaction_set_id     = NULL,
    ERROR_CODE             = NULL,
    error_explanation      = NULL
WHERE     costed_flag = 'E'
      AND acct_period_id = 13443
      AND ERROR_CODE = 'CST_MATCH_DATE_PERIOD'
      AND organization_id = 317
      AND transaction_id = 4146439;
     
     

Update MTL_MATERIAL_TRANSACTIONS
set COSTED_FLAG = 'N', TRANSACTION_GROUP_ID = NULL
where COSTED_FLAG = 'E' or COSTED_FLAG = 'N';


select count(*) from MTL_MATERIAL_TRANSACTIONS where COSTED_FLAG = 'E' or COSTED_FLAG = 'N';

Concurrent Request Statistics



--- Concurrent Request ran in 24 Hours
SELECT fcr.request_id "Request ID",
       fcp.user_concurrent_program_name "Program",
      -- fcr.argument_text " Parameters",
       fu.user_name "Username",
       fr.responsibility_name "Responsbility",
       fcr.actual_start_date "Starting Time",
       fcr.actual_completion_date "Ending Time",
       TRUNC((fcr.actual_completion_date - fcr.actual_start_date) * 1440, 2) "Hours Minutes"
  FROM fnd_concurrent_requests    fcr,
       fnd_concurrent_programs_vl fcp,
       fnd_responsibility_vl      fr,
       fnd_user                   fu
 WHERE actual_start_date LIKE SYSDATE-1
   AND fu.user_id = fcr.requested_by
      --AND (SYSDATE - actual_start_date) * 24 > 1
   AND status_code = 'C'
   AND phase_code = 'C'
      --AND fu.user_name='MJUBARA'
   and fcr.CONCURRENT_PROGRAM_ID = fcp.CONCURRENT_PROGRAM_ID
   and fu.user_id = fcr.requested_by
   and fr.responsibility_id = fcr.responsibility_id
 order by "Hours Minutes" DESC


 --- CONCURRENT REQUESTS COMPLETED WITH ERROR
 SELECT requestor, a.request_id request_id
, SUBSTR(a.user_concurrent_program_name,1,50) name
, TO_CHAR(a.actual_start_date,'DD/MON/YYYY HH:MI') start_time
, TO_CHAR(a.actual_completion_date,'DD/MON/YYYY HH:MI') end_time
, DECODE(a.phase_code, 'R'
,'Running', 'P'
,'Inactive', 'C'
,'Completed', a.phase_code) phase_code
, DECODE(a.status_code, 'E'
,'Error', 'C'
,'Normal', 'X'
,'Terminated', 'Q'
,'On Hold', 'D'
,'Cancelled', 'G'
,'Warning', 'R'
,'Normal', 'W'
,'Paused', a.status_code) status_code
, argument_text Parameters
, completion_text Completion_Error
FROM apps.fnd_conc_req_summary_v a
WHERE TRUNC(actual_completion_date) >= TRUNC(SYSDATE -1)
AND a.status_code IN ('E')
ORDER BY actual_start_date


---Concurrent Requests Completed With Warning
SELECT requestor, a.request_id request_id
, SUBSTR(a.user_concurrent_program_name,1,50) name
, TO_CHAR(a.actual_start_date,'DD/MON/YYYY HH:MI') start_time
, TO_CHAR(a.actual_completion_date,'DD/MON/YYYY HH:MI') end_time
, DECODE(a.phase_code, 'R'
,'Running', 'P'
,'Inactive', 'C'
,'Completed', a.phase_code) phase_code
, DECODE(a.status_code, 'E'
,'Error', 'C'
,'Normal', 'X'
,'Terminated', 'Q'
,'On Hold', 'D'
,'Cancelled', 'G'
,'Warning', 'R'
,'Normal', 'W'
,'Paused', a.status_code) status_code
, argument_text Parameters
, completion_text Completion_Error
FROM apps.fnd_conc_req_summary_v a
WHERE TRUNC(actual_completion_date) >= TRUNC(SYSDATE -1)
AND a.status_code IN ('G')
ORDER BY actual_start_date



---Concurrent Statistics 24 Hours
SELECT count (fcr.request_id) as "Request Count",
       fcp.user_concurrent_program_name "Program",
       fu.user_name "Username",
       TRUNC((fcr.actual_completion_date - fcr.actual_start_date) * 1440, 2) "Minutes"
       FROM fnd_concurrent_requests    fcr,
       fnd_concurrent_programs_vl fcp,
       fnd_user                   fu
 WHERE actual_start_date LIKE SYSDATE-1
   AND fu.user_id = fcr.requested_by
      --AND (SYSDATE - actual_start_date) * 24 > 1
   AND status_code = 'C'
   AND phase_code = 'C'
   and fcr.CONCURRENT_PROGRAM_ID = fcp.CONCURRENT_PROGRAM_ID
   and fu.user_id = fcr.requested_by
   group  by fcp.user_concurrent_program_name, fu.user_name ,fcr.actual_completion_date,fcr.actual_start_date

Concurrent Program Statestics

select CONC.USER_CONCURRENT_PROGRAM_NAME,
       CONC.CONCURRENT_PROGRAM_NAME,
       CONC.ENABLED_FLAG,
       stat.LAST_RUN_DATE,
       stat.LAST_RUN_REQUEST_ID,
       stat.OUTCOME,
       stat.SUCCESSFUL_COMPLETION,
       stat.WARNING_COMPLETION,
       stat.ERROR_COMPLETION,
       stat.MIN_RUN_TIME,
       stat.MAX_RUN_TIME,
       stat.AVG_RUN_TIME,
       stat.ON_FAILURE_LOG_LEVEL,
       (select meaning
          from fnd_lookups FL
         where FL.lookup_code = stat.OUTCOME
           AND FL.LOOKUP_TYPE = 'CP_STATUS_CODE') MEANING,
       stat.SHELF_LIFE,
       stat.CONNSTR1,
       stat.NODE_NAME1
  from FND_CONCURRENT_PROGRAMS_VL CONC,
       FND_APPLICATION_VL         APP,
       FND_CONC_PROG_ONSITE_INFO  stat
where CONC.APPLICATION_ID = APP.APPLICATION_ID
   AND STAT.CONCURRENT_PROGRAM_ID = CONC.CONCURRENT_PROGRAM_ID
   AND CONC.APPLICATION_ID = STAT.PROGRAM_APPLICATION_ID
   AND CONC.ENABLED_FLAG = 'Y'

Concurrent Managers Status

/* Checking  concurrent programs running currently with Details of Processed time and Start Date */
SELECT DISTINCT
         c.USER_CONCURRENT_PROGRAM_NAME,
         ROUND ( ( (SYSDATE - a.actual_start_date) * 24 * 60 * 60 / 60), 2)
             AS Process_time,
         a.request_id,
         a.parent_request_id,
         a.request_date,
         a.actual_start_date,
         a.actual_completion_date,
         (a.actual_completion_date - a.request_date) * 24 * 60 * 60
             AS end_to_end,
         (a.actual_start_date - a.request_date) * 24 * 60 * 60 AS lag_time,
         d.user_name,
         a.phase_code,
         a.status_code,
         a.argument_text,
         a.priority
    FROM apps.fnd_concurrent_requests   a,
         apps.fnd_concurrent_programs   b,
         apps.FND_CONCURRENT_PROGRAMS_TL c,
         apps.fnd_user                  d
   WHERE     a.concurrent_program_id = b.concurrent_program_id
         AND b.concurrent_program_id = c.concurrent_program_id
         AND a.requested_by = d.user_id
         AND status_code = 'R'
ORDER BY Process_time DESC;



/* For checking the locks in concurrent jobs  */
  SELECT DECODE (request, 0, 'Holder: ', 'Waiter: ') || sid sess,
         inst_id,
         id1,
         id2,
         lmode,
         request,
         TYPE
    FROM gV$LOCK
   WHERE (id1, id2, TYPE) IN (SELECT id1, id2, TYPE
                                FROM gV$LOCK
                               WHERE request > 0)
ORDER BY id1, request;

Concurrent Manager Cleanup Script


====================================================================

REM
REM FILENAME
REM   cmclean.sql
REM DESCRIPTION
REM   Clean out the concurrent manager tables
REM NOTES
REM   Usage: sqlplus <apps_user/apps_passwd> @cmclean
REM
REM
REM   $Id: cmclean.sql,v 1.4 2001/04/07 15:55:07 pferguso Exp $
REM
REM
REM +======================================================================+


set verify off;
set head off;
set timing off
set pagesize 1000

column manager format a20 heading 'Manager short name'
column pid heading 'Process id'
column pscode format a12 heading 'Status code'
column ccode format a12 heading 'Control code'
column request heading 'Request ID'
column pcode format a6 heading 'Phase'
column scode format a6 heading 'Status'


WHENEVER SQLERROR EXIT ROLLBACK;

DOCUMENT

   WARNING : Do not run this script without explicit instructions
             from Oracle Support


   *** Make sure that the managers are shut down     ***
   *** before running this script                    ***

   *** If the concurrent managers are NOT shut down, ***
   *** exit this script now !!                       ***

#

accept answer prompt 'If you wish to continue type the word ''dual'': '

set feed off
select null from &answer;
set feed on


REM     Update process status codes to TERMINATED

prompt
prompt  ------------------------------------------------------------------------

prompt  -- Updating invalid process status codes in FND_CONCURRENT_PROCESSES
set feedback off
set head on
break on manager

SELECT  concurrent_queue_name manager,
        concurrent_process_id pid,
        process_status_code pscode
FROM    fnd_concurrent_queues fcq, fnd_concurrent_processes fcp
WHERE   process_status_code not in ('K', 'S')
AND     fcq.concurrent_queue_id = fcp.concurrent_queue_id
AND     fcq.application_id = fcp.queue_application_id;

set head off
set feedback on
UPDATE  fnd_concurrent_processes
SET     process_status_code = 'K'
WHERE   process_status_code not in ('K', 'S');



REM     Set all managers to 0 processes

prompt
prompt  ------------------------------------------------------------------------

prompt  -- Updating running processes in FND_CONCURRENT_QUEUES
prompt  -- Setting running_processes = 0 and max_processes = 0 for all managers

UPDATE  fnd_concurrent_queues
SET     running_processes = 0, max_processes = 0;




REM     Reset control codes

prompt
prompt  ------------------------------------------------------------------------

prompt  -- Updating invalid control_codes in FND_CONCURRENT_QUEUES
set feedback off
set head on
SELECT  concurrent_queue_name manager,
        control_code ccode
FROM    fnd_concurrent_queues
WHERE   control_code not in ('E', 'R', 'X')
AND     control_code IS NOT NULL;

set feedback on
set head off
UPDATE  fnd_concurrent_queues
SET     control_code = NULL
WHERE   control_code not in ('E', 'R', 'X')
AND     control_code IS NOT NULL;

REM     Also null out target_node for all managers
UPDATE  fnd_concurrent_queues
SET     target_node = null;


REM     Set all 'Terminating' requests to Completed/Error
REM     Also set Running requests to completed, since the managers are down

prompt
prompt  ------------------------------------------------------------------------

prompt  -- Updating any Running or Terminating requests to Completed/Error
set feedback off
set head on
SELECT  request_id request,
        phase_code pcode,
        status_code scode
FROM    fnd_concurrent_requests
WHERE   status_code = 'T' OR phase_code = 'R'
ORDER BY request_id;

set feedback on
set head off
UPDATE  fnd_concurrent_requests
SET     phase_code = 'C', status_code = 'E'
WHERE   status_code ='T' OR phase_code = 'R';





REM     Set all Runalone flags to 'N'
REM     This has to be done differently for Release 10

prompt
prompt  ------------------------------------------------------------------------

prompt  -- Updating any Runalone flags to 'N'
prompt
set serveroutput on
set feedback off
declare
        c         pls_integer := dbms_sql.open_cursor;
        upd_rows  pls_integer;
        vers      varchar2(50);
        tbl       varchar2(50);
        col       varchar2(50);
        statement varchar2(255);
begin

        select substr(release_name, 1, 2)
        into   vers
        from fnd_product_groups;

        if vers >= 11 then
           tbl := 'fnd_conflicts_domain';
           col := 'runalone_flag';
        else
           tbl := 'fnd_concurrent_conflict_sets';
           col := 'run_alone_flag';
        end if;


        statement := 'update ' || tbl || ' set ' || col || '=''N'' where ' || col || ' = ''Y''';
        dbms_sql.parse(c, statement, dbms_sql.native);
        upd_rows := dbms_sql.execute(c);
        dbms_sql.close_cursor(c);
        dbms_output.put_line('Updated ' || upd_rows || ' rows of ' || col || ' in ' || tbl || ' to ''N''');
end;
/



prompt

prompt  ------------------------------------------------------------------------

prompt  Updates complete.
prompt  Type commit now to commit these updates, or rollback to cancel.
prompt  ------------------------------------------------------------------------

prompt

set feedback on

REM  <= Last REM statment -----------------------------------------------------



Some Tips About FNDLOAD

Data Synchronization  Data Synchronization is a process in which some setup data would be synchronized, and this would be more important w...