Oracle Database Administration, Oracle Developer Suite, Oracle JDeveloper, Oracle BI Publisher, Oracle Forms/Reports,Oracle SQL Developer

Data Center Consolidation

Data center consolidation is the process of reducing the volume of physical IT assets through highly efficient and scalable technologies. Organizations leverage data center consolidation to reduce operating costs.

Analyse and Solve Serious Hardware and Sofware Problems

Listing several basic hardware and software troubleshooting steps with respect to operating systems, software programs, and computer hardware.

Mission Critical Systems

A mission critical system is a system that is essential to the survival of a business or organization. When a mission critical system fails or is interrupted, business operations are significantly impacted.

The best server hardware to maximize IT performance

Data center hardware advances target new workloads such as big data processing, as well as higher efficiency for existing apps and services. The best server hardware for your data center depends on existing and planned application architectures, data center operations staff skills and of course the IT budget.

Oracle Home inventory is corrupted LsInventorySession failed: OracleHomeInventory

Oracle Home inventory is corrupted LsInventorySession failed: OracleHome Inventory

[oratest@slctest01 OPatch]$ opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.3
Copyright (c) 2012, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/oracle/testdb/11.2.0
Central Inventory : /u01/oraInventory
   from           : /u01/oracle/testdb/11.2.0/oraInst.loc
OPatch version    : 11.2.0.3.3
OUI version       : 11.2.0.3.0
Log file location : /u01/oracle/testdb/11.2.0/cfgtoollogs/opatch/opatch2013-05-15_10-27-12AM_1.log

List of Homes on this system:

Inventory load failed... OPatch cannot load inventory for the given Oracle Home.
Possible causes are:
   Oracle Home dir. path does not exist in Central Inventory
   Oracle Home is a symbolic link
   Oracle Home inventory is corrupted
LsInventorySession failed: OracleHomeInventory gets null oracleHomeInfo

OPatch failed with error code 73


Solution

I was able to solve this issue; Follow the steps below:

 1. Login to the server.
 2. cd $ORACLE_HOME/oui/bin
 $ ./attachHome.sh
 Starting Oracle Universal Installer...

 Checking swap space: must be greater than 500 MB. Actual 196608 MB Passed
 Preparing to launch Oracle Universal Installer from /tmp/OraInstall2012-06-27_03-07-48AM. Please wait ...
 3. Re-run the same command and it is going to work.

 [oratest@slctest01 ~]$ opatch lsinventory

Oracle E-Business Suite Current patch level

 SELECT ABBREVIATION,
             NAME,
             TYPE,
             CODELEVEL,
             BASELINE
       FROM AD_TRACKABLE_ENTITIES
       WHERE ABBREVIATION IN ('ad',
                          'txk',
                          'fnd',
                          'fwk',
                          'atg_pf',
                          'icx')
      ORDER BY ABBREVIATION;

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);

Creating ACL for UTL_SMTP

SELECT *
FROM dba_network_acls;

-- Create ACL and privilege
begin
  dbms_network_acl_admin.create_acl (
    acl         => 'utl_mail.xml',
    description => 'Allow mail to be send',
    principal   => 'APPS',
    is_grant    => TRUE,
    privilege   => 'connect'
    );
    commit;
end;

--Add Privilege

begin
  dbms_network_acl_admin.add_privilege (
  acl       => 'utl_mail.xml',
  principal => 'APPS',
  is_grant  => TRUE,
  privilege => 'resolve'
  );
  commit;
end


--Test1

begin
  dbms_network_acl_admin.assign_acl(
  acl  => 'utl_mail.xml',
  host => 'mail.company.com.sa'
  );
  commit;
end;

--Test2
begin
  utl_mail.send(
  sender     => 'fromuser@company.com',
  recipients => 'myname@company.com,user2@company.com, user3@company.com',
  message    => 'Test E-mail from ERP Database'
  );
  commit;
end;

Cost Manager Status

SELECT x.process_type "Name",
  DECODE(
  (SELECT '1' FROM fnd_concurrent_requests cr,
    fnd_concurrent_programs_vl cp,
    fnd_application a WHERE cp.concurrent_program_id = cr.concurrent_program_id
  AND cp.concurrent_program_name                     = x.process_name
  AND cp.application_id                              = a.application_id
  AND a.application_short_name                       = x.process_app_short_name
  AND phase_code                                    != 'C'
  ),'1','Active','Inactive') "Status",
  x.worker_rows "Worker Rows",
  x.timeout_hours "Timeout Hours",
  x.timeout_minutes "Timeout Minutes",
  x.process_hours "Process Interval Hours",
  x.process_minutes "Process Interval Minutes",
  x.process_seconds "Process Interval Seconds"
FROM
  (SELECT mipc.process_code ,
    mipc.process_status ,
    mipc.process_interval ,
    mipc.manager_priority ,
    mipc.worker_priority ,
    mipc.worker_rows ,
    mipc.processing_timeout ,
    mipc.process_name ,
    mipc.process_app_short_name ,
    a.meaning process_type ,
    FLOOR(mipc.process_interval    /3600) process_hours ,
    FLOOR((mipc.process_interval   - (FLOOR(mipc.process_interval/3600) * 3600))/60) process_minutes ,
    (mipc.process_interval         - (FLOOR(mipc.process_interval/3600) * 3600) - (FLOOR((mipc.process_interval - (FLOOR(mipc.process_interval/3600) * 3600))/60) * 60)) process_seconds ,
    FLOOR(mipc.processing_timeout  /3600) timeout_hours ,
    FLOOR((mipc.processing_timeout - FLOOR(mipc.processing_timeout/3600) * 3600)/60) timeout_minutes
  FROM mtl_interface_proc_controls mipc,
    mfg_lookups a
  WHERE a.lookup_type = 'PROCESS_TYPE'
  AND a.lookup_code   = mipc.process_code
  ) x
  -- WHERE x.PROCESS_TYPE = 'Cost Manager' -- uncomment this to display only the cost manager
ORDER BY 1;



SELECT request_id RequestId,
request_date RequestDt, concurrent_program_name,
phase_code Phase,
status_code Status FROM
fnd_concurrent_requests fcr,
fnd_concurrent_programs fcp
WHERE fcp.application_id = 702 AND
fcp.concurrent_program_name in ('CMCTCM', 'CMCMCW', 'CMCACW') AND
fcr.concurrent_program_id = fcp.concurrent_program_id AND
fcr.program_application_id = 702 AND fcr.phase_code <> 'C'


-- Pending Cost Transations
select count(*) from MTL_MATERIAL_TRANSACTIONS where COSTED_FLAG = 'N' --or COSTED_FLAG = 'N';
--and organization_id=317

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

select * from cst_lc_adj_interface


Select * from cst_lc_adj_interface

Select * from cst_lc_adj_interface_errors


select * from wip_cost_txn_interface

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';

Core HR SQL Queries

--Organization through Organization Hierarchy

SELECT NAME, TYPE, organization_id
                 FROM (SELECT hou.NAME, TYPE, organization_id
                         FROM hr_all_organization_units hou
                        WHERE organization_id IN (
                                 SELECT     organization_id_child
                                                              organization_id
                                       FROM (SELECT organization_id_child,
                                                    organization_id_parent,
                                                    org_structure_version_id
                                               FROM per_org_structure_elements
                                              WHERE org_structure_version_id IN (
                                                       SELECT posv.org_structure_version_id
                                                         FROM per_organization_structures pos,
                                                              per_org_structure_versions posv
                                                        WHERE primary_structure_flag =
                                                                           'Y'
                                                          AND pos.organization_structure_id =
                                                                 posv.organization_structure_id
                                                          AND pos.NAME =
                                                                 :p_x_org_hierarchy))
                                 CONNECT BY organization_id_child =
                                                   PRIOR organization_id_parent
                                 START WITH organization_id_child =
                                                             :x_organization_id)
                          AND UPPER (hou.TYPE) = :x_organization_type)
                WHERE ROWNUM = 1;

--Find Organization Manager Query
SELECT NVL
                         ((SELECT NVL (papf.person_id, 0)
                             FROM hr_all_organization_units org,
                                  hr_all_organization_units_tl org_tl,
                                  hr_organization_information org_info2,
                                  per_all_people_f papf
                            WHERE org_info2.organization_id =
                                                           org.organization_id
                              AND org_info2.org_information_context =
                                                     'Organization Name Alias'
                              AND org_info2.org_information2 = TO_CHAR (papf.person_id(+))
                              AND org.organization_id = org_tl.organization_id
                              AND org_tl.LANGUAGE = USERENV ('LANG')
                              AND org_tl.NAME = :x_org_name
                              AND papf.current_employee_flag = 'Y'
                              AND TRUNC (:x_effective_date)
                                     BETWEEN papf.effective_start_date
                                         AND papf.effective_end_date),
                          0
                         ) val
                 FROM DUAL;
               
--Find the List Users that have a particular Responsibility
select rg.user_id,fu.user_name,ppf.employee_number,ppf.full_name,rt.responsibility_name
from fnd_responsibility_tl rt,FND_USER_RESP_GROUPS_DIRECT rg,fnd_user fu, per_all_people_f ppf
where upper(RESPONSIBILITY_NAME) like '%APPROVALS MANAGEMENT BUSINESS ANALYST'
and rt.RESPONSIBILITY_ID = rg.RESPONSIBILITY_ID
and rg.user_id = fu.user_id
and fu.employee_id = ppf.person_id
and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date


--Find total Active employee in the company
select ppf.employee_number,ppf.full_name,ppf.email_address
from per_all_people_f ppf
where ppf.current_employee_flag = 'Y'
and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and ppf.employee_number is not null
and ppf.person_type_id = ( select person_type_id
from per_person_types
where user_person_type = 'Employee'
and business_group_id = ppf.BUSINESS_GROUP_ID
)

--Get Month Wise Hired Employees Head Count
select to_char(ORIGINAL_DATE_OF_HIRE,'MON') MM, COUNT(PERSON_ID) TOTAL from per_people_x
WHERE to_char(ORIGINAL_DATE_OF_HIRE,'RRRR') = '2017'
group by to_char(ORIGINAL_DATE_OF_HIRE,'MON')

--Provide a List of Active Employees along with their Supervisor’s Name and email address
select ppf.employee_number,ppf.full_name,ppf.email_address ,paaf.supervisor_id,sup.full_name,sup.email_address
from per_all_people_f ppf,per_all_assignments_f paaf,per_people_x sup
where ppf.current_employee_flag = 'Y'
and paaf.supervisor_id (+) = sup.person_id
and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and trunc(sysdate) between paaf.effective_start_date and paaf.effective_end_date
and ppf.person_id = paaf.person_id
and ppf.employee_number is not null
--d ppf.employee_number = '39988'
and ppf.person_type_id = ( select person_type_id
from per_person_types
where user_person_type = 'Employee'
and business_group_id = ppf.BUSINESS_GROUP_ID
)

--Get the Employee Salary Increase Summary
select ppf.employee_number,ppf.full_name,ppp.proposed_salary_n,ppp.change_date
from per_pay_proposals ppp,per_all_people_f ppf,per_all_assignments_f paaf
where ppf.person_id = paaf.person_id
and paaf.assignment_id = ppp.assignment_id
and ppf.employee_number = ‘603167’
and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and trunc(sysdate) between paaf.effective_start_date and paaf.effective_end_date
and ppp.approved = ‘Y’
and change_date = (select min(change_date) from per_pay_proposals where assignment_id = ppp.assignment_id and proposed_salary_n = ppp.proposed_salary_n)
order by ppp.change_date desc

--Get the History for An Employee’s Transfers in the company
--Get the list of employee who were terminated and have been rehired
select ppf.employee_number,ppf.full_name,ppf.email_address
from per_all_people_f ppf
where trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and person_id in
( select person_id
from (
select count(1),person_id
from per_periods_of_service
group by person_id
having count(1) > 1
)
)

--Get the List of Terminated Employees
select ppf.employee_number,ppf.full_name,ppf.email_address
from per_all_people_f ppf
where trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and current_employee_flag is null
and ppf.person_type_id = ( select person_type_id
from per_person_types
where user_person_type = 'Ex-employee'
and business_group_id = ppf.BUSINESS_GROUP_ID
)

--Get an Employees Leave History
select a.date_start,a.date_end,a.absence_days,
(select name from per_ABSENCE_ATTENDANCE_types
where ABSENCE_ATTENDANCE_TYPE_ID = a.ABSENCE_ATTENDANCE_TYPE_ID
and business_group_id =a.business_group_id) leave_type
from per_absence_attendances a
where person_id = (select person_id from per_all_people_f where employee_number = '1000063' and employee_number is not null)
order by date_start desc

--Get EIT Based information for employees
select ppf.employee_number,ppf.full_name, ppei.* from per_all_people_f ppf, per_people_extra_info ppei
where ppf.person_id = ppei.person_id
and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and ppf.employee_number = '1000063'
--and ppei.information_type = 'XX_OTHER_DETAILS'

--Get SIT Based information for employees
select * from per_person_analyses ppa,per_analysis_criteria pac
where ppa.ANALYSIS_CRITERIA_ID = pac.ANALYSIS_CRITERIA_ID
and person_id = 115043
and pac.ID_FLEX_NUM =
(
select fis.ID_FLEX_NUM
from FND_ID_FLEXS fif, FND_ID_FLEX_STRUCTURES fis
where fif.ID_FLEX_CODE = fis.ID_FLEX_CODE
and id_flex_structure_code = ‘XX_PROBATION_EVALUATION’
)

--Get the List of all Organization which are below an organization in Org Hierarchy
--Get the List of all Organization which are Above an organization in Org Hierarchy
--Parent and Child Organizations List

select hp.name parent_org, hc.name child_organization
from PER_ORG_STRUCTURE_ELEMENTS pose, PER_ORG_STRUCTURE_VERSIONS posv, hr_all_organization_units hc, hr_all_organization_units hp
where 1=1
and pose.BUSINESS_GROUP_ID = posv.BUSINESS_GROUP_ID
and pose.ORGANIZATION_ID_CHILD = hc.organization_id
and pose.ORGANIZATION_ID_PARENT = hp.organization_id

--Get the Oracle Balance Values
SELECT pdb.defined_balance_id,dim.dimension_name
FROM pay_defined_balances pdb,
pay_balance_types typ,
pay_balance_dimensions dim
WHERE pdb.balance_type_id = typ.balance_type_id
AND pdb.balance_dimension_id = dim.balance_dimension_id
AND dim.legislation_code = ( SELECT legislation_code FROM per_business_groups WHERE business_group_id = 81)
AND UPPER (typ.balance_name) = UPPER ('Indemnity Days')
AND UPPER (dim.dimension_name) = UPPER ('Assignment Run');

select pay_balance_pkg.get_value (P_Balance_ID, P_Assignment_Action_ID, trunc(sysdate))
from dual

--Trunc(Sysdate) will return you balance value as of Date, you can use any old date as per your requirement.

--Disable Responsibilities for Users
--Normally such requirement occurs when you want that no user should be able to logged in during any particular time like some upgrade project or any critical migration activity. You can disable the users by following query.  Al though direct updates are not allowed but since this table does not contain object version id column so we used queries mentioned below. Please consult Oracle Support if you want to double check the impact of using this update statement.

update fnd_responsibility a
set a.END_DATE = to_date(’05-APR-2016?)
where a.RESPONSIBILITY_KEY in
(      SELECT distinct b.RESPONSIBILITY_KEY
FROM FND_USER_RESP_GROUPS A,
FND_RESPONSIBILITY_VL B,
FND_USER C,
PER_ALL_PEOPLE_F D
WHERE A.responsibility_id = B.responsibility_id AND
C.user_id = A.user_id AND
(to_char(A.end_date) IS NULL   OR   A.end_date > sysdate)
AND C.user_name = D.EMPLOYEE_NUMBER
and (b.RESPONSIBILITY_KEY like ‘%LSG%’)
and C.EMPLOYEE_ID is not null
)

--In order to reset the responsibilities back to original state

update fnd_responsibility a
set a.END_DATE = NULL
where a.RESPONSIBILITY_KEY in
(      SELECT distinct b.RESPONSIBILITY_KEY
FROM FND_USER_RESP_GROUPS A,
FND_RESPONSIBILITY_VL B,
FND_USER C,
PER_ALL_PEOPLE_F D
WHERE A.responsibility_id = B.responsibility_id AND
C.user_id = A.user_id AND
(to_char(A.end_date) IS NULL   OR   A.end_date > sysdate)
AND C.user_name = D.EMPLOYEE_NUMBER
and (b.RESPONSIBILITY_KEY like ‘%LSG%’)
and C.EMPLOYEE_ID is not null
)
and end_date IS not NULL
and end_date = ’05-APR-2016?

--Provide the List of Employees current and Previous Assignment Details
--(shows  Employee Organization Change history. Like wise we can change the query to show the history of Grade, Payroll, Organization, Location, Position, Job change summary)

select
ppf.employee_number
,paaf.assignment_number
,ppf.full_name
,paaf.organization_id current_org_id
,paaf.effective_start_date Curr_org_start_date
,(select name from hr_all_organization_units where organization_id = paaf.organization_id) current_org_name
,paaf_prev.effective_start_date prev_org_start_date
,paaf_prev.organization_id prev_org_id
,(select name from hr_all_organization_units where organization_id = paaf_prev.organization_id) prev_org
from per_all_assignments_f paaf,per_all_assignments_f paaf_prev,pay_people_groups ppg,pay_people_groups ppg_prev,per_all_people_f ppf
where paaf_prev.effective_end_date + 1= paaf.effective_start_date
and paaf_prev.assignment_id = paaf.assignment_id
and paaf_prev.assignment_type = 'E'
and ppf.employee_number = '1000063'
and paaf.assignment_type = 'E'
and paaf.organization_id <> paaf_prev.organization_id
and paaf.PEOPLE_GROUP_ID = ppg.people_group_id
and paaf_prev.PEOPLE_GROUP_ID = ppg_prev.people_group_id
and paaf.effective_start_date between ppf.effective_start_date and ppf.effective_end_date
and paaf.person_id = ppf.person_id
order by paaf_prev.effective_start_date desc

--Employee Short Leave Details and Hours Calculation
select paa.person_id,paa.date_start, paa.date_end,time_start,time_end
,round ( ( ((substr(time_end,1,2) -substr(time_start,1,2)) * 60
+ (substr(time_end,4,2) -substr(time_start,4,2))) / 60 ) ,2) Hours
from per_absence_attendances paa,per_absence_Attendance_types paat
where paa.person_id = 68567
and paa.absence_attendance_type_id = paat.absence_attendance_type_id
and paat.name = 'Short Leave'
and paa.date_start between :P_Period_Start_date and :P_Period_End_date
and paa.date_end between :P_Period_Start_date and :P_Period_End_date

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;

Compile Forms command line

TEST

f60gen module=/u5/applupg2/uatappl/au/11.5.0/forms/US/APXINWKB.fmb userid=APPS/APPS
output_file=/u5/applupg2/uatappl/ap/11.5.0/forms/US/APXINWKB.fmx
module_type=form
batch=no
compile_all=special



PROD


f60gen module=/u3/applprd/prdappl/au/11.5.0/forms/US/APXINWKB.fmb userid=APPS/APPS
output_file=/u3/applprd/prdappl/ap/11.5.0/forms/US/APXINWKB.fmx
module_type=form
batch=no
compile_all=special

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 -----------------------------------------------------



Check Materialized view Refresh


 SELECT owner, mview_name, last_refresh_date
  FROM all_mviews
 where mview_name like 'MATERIALIZED_VIEW_NAME'

Check Database Locks

--To check database locks----[Kill Inactive Session] ----------------------------------------------------
SELECT * FROM dba_locks WHERE blocking_others='Blocking';

select LOCK_TYPE,SESSION_ID,BLOCKING_OTHERS from dba_locks where BLOCKING_OTHERS !='Not Blocking';

select process,sid, blocking_session from v$session where blocking_session is not null;

--Locked tables
SELECT l.session_id sid, o.object_name, o.object_type
FROM v$locked_object l, all_objects o
WHERE l.object_id = o.object_id

select SID,SERIAL#,MODULE,ACTION,CLIENT_IDENTIFIER,BLOCKING_SESSION_STATUS,STATE from v$session
where status='INACTIVE'
--where CLIENT_IDENTIFIER='%MONIR%'
AND MODULE like '%BOM%'
AND STATE='WAITING'
AND CLIENT_IDENTIFIER !='SYSADMIN'


--get SERIAL# where SID is from the above script
select * from v$session where SID=6563


--To kill the session with seesion id------------------------------------------------------------------
ALTER SYSTEM KILL SESSION '1351,993';

select * from v$session where process='144'



SELECT B.Owner, B.Object_Name, A.Oracle_Username, A.OS_User_Name 
FROM V$Locked_Object A, All_Objects B
WHERE A.Object_ID = B.Object_ID


select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from
(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a,
(select object_id, owner, object_name,object_type from dba_objects) b
where a.object_id=b.object_id;

SELECT a.object_id, a.session_id, substr(b.object_name, 1, 40)
FROM v$locked_object a, dba_objects b
WHERE a.object_id = b.object_id
AND b.object_name like 'BOM%'
ORDER BY b.object_name;




SELECT l.*, o.owner object_owner, o.object_name
FROM SYS.all_objects o, v$lock l
WHERE l.TYPE = 'TM'
AND o.object_id = l.id1
AND o.object_name in ('AP_INVOICES_ALL', 'AP_INVOICE_LINES_ALL', 'AP_INVOICE_DISTRIBUTIONS_ALL');




SELECT SID, SERIAL#
FROM v$session
WHERE SID = 960;



--R12: APXPAWKB Cannot Select this Payment Document Because it is in use By Another Single Payment (Doc ID 1322570.1)
--In the instance where user can reproduce the issue run the following queries:

1)

select * from dba_objects where object_name like 'CE_PAYMENT_DOCUMENTS'
and owner = 'CE';

2)

select * from v$locked_object where object_id in (select object_id from
dba_objects where object_name like 'CE_PAYMENT_DOCUMENTS'and owner = 'CE');

3)

select * from v$session where sid in (select session_id from
v$locked_object where object_id in (select object_id from dba_objects where
object_name like 'CE_PAYMENT_DOCUMENTS'and owner = 'CE'));

4)

select * from dba_locks where session_id in (select session_id from
v$locked_object where object_id in (select object_id from dba_objects where
object_name like ‘CE_PAYMENT_DOCUMENTS’and owner = ‘CE’));

Query result 3 provides the session which is having the lock of payment document.

Kill the session which is locking the 'CE_PAYMENT_DOCUMENTS' table

alter system kill session 'session,serial';

Cancel Scheduled Concurrent requests

--How to Cancel a Concurrent Request Stuck in the Queue? [ID 749748.1]
--CCM.sql Diagnostic Script for Concurrent Manager [ID 171855.1]
--CMCLEAN.SQL - Non Destructive Script to Clean Concurrent Manager Tables [ID 134007.1]
--How to Clear a Request Set Stuck in RUNNING / PAUSED Status [ID 1081912.6]

--STATUS_CODE Column:
--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 S Suspended T Terminating U Disabled W Paused X Terminated Z Waiting

--PHASE_CODE column
--C Completed I Inactive P Pending R Running

update FND_CONCURRENT_REQUESTS set phase_code='C',status_code='D' where phase_code='R' and requested_by in ('1187','1158','2842','3481')

commit

select * from FND_CONCURRENT_REQUESTS where phase_code='R' and requested_by in ('1757','1197','1186','1185')

--Update a specifix concurrent program
update FND_CONCURRENT_REQUESTS set phase_code='C',status_code='D' where phase_code='R' --and requested_by in ('1757','1197','1186','1185')
and REQUEST_ID in ('12095604','12095598','12095589')

commit

select * from FND_CONCURRENT_REQUESTS where phase_code='R' --and requested_by in ('1757','1197','1186','1185')
and REQUEST_ID in ('11150939','11134004','11130061')


-- To get the list of Scheduled Concurrent Requests ------------------------------------------------------------

SELECT
a.request_id,
A.REQUESTED_BY,
a.program,
a.argument_text,
a.requested_start_date,
b.resubmit_interval,
b.resubmit_interval_unit_code,
a.requestor
FROM  apps.fnd_conc_req_summary_v a,    apps.fnd_concurrent_requests b
WHERE a.phase_code='P' AND a.request_id=b.request_id
--and a.REQUESTOR not in ('SYSADMIN')
ORDER BY a.request_id DESC

Assigning Responsibility using FND_USER_PKG


BEGIN
fnd_user_pkg.addresp
(username => UPPER
('MUQTHIYAR.PASHA'),
resp_app => 'FND',
resp_key => 'APPLICATION_DEVELOPER',
security_group => 'STANDARD',
description => NULL,
start_date => SYSDATE,
end_date => NULL
);
COMMIT;
DBMS_OUTPUT.put_line ('Responsibility Added Successfully');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Responsibility is not added due to'|| SQLCODE|| SUBSTR (SQLERRM, 1, 100));
ROLLBACK;
END;
/



/* Assign Rest to user0) */
BEGIN
    FOR r
        IN (SELECT distinct fu.user_name,
       fa.application_short_name,
       fr.responsibility_key,   
       furg.start_date,           
       furg.end_date
  FROM fnd_user_resp_groups_direct        furg,
       applsys.fnd_user                   fu,
       applsys.fnd_responsibility_tl      frt,
       applsys.fnd_responsibility         fr,
       applsys.fnd_application_tl         fat,
       applsys.fnd_application            fa
 WHERE furg.user_id             =  fu.user_id
   AND furg.responsibility_id   =  frt.responsibility_id
   AND fr.responsibility_id     =  frt.responsibility_id
   AND fa.application_id        =  fat.application_id
   AND fr.application_id        =  fat.application_id
   AND frt.language             =  USERENV('LANG')
   AND FU.USER_NAME IN ('USER1',
                                       'USER2',
                                       'DEVUSER1',
                                       'DEVUSER2',
                                       'FUNCUSER1',
                                       'FUNUSR2')
   AND frt.RESPONSIBILITY_NAME in ('Application Developer',
                            'Workflow Administrator',
                            'Functional Developer',
                            'Functional Administrator',
                            'XML Publisher Administrator',
                            'General Ledger KSA Ledger IT',
                            'General Ledger UAE Ledger IT',
                            'General Ledger FZE Ledger IT' ))
    LOOP
        BEGIN
            fnd_user_pkg.addresp (username         => UPPER (r.USER_NAME),
                                  resp_app         => r.APPLICATION_SHORT_NAME,
                                  resp_key         => r.RESPONSIBILITY_KEY,
                                  security_group   => 'STANDARD',
                                  description      => NULL,
                                  start_date       => SYSDATE,
                                  end_date         => NULL);
            COMMIT;
            DBMS_OUTPUT.put_line ('Responsibility Added Successfully');
        EXCEPTION
            WHEN OTHERS
            THEN
                DBMS_OUTPUT.put_line (
                       'Responsibility is not added due to'
                    || SQLCODE
                    || SUBSTR (SQLERRM, 1, 100));
                ROLLBACK;
        END;
    END LOOP;
END;
/


--
SELECT distinct fu.user_name,
       fa.application_short_name,
       fr.responsibility_key,   
       furg.start_date,           
       furg.end_date
  FROM fnd_user_resp_groups_direct        furg,
       applsys.fnd_user                   fu,
       applsys.fnd_responsibility_tl      frt,
       applsys.fnd_responsibility         fr,
       applsys.fnd_application_tl         fat,
       applsys.fnd_application            fa
 WHERE furg.user_id             =  fu.user_id
   AND furg.responsibility_id   =  frt.responsibility_id
   AND fr.responsibility_id     =  frt.responsibility_id
   AND fa.application_id        =  fat.application_id
   AND fr.application_id        =  fat.application_id
   AND frt.language             =  USERENV('LANG')
   AND FU.USER_NAME IN ('USER1',
                                       'USER2',
                                       'DEVUSER1',
                                       'DEVUSER2',
                                       'FUNCUSER1',
                                       'FUNUSR2')
   AND frt.RESPONSIBILITY_NAME in ('Application Developer',
                            'Workflow Administrator',
                            'Functional Developer',
                            'Functional Administrator',
                            'XML Publisher Administrator',
                            'General Ledger KSA Ledger IT',
                            'General Ledger UAE Ledger IT',
                            'General Ledger FZE Ledger IT')
   --AND UPPER(fu.user_name)      =  UPPER('USER1')  -- <change it>
   --AND (furg.end_date IS NULL OR furg.end_date >= TRUNC(SYSDATE))
 --ORDER BY frt.responsibility_name;

Archive Log Statastics


select * from V$LOG_HISTORY

select * from V$ARCHIVE_DEST


select trunc(COMPLETION_TIME) TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/1024 SIZE_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME) order by 1;


select trunc(COMPLETION_TIME) TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/1024 SIZE_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME) order by 1;

select trunc(COMPLETION_TIME,'HH24') TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/1024 SIZE_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME,'HH24') order by 1;

SELECT TRUNC(COMPLETION_TIME) ARCHIVED_DATE,
           SUM(BLOCKS * BLOCK_SIZE) / 1024 / 1024 SIZE_IN_MB
      FROM V$ARCHIVED_LOG
     GROUP BY TRUNC(COMPLETION_TIME)
     ORDER BY 1;



select sum((blocks*block_size)/(1024*1024))SIZEinMB,sequence#,name
from v$archived_log
group by sequence#,name
order by sequence#


SELECT trunc(first_time) DAY,
     count(*) NB_SWITCHS,
     trunc(count(*)*log_size/1024) TOTAL_SIZE_KB,
     to_char(count(*)/24,'9999.9') AVG_SWITCHS_PER_HOUR
FROM v$loghist,(select avg(bytes) log_size from v$log)
GROUP BY trunc(first_time),log_size
/


-- Size of the archive log files each hour
alter session set nls_date_format = 'YYYY-MM-DD HH24';

SELECT TRUNC(COMPLETION_TIME, 'HH') ARCHIVED_DATE_HOUR,
            SUM(BLOCKS * BLOCK_SIZE) / 1024 / 1024 SIZE_IN_MB
       FROM V$ARCHIVED_LOG
      GROUP BY TRUNC(COMPLETION_TIME, 'HH')
      ORDER BY 1;


SELECT
            TRUNC(COMPLETION_TIME) ARCHIVED_DATE,
            THREAD#,
            SUM(BLOCKS * BLOCK_SIZE) / 1024 / 1024 SIZE_IN_MB
       FROM V$ARCHIVED_LOG
      GROUP BY TRUNC(COMPLETION_TIME), THREAD#
      ORDER BY 1, 2;
     
     
     

-- per day the volume in MBytes of archived logs generated
SELECT SUM_ARCH.DAY,
         SUM_ARCH.GENERATED_MB,
         SUM_ARCH_DEL.DELETED_MB,
         SUM_ARCH.GENERATED_MB - SUM_ARCH_DEL.DELETED_MB "REMAINING_MB"
    FROM (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024), 2))
                      GENERATED_MB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH,
         (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024), 2))
                      DELETED_MB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES' AND DELETED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH_DEL
   WHERE SUM_ARCH.DAY = SUM_ARCH_DEL.DAY(+)
ORDER BY TO_DATE (DAY, 'DD/MM/YYYY');


-- display the number of archived logs generated per hour per day:

---number of archived logs generated per hour per day

SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '00', 1, NULL))
            "00-01",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '01', 1, NULL))
            "01-02",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '02', 1, NULL))
            "02-03",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '03', 1, NULL))
            "03-04",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '04', 1, NULL))
            "04-05",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '05', 1, NULL))
            "05-06",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '06', 1, NULL))
            "06-07",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '07', 1, NULL))
            "07-08",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '08', 1, NULL))
            "08-09",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '09', 1, NULL))
            "09-10",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '10', 1, NULL))
            "10-11",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '11', 1, NULL))
            "11-12",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '12', 1, NULL))
            "12-13",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '13', 1, NULL))
            "13-14",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '14', 1, NULL))
            "14-15",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '15', 1, NULL))
            "15-16",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '16', 1, NULL))
            "16-17",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '17', 1, NULL))
            "17-18",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '18', 1, NULL))
            "18-19",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '19', 1, NULL))
            "19-20",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '20', 1, NULL))
            "20-21",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '21', 1, NULL))
            "21-22",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '22', 1, NULL))
            "22-23",
         SUM (DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '23', 1, NULL))
            "23-00",
         COUNT (*) TOTAL
    FROM V$ARCHIVED_LOG
WHERE ARCHIVED='YES'
GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')
ORDER BY TO_DATE (DAY, 'DD/MM/YYYY');



-- Combination of these scripts is:

SELECT LOG_HISTORY.*,
         SUM_ARCH.GENERATED_MB,
         SUM_ARCH_DEL.DELETED_MB,
         SUM_ARCH.GENERATED_MB - SUM_ARCH_DEL.DELETED_MB "REMAINING_MB"
    FROM (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '00', 1, NULL))
                      "00-01",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '01', 1, NULL))
                      "01-02",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '02', 1, NULL))
                      "02-03",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '03', 1, NULL))
                      "03-04",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '04', 1, NULL))
                      "04-05",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '05', 1, NULL))
                      "05-06",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '06', 1, NULL))
                      "06-07",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '07', 1, NULL))
                      "07-08",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '08', 1, NULL))
                      "08-09",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '09', 1, NULL))
                      "09-10",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '10', 1, NULL))
                      "10-11",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '11', 1, NULL))
                      "11-12",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '12', 1, NULL))
                      "12-13",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '13', 1, NULL))
                      "13-14",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '14', 1, NULL))
                      "14-15",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '15', 1, NULL))
                      "15-16",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '16', 1, NULL))
                      "16-17",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '17', 1, NULL))
                      "17-18",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '18', 1, NULL))
                      "18-19",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '19', 1, NULL))
                      "19-20",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '20', 1, NULL))
                      "20-21",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '21', 1, NULL))
                      "21-22",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '22', 1, NULL))
                      "22-23",
                   SUM (
                      DECODE (TO_CHAR (COMPLETION_TIME, 'HH24'), '23', 1, NULL))
                      "23-00",
                   COUNT (*) TOTAL
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) LOG_HISTORY,
         (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024), 2))
                      GENERATED_MB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH,
         (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024), 2))
                      DELETED_MB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES' AND DELETED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH_DEL
   WHERE LOG_HISTORY.DAY = SUM_ARCH.DAY AND SUM_ARCH.DAY = SUM_ARCH_DEL.DAY(+)
ORDER BY TO_DATE (LOG_HISTORY.DAY, 'DD/MM/YYYY');

Application Check List

Application Information Gathering
=================================

Existing Operating Units
========================

select ORGANIZATION_ID, NAME
from hr_operating_units
order by ORGANIZATION_ID;


Registered Applications
=======================

select application_id, application_short_name, basepath
from fnd_application
order by application_id;

Registered ORACLE Schemas
=========================

select fou.oracle_id, fou.oracle_username
        , fou.install_group_num, fou.read_only_flag
        , decode(nvl(du.username,' X '),' X ','No','Yes') in_dba_users
        , nvl(du.default_tablespace,'Unknown') default_tablespace
        , nvl(du.temporary_tablespace,'Unknown') temporary_tablespace
from dba_users du, fnd_oracle_userid fou
where du.username(+) = fou.oracle_username
order by 1

Product Installation Status, Version Info and Patch Level
=========================================================

select decode(nvl(a.APPLICATION_short_name,'Not Found'),
        'SQLAP','AP','SQLGL','GL','OFA','FA',
        'Not Found','id '||to_char(fpi.application_id),
        a.APPLICATION_short_name) apps,
        decode(fpi.status,'I','Installed','S','Shared',
               'N','Inactive',fpi.status) status,
        fpi.product_version,
        nvl(fpi.patch_level,'-- Not Available --') Patchset,
        to_char(fpi.last_update_date,'dd-Mon-RRRR') "Update Date"
from fnd_oracle_userid o, fnd_application a, fnd_product_installations fpi
where fpi.application_id = a.application_id(+)
  and fpi.oracle_id = o.oracle_id(+)
order by 1,2;


 Product Database Configuration
 ==============================

select decode(nvl(a.APPLICATION_short_name,'Not Found'),
        'SQLAP','AP','SQLGL','GL','OFA','FA',
        'Not Found','id '||to_char(fpi.application_id),
        a.APPLICATION_short_name) apps,
        decode(nvl(o.ORACLE_username,'Not Found'),
               'Not Found','id '||to_char(fpi.oracle_id),
               o.ORACLE_username) ORACLE_username,
        decode(fpi.db_status,'I','Installed','L','Custom','N','Not Installed',
        'S','Shared',fpi.db_status) "DB Status",
        fpi.install_group_num,
        fpi.sizing_factor,
        fpi.tablespace, fpi.index_tablespace
from fnd_oracle_userid o, fnd_application a, fnd_product_installations fpi
where fpi.application_id = a.application_id(+)
  and fpi.oracle_id = o.oracle_id(+)
order by 1,2

Adding Report to Request Group using API



/**********************************************************************
*PURPOSE: To Add a Concurrent Program to a Request Group from backend *                                 
**********************************************************************/
--

DECLARE
    l_program_short_name    VARCHAR2 (200);
    l_program_application   VARCHAR2 (200);
    l_request_group         VARCHAR2 (200);
    l_group_application     VARCHAR2 (200);
    l_check                 VARCHAR2 (2);
--
BEGIN
    --
    l_program_short_name := 'XXINVNLCDNT';
    l_program_application := 'Inventory';
    l_request_group := 'OM Concurrent Programs';
    l_group_application := 'Order Management';
    --
    --Calling API to assign concurrent program to a reqest group
    --
    apps.fnd_program.add_to_group (
        program_short_name    => l_program_short_name,
        program_application   => l_program_application,
        request_group         => l_request_group,
        group_application     => l_group_application);
    --
    COMMIT;

    --
    BEGIN
        --
        --To check whether a paramter is assigned to a Concurrent Program or not
        --
        SELECT 'Y'
          INTO l_check
          FROM fnd_request_groups       frg,
               fnd_request_group_units  frgu,
               fnd_concurrent_programs  fcp
         WHERE     frg.request_group_id = frgu.request_group_id
               AND frg.application_id = frgu.application_id
               AND frgu.request_unit_id = fcp.concurrent_program_id
               AND frgu.unit_application_id = fcp.application_id
               AND fcp.concurrent_program_name = 'XXINVNLCDNT';

        --
        DBMS_OUTPUT.put_line (
            'Adding Concurrent Program to Request Group Succeeded');
    --
    EXCEPTION
        WHEN NO_DATA_FOUND
        THEN
            DBMS_OUTPUT.put_line (
                'Adding Concurrent Program to Request Group Failed');
    END;
END;