Wednesday, May 22, 2013

Removing Credentials from a Cloned EBS Production Database


Removing Credentials from a Cloned EBS Production Database

  Step 1 - Clear All Credentials
  Step 2 - Re-establish Bootstrap Credentials
  Step 3 - Prepare Scripts for Setting Additional Passwords
  Step 4 - Assign New Passwords to All Schemas Not Managed with EBS
  Step 5 - Assign New Passwords to All Schemas Managed with EBS
  Additional Steps
  Running AutoConfig

References
Applies to:

Oracle Applications Manager - Version 11.5.9 to 12 [Release 11.5 to 1.2]
Information in this document applies to any platform.
Abstract

When cloning a Production database in Oracle E-Business Suite (EBS) it is a best practice to remove all Production account credentials in the cloned copy of the database. This will help to prevent retrieval of Production credentials, which could be used to compromise the security and integrity of the Production database.

It is ideal to complete this process as soon as possible after the database data files have been copied. At a minimum it should be completed before the database is turned over to any party less trusted than the Production database DBA team.

This document describes the steps required to remove the Production EBS database credentials, such as database user (schema) password hashes and encrypted passwords. Additionally information is provided about how to reestablish credentials in the cloned copy so that the clone may be used for functional, performance or patch application testing.

Steps from this paper should be incorporated into your database cloning process and procedures.

History

Author :
Create Date 14-Mar-2007
Update Date 11-JUL-2011
Expire Date

Details

The steps outlined in this White Paper will:
Help to ensure that Production credentials are not retrievable from a cloned copy of an EBS Production database.
Boot strap the cloned copy with enough "clone credentials" that it may be used for testing.
The steps in this document should be integrated in your database cloning process, see the "Reference" section below for documentation on cloning EBS systems for Releases 11i and 12.

The following sequence of steps will remove production account credentials from the cloned copy of the production database and reestablish new credentials in the cloned copy. All of the new accounts on the clone target will have the password "clone".

Step 1 - Clear all credentials
Step 2 - Re-establish basic accounts (for runtime: SYS,SYSTEM,APPLSYSPUB,APPLSYS,APPS + GUEST,SYSADMIN)
Step 3 - Prepare scripts for setting additional passwords
Step 4 - Assign new passwords to all database users not managed with EBS
Step 5 - Assign new passwords to all database users managed with EBS
Optional additional steps
Steps 1 through 4 are run on the database server running as the Operating System user, "oracle", using "sqlplus" connected as the "SYS" or "APPS" database user. Step 5 is run as the Operating System user "applmgr" on an application tier and uses the "FNDCPASS" command line utility. This means that steps 1 through 4 can be performed the first time the cloned database is started, i.e. before it is made accessible to the network via the database TNS listener. Step 5 is not time critical and can be performed when access to the cloned system for patch purposes is required.

All application tier processes must be stopped during this procedure.

Step 1 - Clear All Credentials

To clear all credentials on a target clone of a production database you must establish a shell environment with sufficient Oracle environment variables to successfully start "sqlplus" via the "BEQ" (bequeth) driver. If Rapid Clone has been completed successfully, then each Oracle Home should have a .env file. However, in the event you need to set the environment manually, here are the minimal environment settings: 

$ export ORACLE_SID=
$ export ORACLE_HOME=
$ export PATH=$ORACLE_HOME/bin
$ unset TWO_TASK

oracle$ sqlplus '/ as sysdba'

To clear all credentials in the cloned copy of a Production database, create and execute the following 3 SQL scripts:

REM --- step1.sql
spool  step1.lst

REM Start the database clone for the first time
startup restrict

REM Clear all production credentials from the cloned database

update SYS.user$ set
 password = translate(password,'0123456789ABCDEF','0000000000000000')
 where type#=1 and length(password) = 16
/
update APPLSYS.FND_ORACLE_USERID set
 ENCRYPTED_ORACLE_PASSWORD='INVALID'
/

update APPLSYS.FND_USER set
 ENCRYPTED_FOUNDATION_PASSWORD='INVALID',
 ENCRYPTED_USER_PASSWORD='INVALID'
/
commit;

REM Shutdown the database
shutdown
exit

REM end of script
At this point, the cloned copy of the database is free from Production credentials. The database was shut down by the script in order for the unusual way of clearing the database user (schema) passwords to take effect. You will need to restart the cloned copy of the database in preparation for steps 2, 3 and 4:

oracle$ echo startup | sqlplus '/ as sysdba'
Step 2 - Re-establish Bootstrap Credentials

The database at the moment has no credentials. Now log on as "SYS" with operation system authentication. This will allow you to establish new credentials.

oracle$ sqlplus '/ as sysdba'
Here is the script for step 2, including inline comments which explains what is done.

REM --- step2.sql
spool step2.lst

REM Set a new password for a few initial database users

alter user SYS identified by CLONE;
alter user SYSTEM identified by CLONE;
alter user APPLSYSPUB identified by CLONE;
alter user APPLSYS identified by CLONE;
alter user APPS identified by CLONE;

REM Provide boot-strap info for FNDCPASS...
update APPLSYS.FND_ORACLE_USERID set
 ENCRYPTED_ORACLE_PASSWORD='CLONE'
 where ORACLE_USERNAME = 'APPLSYSPUB'
/

update APPLSYS.FND_ORACLE_USERID set
 ENCRYPTED_ORACLE_PASSWORD='ZG' ||
 'B27F16B88242CE980EF07605EF528F9391899B09552FD89FD' ||
 'FF43E4DDFCE3972322A41FBB4DDC26DDA46A446582307D412'
 where ORACLE_USERNAME = 'APPLSYS'
/

update APPLSYS.FND_ORACLE_USERID set
 ENCRYPTED_ORACLE_PASSWORD='ZG' ||
 '6CC0BB082FF7E0078859960E852F8D123C487C024C825C0F9' ||
 'B1D0863422026EA41A6B2B5702E2299B4AC19E6C1C23333F0'
 where ORACLE_USERNAME = 'APPS'
/
commit;

REM We run as SYS, now connect as APPS to run some plsql
connect APPS/CLONE

REM Every EBS database needs a GUEST user
select APPS.fnd_web_sec.change_guest_password( 'CLONE', 'CLONE' ) "RES"
 from dual;
commit;

REM Set GUEST credential in site level profile option
set serveroutput on
declare
 dummy boolean;
begin
 dummy := APPS.FND_PROFILE.SAVE('GUEST_USER_PWD', 'GUEST/CLONE', 'SITE');
 if not dummy then
 dbms_output.put_line( 'Error setting GUEST_USER_PWD profile' );
 end if;
end;
/
commit;

REM One more time for luck (avoid session caching of profiles)
connect APPS/CLONE

REM Set SYSADMIN password
select APPS.fnd_web_sec.change_password('SYSADMIN','CLONE') "RES"
 from dual;
commit;
exit

The expected output from step 2 is as follows:

User altered.
User altered.
User altered.
User altered.
User altered.
1 row updated.
1 row updated.
1 row updated.
Commit complete.
Connected.
RES
------
Y
Commit complete.
PL/SQL procedure successfully completed.
Commit complete.
Connected.
RES
------
Y
Commit complete.

It is important to verify that no errors are reported and that the 2 returned "RES" values are both "Y", which indicates success.


ATTENTION :

It has been identified, that some Customers running into an error for the SQL PLus command
select APPS.fnd_web_sec.change_password('SYSADMIN','CLONE') "RES" from dual;
In this case, please check Note 1350776.1 for the solution, before your are going ahead with the next steps !

Now we have completed establishing a set of bootstrap EBS credentials in the database.



Step 3 - Prepare Scripts for Setting Additional Passwords

In this step scripts are prepared to assign passwords to the other database users which were disabled in Step 1. Dynamically generated scripts are used to accomplish this because the set of database users may differ between instances of EBS. Create the script below and run it as the Operating System user "oracle":

$ sqlplus '/ as sysdba'

The comments in script below explains what is done in step 3.

REM --- step3.sql

REM Prepare SQL and SHELL scripts to set more passwords later
spool step3.lst

REM Generate a sql script to set password for db users not managed with EBS

select 'alter user "'|| USERNAME ||'" identified by CLONE; '
 from SYS.DBA_USERS
 where USERNAME not in (select ORACLE_USERNAME from APPLSYS.FND_ORACLE_USERID)
 and USERNAME not in ('SYS','SYSTEM');

REM Generate a shell script to set password for all base product schemas

select 'FNDCPASS apps/clone 0 Y system/clone ALLORACLE clone' from dual;

REM Generate a shell script to set password for non-EBS db users managed with EBS

select 'FNDCPASS apps/clone 0 Y system/clone ORACLE "' ||
 replace(ORACLE_USERNAME,'$','\$') || '" clone'
 from APPLSYS.FND_ORACLE_USERID
 where READ_ONLY_FLAG = 'X'
 and ORACLE_USERNAME in (select USERNAME from SYS.DBA_USERS);

REM Generate a shell script to set password for APPS/APPLSYS/APPM_mrc db users

select 'FNDCPASS apps/clone 0 Y system/clone SYSTEM APPLSYS clone' from dual;

REM Generate scripts for steps 4 & 5
spool off

HOST grep '^alter user ' step3.lst > dbusers4.sql
HOST grep '^FNDCPASS ' step3.lst > dbusers5.sh

exit

REM End of Script
NOTE: The script above calls the UNIX command "grep" to extract 2 sets of lines from the step3.lst spool file. If you are running Windows, the shell redirection will fail when attempted from within sqlplus. You can perform the failed step by going to a command prompt (using the HOST command from sqlplus). If you have your MKS environment set, then you can use the "grep" syntax or alternatively you can use the below syntax from a Windows command (cmd.exe) prompt.

# alternative commands for extracting sql and shell commands from step3.lst
C:\ORACLE\Clone> findstr "^alter user " step3.lst > dbusers4.sql
C:\ORACLE\Clone> findstr "^FNDCPASS " step3.lst > dbusers5.cmd
Step 4 - Assign New Passwords to All Schemas Not Managed with EBS

This Step runs the SQL script, "dbusers4.sql", generated in Step 3.

Sample content of "dbusers4.sql" listed below for illustration purposes only, you must run the one you generated on your system.


NOTE:  "dbusers4.sql", for example purposes only!
alter user "OLAPSYS" identified by CLONE;
 ...
alter user "MDSYS" identified by CLONE;
alter user "ORDPLUGINS" identified by CLONE;
alter user "ORDSYS" identified by CLONE;
alter user "DBSNMP" identified by CLONE;
alter user "OUTLN" identified by CLONE;
alter user "AD_MONITOR" identified by CLONE;
alter user "EM_MONITOR" identified by CLONE;
Note: Prior to running your script, you should review the contents of the script for any obvious problems or syntax errors- this is good advice for any dynamically-created SQL scripts.
Connect as "SYSDBA":

$ sqlplus "/ as sysdba"

Now run the "dbusers4.sql" file:
SQL> spool step4.lst
SQL> start dbusers4.sql
SQL> exit

The output spool file should show many output lines stating "User altered.". No error messages (ORA-nnnnn) should appear.

At this point, the database should be started and running. Stop and restart the database at this time. To ensure that the application tier code can access the database for  Step 5, you must also ensure that the database TNS-listener service is running.

$ echo shutdown | sqlplus "/ as sysdba"
$ echo startup | sqlplus "/ as sysdba"
$ lsnrctl start
Step 5 - Assign New Passwords to All Schemas Managed with EBS

This step uses the "FNDCPASS" command to set the passwords for all the EBS managed schemas and all the base product schemas. The "FNDCPASS" must be run from an application tier node.(Any node with an APPL_TOP file system.)

You will need to locate and copy the "dbusers5.sh" script from the directory where it was created in Step 3. Again, as with any dynamcially generated scripts that you run on your system, you should review the contents of the file before running it.

Note for Windows users: In the unlikely event that any of the usernames contain the dollar sign "$" it has been escaped by prefixing it by a backslash "\"; on Windows the backslash should be removed.

To run "FNDCPASS" you also need a number of environment variables set, at a minimum ensure that:

"FNDCPASS" is in the "$PATH" ("$ which FNDCPASS" will tell you if it is.)
The "ORACLE_HOME" environment variable points to the "Tools" ORACLE_HOME (8.0.6 on 11i, 10.1.2 on R12)
The "TWO_TASK" environment variable is set to a value that can be resolved via the "$TNS_ADMIN/tnsnames.ora file", in order to access the clone target database.
# Verify that the Oracle client environment is set to correct database (as "applmgr" OS user)

applmgr$ sqlplus -s apps/clone < select SYSDATE,NAME from v\$DATABASE;
EOF

SYSDATE NAME
--------- ---------
25-JUL-07 PRD12

applmgr$ mkdir ~/s5 ; cd ~/s5 # create new directory to hold output files
applmgr$ sh dbusers5.sh # Run the FNDCPASS shell script

The following is sample content of a "dbusers5.sh" file is listed below for illustration purposes only, run the one you generated on your system.

NOTE: This "dbusers5.sh" is for example only!

 FNDCPASS apps/clone 0 Y system/clone ALLORACLE clone
 FNDCPASS apps/clone 0 Y system/clone ORACLE "OWAPUB" clone
 FNDCPASS apps/clone 0 Y system/clone ORACLE "ODM" clone
 FNDCPASS apps/clone 0 Y system/clone ORACLE "CTXSYS" clone
 FNDCPASS apps/clone 0 Y system/clone SYSTEM APPLSYS clone
Each run of "FNDCPASS" will generate output an output/log file in the current working directory, you should review these log files (example "L2763902.log") for errors.
NOTE: If your version of  the "FNDCPASS" utility does not support the "ALLORACLE" mode, see "Q5" in the "Discussion" section below.

To verify that you have assigned passwords to all the database users, run the following query and ensure that it does not return any rows:
SQL> select USERNAME,PASSWORD from DBA_USERS where PASSWORD='0000000000000000';

This concludes the clearing and re-establishment of account credentials from a cloned database. Please see the following 2 steps "Additional Steps" and "Running Autoconfig" before attempting to use the system.
Additional Steps

What remains to be done is to set new passwords for additional applications users or the creation of new test users, depending on your needs. Changing passwords for applications users can be done using the "Define User" form (logged on as "SYSADMIN/CLONE") or by running "FNDCPASS" with the below syntax from an "applmgr" applications shell environment.

applmgr$ FNDCPASS apps/clone 0 Y system/clone USER
You may also wish to change the passwords to something other than "clone". You can use modified versions of the scripts in this note and you should reference the security best practices document for advice on changing passwords for an E-Business Suite system, see the References section below.

Running AutoConfig

Before you can actually start and access the cloned EBS system from the Application, a number of other configuration items, such as system Profile Options, most likely need to be changed in the cloned environment. Items to change typically include:

IP addresses, hostnames and port numbers
Profiles containing hostnames and port numbers
Web interface URLs
Hostnames of external services (mail, print, SSO)
The cloning notes, listed in the "Reference" section below, will provide you with information on how to run AutoConfig. Running AutoConfig is a requirement and it must be run on all tiers of the cloned system to propagate password changes and other changed settings into Autoconfig-managed files.

Prior to running AutoConfig ensure that the AutoConfig Context file contains the new "GUEST" password (Context variable "s_guest_pass") and the new password for "APPLSYSPUB" (Context variable "s_gwyuid_pass").
Password for Context Variable New Value
APPLSYSPUB s_gwyuid_pass CLONE
GUEST s_guest_pass CLONE


Friday, May 10, 2013

Index rebuilding


SELECT * FROM dba_objects WHERE object_id ='696249'; -- this query will give us the corrupt index id

select TABLE_NAME,INDEX_NAME,COLUMN_NAME,COLUMN_POSITION from dba_ind_columns
where TABLE_NAME in ('FND_CONCURRENT_REQUESTS')
order by 1,2,COLUMN_POSITION;

=====================================================================================================================
Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N1 validate structure online; -- Idex Analyzed


select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N1','APPLSYS') from dual;

--- double click the output

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N1" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("REQUESTED_BY",

"ACTUAL_COMPLETION_DATE")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"


drop index APPLSYS.FND_CONCURRENT_REQUESTS_N1;  -- type commit once


CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N1" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("REQUESTED_BY",

"ACTUAL_COMPLETION_DATE")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"
 
=====================================================================================================================



Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N1 validate structure online; -- Idex Analyzed

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N2','APPLSYS') from dual;

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N2" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("STATUS_CODE")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

---------------------------------------------------------------------------------
Error - ORA-00054: resource busy and acquire with NOWAIT specified.
conn as sysdba
show parameter DDL_LOCK_TIMEOUT

SQL>alter system set ddl_lock_timeout = 100 ;

Session altered.

Now in the first session issue commit.
SQL> commit;

--------------------------------------------------------------------------------
Step 3

drop index APPLSYS.FND_CONCURRENT_REQUESTS_N2;

Step 4

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N2" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("STATUS_CODE")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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


Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N3 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N3','APPLSYS') from dual;

drop index APPLSYS.FND_CONCURRENT_REQUESTS_N3;

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N3" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("PARENT_REQUEST_ID")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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

Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N4 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N4','APPLSYS') from dual;

drop index APPLSYS.FND_CONCURRENT_REQUESTS_N4;

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N4" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("PRIORITY_REQUEST_ID")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX" ;

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

Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N5 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N5','APPLSYS') from dual;

drop index APPLSYS.FND_CONCURRENT_REQUESTS_N5;

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N5" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("DESCRIPTION")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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

Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N6 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N6','APPLSYS') from dual;

drop index APPLSYS.FND_CONCURRENT_REQUESTS_N6;

  CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N6" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("CONCURRENT_PROGRAM_ID",

"PROGRAM_APPLICATION_ID")
  PCTFREE 10 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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

Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N7 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N7','APPLSYS') from dual;

drop index APPLSYS.FND_CONCURRENT_REQUESTS_N7;

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N7" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("PHASE_CODE", "STATUS_CODE")
  PCTFREE 10 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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

Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N8 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N8','APPLSYS') from dual;


drop index APPLSYS.FND_CONCURRENT_REQUESTS_N8;


CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N8" ON "APPLSYS"."FND_CONCURRENT_REQUESTS"

("RESPONSIBILITY_APPLICATION_ID", "RESPONSIBILITY_ID")
  PCTFREE 10 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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


Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N9 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N9','APPLSYS') from dual;


drop index APPLSYS.FND_CONCURRENT_REQUESTS_N9;

CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N9" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("OPS_INSTANCE", "STATUS_CODE")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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


Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N10 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N10','APPLSYS') from dual;


drop index APPLSYS.FND_CONCURRENT_REQUESTS_N10;


  CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N10" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("CD_ID")
  PCTFREE 10 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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


Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_N11 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_N11','APPLSYS') from dual;


drop index APPLSYS.FND_CONCURRENT_REQUESTS_N11;


CREATE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_N11" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("REQUEST_DATE")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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


Analyze Index APPLSYS.FND_CONCURRENT_REQUESTS_U1 validate structure online;

select dbms_metadata.get_ddl('INDEX','FND_CONCURRENT_REQUESTS_U1','APPLSYS') from dual;



drop index APPLSYS.FND_CONCURRENT_REQUESTS_U1;


CREATE UNIQUE INDEX "APPLSYS"."FND_CONCURRENT_REQUESTS_U1" ON "APPLSYS"."FND_CONCURRENT_REQUESTS" ("REQUEST_ID")
  PCTFREE 0 INITRANS 11 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
  TABLESPACE "APPS_TS_TX_IDX"

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

ERROR at line 1:
ORA-08102: index key not found, obj# 696249, file 406, block 290081 (2)

Wednesday, May 1, 2013

Concurrent Request Scripts


Concurrent Request Scripts

****HISTORY OF CONCURRENT REQUEST - SCRIPT (PROGRAM WISE) *****

set pagesize 200
set linesize 200
col "Who submitted" for a25
col "Status" for a10
col "Parameters" for a20
col USER_CONCURRENT_PROGRAM_NAME for a42
SELECT distinct t.user_concurrent_program_name,
r.REQUEST_ID,
to_char(r.ACTUAL_START_DATE,'dd-mm-yy hh24:mi:ss') "Started at",
to_char(r.ACTUAL_COMPLETION_DATE,'dd-mm-yy hh24:mi:ss') "Completed at",
decode(r.PHASE_CODE,'C','Completed','I','Inactive','P ','Pending','R','Running','NA') phasecode,
decode(r.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', 'S','Suspended', 'T','Terminating', 'U','Disabled', 'W','Paused', 'X','Terminated', 'Z','Waiting') "Status",r.argument_text "Parameters",substr(u.description,1,25) "Who submitted",round(((nvl(v.actual_completion_date,sysdate)-v.actual_start_date)*24*60)) Etime
FROM
apps.fnd_concurrent_requests r ,
apps.fnd_concurrent_programs p ,
apps.fnd_concurrent_programs_tl t,
apps.fnd_user u, apps.fnd_conc_req_summary_v v
WHERE
r.CONCURRENT_PROGRAM_ID = p.CONCURRENT_PROGRAM_ID
AND r.actual_start_date >= (sysdate-30)
--AND r.requested_by=22378
AND   r.PROGRAM_APPLICATION_ID = p.APPLICATION_ID
AND t.concurrent_program_id=r.concurrent_program_id
AND r.REQUESTED_BY=u.user_id
AND v.request_id=r.request_id
--AND r.request_id ='2260046' in ('13829387','13850423')
and t.user_concurrent_program_name like '%%'
order by to_char(r.ACTUAL_COMPLETION_DATE,'dd-mm-yy hh24:mi:ss');


 *** Requests completion date details ***

SELECT request_id, TO_CHAR( request_date, 'DD-MON-YYYY HH24:MI:SS' )
request_date, TO_CHAR( requested_start_date,'DD-MON-YYYY HH24:MI:SS' )
requested_start_date, TO_CHAR( actual_start_date, 'DD-MON-YYYY HH24:MI:SS' )
actual_start_date, TO_CHAR( actual_completion_date, 'DD-MON-YYYY HH24:MI:SS' )
actual_completion_date, TO_CHAR( sysdate, 'DD-MON-YYYY HH24:MI:SS' )
current_date, ROUND( ( NVL( actual_completion_date, sysdate ) - actual_start_date ) * 24, 2 ) duration
FROM fnd_concurrent_requests
WHERE request_id = TO_NUMBER('&p_request_id');

*** Reqid_from sid **

SELECT a.request_id, a.PHASE_CODE, a.STATUS_CODE,
d.sid as Oracle_SID,
d.serial#,
d.osuser,
d.process,
c.SPID as OS_Process_ID
FROM apps.fnd_concurrent_requests a,
apps.fnd_concurrent_processes b,
gv$process c,
gv$session d
WHERE a.controlling_manager = b.concurrent_process_id
AND c.pid = b.oracle_process_id
AND b.session_id=d.audsid AND a.PHASE_CODE='R' AND a.STATUS_CODE='R'
AND d.sid = &SID;

How to Determine Which Manager Ran a Specific Concurrent Request?

col USER_CONCURRENT_QUEUE_NAME for a100
select b.USER_CONCURRENT_QUEUE_NAME from fnd_concurrent_processes a,
fnd_concurrent_queues_vl b, fnd_concurrent_requests c
where a.CONCURRENT_QUEUE_ID = b.CONCURRENT_QUEUE_ID
and a.CONCURRENT_PROCESS_ID = c.controlling_manager
and c.request_id = '&conc_reqid';


Concurrent request status for a given sid?

col MODULE for a20
col OSUSER for a10
col USERNAME for a10
set num 10
col MACHINE for a20
set lines 200
col SCHEMANAME for a10
select s.INST_ID,s.sid,s.serial#,p.spid os_pid,s.status, s.osuser,s.username, s.MACHINE,s.MODULE, s.SCHEMANAME,
s.action from gv$session s, gv$process p WHERE s.paddr = p.addr and s.sid = '&oracle_sid';


Find out request id from Oracle_Process Id:

select REQUEST_ID,ORACLE_PROCESS_ID,OS_PROCESS_Id from apps.fnd_concurrent_requests where ORACLE_PROCESS_ID='&a';

To find concurrent program name,phase code,status code for a given request id?

SELECT request_id, user_concurrent_program_name, DECODE(phase_code,'C','Completed',phase_code) phase_code, DECODE(status_code,'D', 'Cancelled' ,
'E', 'Error' , 'G', 'Warning', 'H','On Hold' , 'T', 'Terminating', 'M', 'No Manager' , 'X', 'Terminated',  'C', 'Normal', status_code) status_code, to_char(actual_start_date,'dd-mon-yy:hh24:mi:ss') Start_Date, to_char(actual_completion_date,'dd-mon-yy:hh24:mi:ss'), completion_text FROM apps.fnd_conc_req_summary_v WHERE request_id = '&req_id' ORDER BY 6 DESC;

To find the sql query for a given concurrent request sid?

select sid,sql_text from gv$session ses, gv$sqlarea sql where
ses.sql_hash_value = sql.hash_value(+) and ses.sql_address = sql.address(+) and ses.sid='&oracle_sid'
/

To find child requests for Parent request id.

set lines 200
col USER_CONCURRENT_PROGRAM_NAME for a40
col PHASE_CODE for a10
col STATUS_CODE for a10
col COMPLETION_TEXT for a20
SELECT sum.request_id,req.PARENT_REQUEST_ID,sum.user_concurrent_program_name, DECODE(sum.phase_code,'C','Completed',sum.phase_code) phase_code, DECODE(sum.status_code,'D', 'Cancelled' ,
'E', 'Error' , 'G', 'Warning', 'H','On Hold' , 'T', 'Terminating', 'M', 'No Manager' , 'X', 'Terminated',  'C', 'Normal', sum.status_code) status_code, sum.actual_start_date, sum.actual_completion_date, sum.completion_text FROM apps.fnd_conc_req_summary_v sum, apps.fnd_concurrent_requests req where  req.request_id=sum.request_id and req.PARENT_REQUEST_ID = '&parent_concurrent_request_id';


set col os_process_id for 99
select HAS_SUB_REQUEST, is_SUB_REQUEST, parent_request_id, ORACLE_PROCESS_ID, ORACLE_SESSION_ID, OS_PROCESS_ID from fnd_concurrent_requests where request_id= '&Req_ID' ;


Cancelling Concurrent request :

--By request id
update fnd_concurrent_requests
set status_code='D', phase_code='C'
where request_id=&req_id;

--by program_id
update fnd_concurrent_requests
set status_code='D', phase_code='C'
where CONCURRENT_PROGRAM_ID=&prg_id;

To terminate the all concurrent requests using by Module wise.

select 'ALTER SYSTEM KILL SESSION '''||sid||','||serial#||''' immediate;' from gv$session where MODULE like 'GLPREV';

History of concurrent requests which are error out

SELECT a.request_id "Req Id"
,a.phase_code,a.status_code
, actual_start_date
, actual_completion_date
,c.concurrent_program_name || ': ' || ctl.user_concurrent_program_name "program"
FROM APPLSYS.fnd_Concurrent_requests a,APPLSYS.fnd_concurrent_processes b
,applsys.fnd_concurrent_queues q
,APPLSYS.fnd_concurrent_programs c
,APPLSYS.fnd_concurrent_programs_tl ctl
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 a.status_code = 'E'
AND a.phase_code = 'C'
AND actual_start_date > sysdate - 2
AND b.queue_application_id = q.application_id
AND b.concurrent_queue_id = q.concurrent_queue_id
AND ctl.concurrent_program_id = c.concurrent_program_id
AND ctl.LANGUAGE = 'US'
ORDER BY 5 DESC;

***** Find out Concurrent Program which enable with trace****

col User_Program_Name for a40
col Last_Updated_By for a30
col DESCRIPTION for a30
SELECT A.CONCURRENT_PROGRAM_NAME "Program_Name",
SUBSTR(A.USER_CONCURRENT_PROGRAM_NAME,1,40) "User_Program_Name",
SUBSTR(B.USER_NAME,1,15) "Last_Updated_By",
SUBSTR(B.DESCRIPTION,1,25) DESCRIPTION
FROM APPS.FND_CONCURRENT_PROGRAMS_VL A, APPLSYS.FND_USER B
WHERE A.ENABLE_TRACE='Y'
AND A.LAST_UPDATED_BY=B.USER_ID;


***Concurrent Program count under QUEUE ***

col  "program name" format a55;
col "name" format  a17;
col "queue name" format a15
col "statuscode" format a3
select user_CONCURRENT_PROGRAM_NAME "PROGRAM NAME",concurrent_queue_name "QUEUE NAME", priority,decode(phase_code,'P','Pending') "PHASE",
decode(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','S',
'Suspended','T','Terminating','U','Disabled','W','Paused','X','Terminated','Z','Waiting') "
NAME", status_code,count(*) from
fnd_concurrent_worker_requests
where  phase_code='P' and hold_flag!='Y'
and requested_start_date<=sysdate
and concurrent_queue_name<> 'FNDCRM'
and concurrent_queue_name<> 'GEMSPS'
group by
user_CONCURRENT_PROGRAM_NAME,
concurrent_queue_name,priority,phase_code,status_code
order by count(*) desc
/

***Lists the Manager Names with the No. of Requests in Pending/Running ***

col "USER_CONCURRENT_QUEUE_NAME" format a40;

SELECT a.USER_CONCURRENT_QUEUE_NAME,a.MAX_PROCESSES,
sum(decode(b.PHASE_CODE,'P',decode(b.STATUS_CODE,'Q',1,0),0)) Pending_Standby,
sum(decode(b.PHASE_CODE,'P',decode(b.STATUS_CODE,'I',1,0),0)) Pending_Normal,
sum(decode(b.PHASE_CODE,'R',decode(b.STATUS_CODE,'R',1,0),0)) Running_Normal
FROM FND_CONCURRENT_QUEUES_VL a, FND_CONCURRENT_WORKER_REQUESTS b
where a.concurrent_queue_id = b.concurrent_queue_id
AND b.Requested_Start_Date<=SYSDATE
GROUP BY a.USER_CONCURRENT_QUEUE_NAME,a.MAX_PROCESSES;


*** Concurrent QUEUE Details ***


set echo off
set linesize 130
set serveroutput on size 50000
set feed off
set veri off
DECLARE
running_count NUMBER := 0;
pending_count NUMBER := 0;
crm_pend_count NUMBER := 0;
--get the list of all conc managers and max worker and running workers
CURSOR conc_que IS
SELECT concurrent_queue_id,
concurrent_queue_name,
user_concurrent_queue_name,
max_processes,
running_processes
FROM apps.fnd_concurrent_queues_vl
WHERE enabled_flag='Y' and
concurrent_queue_name not like 'XDP%' and
concurrent_queue_name not like 'IEU%' and
concurrent_queue_name not in ('ARTAXMGR','PASMGR') ;
BEGIN
DBMS_OUTPUT.PUT_LINE('====================================================================================================');
DBMS_OUTPUT.PUT_LINE('QueueID'||' '||'Queue          '||
'Concurrent Queue Name               '||' '||'MAX '||' '||'RUN '||' '||
'Running '||' '||'Pending   '||' '||'In CRM');
DBMS_OUTPUT.PUT_LINE('====================================================================================================');
FOR i IN conc_que
LOOP
--for each manager get the number of pending and running requests in each queue
SELECT /*+ RULE */ nvl(sum(decode(phase_code, 'R', 1, 0)), 0),
nvl(sum(decode(phase_code, 'P', 1, 0)), 0)
INTO running_count, pending_count
FROM fnd_concurrent_worker_requests
WHERE
requested_start_date <= sysdate
and concurrent_queue_id = i.concurrent_queue_id
AND hold_flag != 'Y';
--for each manager get the list of requests pending due to conflicts in each manager
SELECT /*+ RULE */ count(1)
INTO crm_pend_count
FROM apps.fnd_concurrent_worker_requests a
WHERE concurrent_queue_id = 4
AND hold_flag != 'Y'
AND requested_start_date <= sysdate
AND exists (
SELECT 'x'
FROM apps.fnd_concurrent_worker_requests b
WHERE a.request_id=b.request_id
and concurrent_queue_id = i.concurrent_queue_id
AND hold_flag != 'Y'
AND requested_start_date <= sysdate);
--print the output by joining the outputs of manager counts,
DBMS_OUTPUT.PUT_LINE(
rpad(i.concurrent_queue_id,8,'_')||
rpad(i.concurrent_queue_name,15, ' ')||
rpad(i.user_concurrent_queue_name,40,' ')||
rpad(i.max_processes,6,' ')||
rpad(i.running_processes,6,' ')||
rpad(running_count,10,' ')||
rpad(pending_count,10,' ')||
rpad(crm_pend_count,10,' '));
--DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------------------------------------------------');
END LOOP;
DBMS_OUTPUT.PUT_LINE('====================================================================================================');
END;
/
set verify on
set echo on

Friday, April 26, 2013

WARNING: Heavy Swapping Observed On System In Last 5 Mins.After upgrade to 11.2.0.3


WARNING: Heavy Swapping Observed On System In Last 5 Mins.After upgrade to 11.2.0.3


Oracle Database - Enterprise Edition - Version 11.2.0.3 to 11.2.0.3 [Release 11.2]
Information in this document applies to any platform.
Goal

The document explains why you may see the following WARNING in the alert log after upgrading to 11.2.0.3.

Wed Apr 25 10:10:50 2012
WARNING: Heavy swapping observed on system in last 5 mins.
pct of memory swapped in [7.16%] pct of memory swapped out [0.56%].
Please make sure there is no memory pressure and the SGA and PGA
are configured correctly. Look at DBRM trace file for more details.
Fix

The reason you may now see these informational messages in the alert is due to the fact that in 11.2.0.3 an enhancement fix was included for unpublished
Bug 10220118 - Print warning to alert log when system is swapping (Doc ID 10220118.8)

Please refer to
Note 10220118.8 - Bug 10220118 - Print warning to alert log when system is swapping



Description

  This fix is really an enhancement.
  With this fix a warning is printed to the alert log (and DBRM trace)
  if excessive swapping is observed on the system.
  The warning will not be printed more than once per hour.
 

The same issues could have been happening on 11.2.0.2 but they simply would not have been reported.
There is no cause for concern and we suggest that the databases are just monitored as usual.

If you look in the alert log, you will see that the message does not happen every hour.
If SWAP was causing any serious issue we could also see ORA-4031/ORA-4030 and would then be able to use the DBRM trace in conjunction with obtaining further diagnostics.



- If your Platform is IBM-AIX then This is not the only reason for this alert log file. There is a known port-specific bug for IBM AIX on POWER Systems (64-bit):

Bug 14731911 : FALSE SWAP WARNING MESSAGES PRINTED TO ALERT.LOG ON AIX
Base Bug 11801934 : WRONG PAGE-IN AND PAGE-OUT OS VM STATS IN AIX.

Solution for AIX

Apply patch 11801934 if available for your platform or request a patch to Oracle Support in a new Service Request.



Wednesday, April 3, 2013

Fixing Duplicate Sales Order Transactions In MTI, MMTT and MMT



Inventory Standard Datafix Instruction #17: Fixing Duplicate Sales Order Transactions In MTI, MMTT and MMT

In this Document
Goal
Fix
          A - Identification Scripts.
          Identify
          Symptoms
          Symptom List
          B - Verifying your File Versions.
          C -  Root Cause Analysis.
          1. Duplicate Transactions After One In Batch Failed
          2. New Root- Causes?
          D - Datafix.
          1. Identify data.
          2. Backup data.
          3. Run the datafix script.
          4- Check the data.
References
Applies to:

Oracle Inventory Management - Version 11.5.10.2 and later
Information in this document applies to any platform.
Error occurred while relieving reservations: INV_RSV_RLF_FAILED


Goal



This document provides detailed instructions for removing duplicate sales order transactions between the various inventory transaction tables:  Transaction interface (MTL_TRANSACTIONS_INTERFACE MTI), pending transactions (MTL_MATERIAL_TRANSACTIONS_TEMP MMTT) and the transaction history (MTL_MATERIAL_TRANSACTIONS MMTT).  The scripts focus on sales orders and have no affect on inventory transactions like miscellaneous receipts or WIP transactions. Also this document will show all the available information regarding the Root Cause of this data corruption.

Please follow up this document in the following order:
A. Identification Scripts: This will confirm if you are having this data corruption.
B. Verifying your file versions: This will allow you and support to confirm if you are already in a known fixed version.
C. Root Cause Analysis. It shows all the relevant information about this issue Root Cause.
D. Datafix Intructions. It will provide steps for fixing the data corruption.

Fix

A - Identification Scripts.

Identify

Please run the identification script (INV17-ident.sql) uploaded into this document.

PROMPT
PROMPT INV17-ident.sql
PROMPT From Note:1472074.1 Inventory Standard Datafix Instruction #17:
PROMPT ... Fixing Duplicate Sales Order Transactions In MTI, MMTT and MMT
PROMPT The script is based on details in Bug 4286083.
PROMPT The sql identifies if the transactions are duplicate transactions
PROMPT in the inventory transactions tables. 
PROMPT The sql is ONLY valid for Order Management duplicate transactions
PROMPT and will NOT identifyother sources like WIP jobs or inventory aliases.
PROMPT

PROMPT a. MMT vs. MTI
PROMPT Count Duplicates Between Historical transactions (MMT) vs. Interface transactions (MTI)
SELECT count(*)
FROM mtl_material_transactions b, mtl_transactions_interface a
WHERE a.picking_line_id = b.picking_line_id
AND a.trx_source_line_id = b.trx_source_line_id
AND a.inventory_item_id = b.inventory_item_id
AND b.transaction_type_id = a.transaction_type_id
AND b.transaction_source_type_id in (2,8)
AND b.picking_line_id is not null ;

PROMPT b. MMTT vs. MTI
PROMPT Count Duplicates Between Pending transactions (MMTT) vs. Interface transactions (MTI)
SELECT count(*)
FROM mtl_material_transactions_temp b,  mtl_transactions_interface a
WHERE a.picking_line_id = b.picking_line_id
AND a.trx_source_line_id = b.trx_source_line_id
AND a.inventory_item_id = b.inventory_item_id
AND b.transaction_type_id = a.transaction_type_id
AND b.transaction_source_type_id in (2,8)
AND b.picking_line_id is not null ;

PROMPT c. MMT vs. MMTT:
PROMPT Count Duplicates Between Historical transactions (MMT) vs. Pending transactions (MMTT)
SELECT count(*)
FROM mtl_material_transactions b,  mtl_material_transactions_temp a
WHERE a.picking_line_id = b.picking_line_id
AND a.trx_source_line_id = b.trx_source_line_id
AND a.inventory_item_id = b.inventory_item_id
AND b.transaction_type_id = a.transaction_type_id
AND b.transaction_source_type_id in ( 2,8)
AND b.picking_line_id is not null;
Symptoms

The symptoms for this issue can be similar to Note:1471606.1 Inventory Standard Datafix Instruction #16: Fixing Stuck transaction with 'Error Occurred While Relieving Reservations'. In addition, you might find transactions preventing period close when the records are actually duplicates that can be deleted.

Symptom List

Here are some common observations, symptoms and errors that identify this issue.

Action Result
Close period   The period cannot close due to pending transactions.
Pick release   Pick release backorders line
Transact or allocate move order    
Transact or allocate fails. Receive an error:
The material sourcing process failed to create picking suggestions for line

View Material Workbench Available Quantity       Onhand quantity is MORE than available quantity but you have no current move orders or reservations.
Ship confirm  Onhand quantity is MORE than available quantity but you have no current move orders or reservations.
Ship confirm 
Ship confirm fails. Receive an error:
An error occurred while relieving reservations
(Code: INV_RSV_RLF_FAILED)



B - Verifying your File Versions.

Execute the following from your server for getting key file versions of the following files:

TrxProcessor.java
BaseTransaction.java
INVTXMGB.pls
INVTRXWB.pls

You can use SQL like the following:

set serveroutput on
PROMPT : - - - - : TrxProcessor.java : - - - - :
exec fnd_aolj_util.getClassVersionfromDB('oracle.apps.inv.transaction.server.TrxProcessor');

PROMPT : - - - - : BaseTransaction.java : - - - - :
exec fnd_aolj_util.getclassversionfromdb('oracle.apps.inv.transaction.server.BaseTransaction');

PROMPT : - - - - : INVTXMGB.pls : - - - - :
SELECT text FROM dba_source
 WHERE name = 'INV_TXN_MANAGER_PUB'
    AND line < 3;

PROMPT : - - - - : INVTRXWB.pls : - - - - :
SELECT text FROM dba_source
 WHERE name = 'INV_LPN_TRX_PUB'
    AND line < 3;
Or review the AppsCheck output from Note 276207.1 for application parameter: Inventory

C -  Root Cause Analysis.

The following Root Causes have been identified at this moment.

1. Duplicate Transactions After One In Batch Failed

While processing transactions through open interface, if batch id is populated and if the first row in a batch fails then the previous batch, which got successfully processed was not getting deleted from pending transactions table and open interface table.                                                         

Release         Bug     Patch  Filename       Version
R11.5.8         Bug 3024133  Patch 2640488         BaseTransaction.java          115.111.11580.5+
R11.5.10       Bug 5710072  Patch 5935177         BaseTransaction.java          115.235.115100.36+
R12.0.x         Bug 5748351  Patch 6728000:R12.0.6       TrxProcessor.java
BaseTransaction.java
INVTXMGB.pls
INVTRXWB.pls          120.10.12000000.4+
120.39.12000000.2+
120.25.12000000.3+
120.34.12000000.11+


2. New Root- Causes?

We are always looking for additional reasons for data issues. If you are on a higher version or can replicate the issue for a different situation, please log a service request.

IMPORTANT: If you are in higher file version please log a SR with Support Services or update the existing one providing this note number and the script output from section A and the file versions from section B and we will add your SR to the Internal Root Cause Analysis (RCA) Bug 8857390 for Release 12 and RCA Bug 9270328 for release 11i.

Also, if you are in higher file versions and you can replicate this issue, we would like to hear more on how you do it and then we can log a new bug focusing on fixing the issue. Please log a SR with Support Services or update the existing one with replication steps.



D - Datafix.

Follow the steps below to fix the data. The following temporary views are created to facilitate the backup table creation and the datafix. You can drop these views later if desired:

View   Explanation
mmt_mti_records_v  Compare the historical transactions to the interface transactions.
mmtt_mti_records_v Compare the pending transactions to the interface transactions.
mmt_mmtt_records_v        Compare the historical transactions to the pending transactions.


1. Identify data.

Please run the identification script (INV17-ident.sql) uploaded into this document.

2. Backup data.

Run the backup script (INV17-backup.sql). The backup script creates the following tables: mti_dup_backup, msni_dup_backup, mtli_dup_backup, mti_dup_backup_mmtt, msni_dup_backup_mmtt, mtli_dup_backup_mmtt, mmtt_dup_backup, msnt_dup_backup, mtlt_dup_backup

3. Run the datafix script.

Run the datafix script (INV17-datafix.sql) uploaded into the note. This will fix the data by removing duplicate transactions.

Note: The script DOES commit.
4- Check the data.

Check if your data has been corrected and you are not experiencing problems. You can rerun the script from the identification section:  (INV17-ident.sql) uploaded into this document.

Note: You may also need to submit any good, remaining transactions. For example, you could check for unprocessed records, resubmit any you can via the form, rerun the inventory manager, rerun trip stop, etc. See Note:1069492.1 Resolving Period Close Pending Transaction R12 that includes SQL to update transactions as well.

For example, this SQL could resubmit unprocessed pending transactions that you cannot see via the form because they are transaction mode 8:

update mtl_material_transactions_temp
 set process_flag = 'Y',
 lock_flag = 'N',
 transaction_mode = 3,
 error_code = NULL,
 error_explanation = NULL
where process_flag in ('Y','E')


References

NOTE:568012.1 - FAQ: Inventory Standard Datafixes
NOTE:280400.1 - Stuck Transaction Interface Sales Order Issues: An Error Occured While Relieving Reservations (INV_RSV_RLF_FAILED)
NOTE:294391.1 - What do the transaction mode (like transaction_mode = 8) numbers mean in the pending transactions table (MTL_MATERIAL_TRANSACTIONS_TEMP)?



Attachments


Fixing Duplicate Sales Order Transactions In MTI, MMTT and MMT



Inventory Standard Datafix Instruction #17: Fixing Duplicate Sales Order Transactions In MTI, MMTT and MMT

In this Document
Goal
Fix
          A - Identification Scripts.
          Identify
          Symptoms
          Symptom List
          B - Verifying your File Versions.
          C -  Root Cause Analysis.
          1. Duplicate Transactions After One In Batch Failed
          2. New Root- Causes?
          D - Datafix.
          1. Identify data.
          2. Backup data.
          3. Run the datafix script.
          4- Check the data.
References
Applies to:

Oracle Inventory Management - Version 11.5.10.2 and later
Information in this document applies to any platform.
Error occurred while relieving reservations: INV_RSV_RLF_FAILED


Goal



This document provides detailed instructions for removing duplicate sales order transactions between the various inventory transaction tables:  Transaction interface (MTL_TRANSACTIONS_INTERFACE MTI), pending transactions (MTL_MATERIAL_TRANSACTIONS_TEMP MMTT) and the transaction history (MTL_MATERIAL_TRANSACTIONS MMTT).  The scripts focus on sales orders and have no affect on inventory transactions like miscellaneous receipts or WIP transactions. Also this document will show all the available information regarding the Root Cause of this data corruption.

Please follow up this document in the following order:
A. Identification Scripts: This will confirm if you are having this data corruption.
B. Verifying your file versions: This will allow you and support to confirm if you are already in a known fixed version.
C. Root Cause Analysis. It shows all the relevant information about this issue Root Cause.
D. Datafix Intructions. It will provide steps for fixing the data corruption.

Fix

A - Identification Scripts.

Identify

Please run the identification script (INV17-ident.sql) uploaded into this document.

PROMPT
PROMPT INV17-ident.sql
PROMPT From Note:1472074.1 Inventory Standard Datafix Instruction #17:
PROMPT ... Fixing Duplicate Sales Order Transactions In MTI, MMTT and MMT
PROMPT The script is based on details in Bug 4286083.
PROMPT The sql identifies if the transactions are duplicate transactions
PROMPT in the inventory transactions tables. 
PROMPT The sql is ONLY valid for Order Management duplicate transactions
PROMPT and will NOT identifyother sources like WIP jobs or inventory aliases.
PROMPT

PROMPT a. MMT vs. MTI
PROMPT Count Duplicates Between Historical transactions (MMT) vs. Interface transactions (MTI)
SELECT count(*)
FROM mtl_material_transactions b, mtl_transactions_interface a
WHERE a.picking_line_id = b.picking_line_id
AND a.trx_source_line_id = b.trx_source_line_id
AND a.inventory_item_id = b.inventory_item_id
AND b.transaction_type_id = a.transaction_type_id
AND b.transaction_source_type_id in (2,8)
AND b.picking_line_id is not null ;

PROMPT b. MMTT vs. MTI
PROMPT Count Duplicates Between Pending transactions (MMTT) vs. Interface transactions (MTI)
SELECT count(*)
FROM mtl_material_transactions_temp b,  mtl_transactions_interface a
WHERE a.picking_line_id = b.picking_line_id
AND a.trx_source_line_id = b.trx_source_line_id
AND a.inventory_item_id = b.inventory_item_id
AND b.transaction_type_id = a.transaction_type_id
AND b.transaction_source_type_id in (2,8)
AND b.picking_line_id is not null ;

PROMPT c. MMT vs. MMTT:
PROMPT Count Duplicates Between Historical transactions (MMT) vs. Pending transactions (MMTT)
SELECT count(*)
FROM mtl_material_transactions b,  mtl_material_transactions_temp a
WHERE a.picking_line_id = b.picking_line_id
AND a.trx_source_line_id = b.trx_source_line_id
AND a.inventory_item_id = b.inventory_item_id
AND b.transaction_type_id = a.transaction_type_id
AND b.transaction_source_type_id in ( 2,8)
AND b.picking_line_id is not null;
Symptoms

The symptoms for this issue can be similar to Note:1471606.1 Inventory Standard Datafix Instruction #16: Fixing Stuck transaction with 'Error Occurred While Relieving Reservations'. In addition, you might find transactions preventing period close when the records are actually duplicates that can be deleted.

Symptom List

Here are some common observations, symptoms and errors that identify this issue.

Action Result
Close period   The period cannot close due to pending transactions.
Pick release   Pick release backorders line
Transact or allocate move order    
Transact or allocate fails. Receive an error:
The material sourcing process failed to create picking suggestions for line

View Material Workbench Available Quantity       Onhand quantity is MORE than available quantity but you have no current move orders or reservations.
Ship confirm  Onhand quantity is MORE than available quantity but you have no current move orders or reservations.
Ship confirm 
Ship confirm fails. Receive an error:
An error occurred while relieving reservations
(Code: INV_RSV_RLF_FAILED)



B - Verifying your File Versions.

Execute the following from your server for getting key file versions of the following files:

TrxProcessor.java
BaseTransaction.java
INVTXMGB.pls
INVTRXWB.pls

You can use SQL like the following:

set serveroutput on
PROMPT : - - - - : TrxProcessor.java : - - - - :
exec fnd_aolj_util.getClassVersionfromDB('oracle.apps.inv.transaction.server.TrxProcessor');

PROMPT : - - - - : BaseTransaction.java : - - - - :
exec fnd_aolj_util.getclassversionfromdb('oracle.apps.inv.transaction.server.BaseTransaction');

PROMPT : - - - - : INVTXMGB.pls : - - - - :
SELECT text FROM dba_source
 WHERE name = 'INV_TXN_MANAGER_PUB'
    AND line < 3;

PROMPT : - - - - : INVTRXWB.pls : - - - - :
SELECT text FROM dba_source
 WHERE name = 'INV_LPN_TRX_PUB'
    AND line < 3;
Or review the AppsCheck output from Note 276207.1 for application parameter: Inventory

C -  Root Cause Analysis.

The following Root Causes have been identified at this moment.

1. Duplicate Transactions After One In Batch Failed

While processing transactions through open interface, if batch id is populated and if the first row in a batch fails then the previous batch, which got successfully processed was not getting deleted from pending transactions table and open interface table.                                                         

Release         Bug     Patch  Filename       Version
R11.5.8         Bug 3024133  Patch 2640488         BaseTransaction.java          115.111.11580.5+
R11.5.10       Bug 5710072  Patch 5935177         BaseTransaction.java          115.235.115100.36+
R12.0.x         Bug 5748351  Patch 6728000:R12.0.6       TrxProcessor.java
BaseTransaction.java
INVTXMGB.pls
INVTRXWB.pls          120.10.12000000.4+
120.39.12000000.2+
120.25.12000000.3+
120.34.12000000.11+


2. New Root- Causes?

We are always looking for additional reasons for data issues. If you are on a higher version or can replicate the issue for a different situation, please log a service request.

IMPORTANT: If you are in higher file version please log a SR with Support Services or update the existing one providing this note number and the script output from section A and the file versions from section B and we will add your SR to the Internal Root Cause Analysis (RCA) Bug 8857390 for Release 12 and RCA Bug 9270328 for release 11i.

Also, if you are in higher file versions and you can replicate this issue, we would like to hear more on how you do it and then we can log a new bug focusing on fixing the issue. Please log a SR with Support Services or update the existing one with replication steps.



D - Datafix.

Follow the steps below to fix the data. The following temporary views are created to facilitate the backup table creation and the datafix. You can drop these views later if desired:

View   Explanation
mmt_mti_records_v  Compare the historical transactions to the interface transactions.
mmtt_mti_records_v Compare the pending transactions to the interface transactions.
mmt_mmtt_records_v        Compare the historical transactions to the pending transactions.


1. Identify data.

Please run the identification script (INV17-ident.sql) uploaded into this document.

2. Backup data.

Run the backup script (INV17-backup.sql). The backup script creates the following tables: mti_dup_backup, msni_dup_backup, mtli_dup_backup, mti_dup_backup_mmtt, msni_dup_backup_mmtt, mtli_dup_backup_mmtt, mmtt_dup_backup, msnt_dup_backup, mtlt_dup_backup

3. Run the datafix script.

Run the datafix script (INV17-datafix.sql) uploaded into the note. This will fix the data by removing duplicate transactions.

Note: The script DOES commit.
4- Check the data.

Check if your data has been corrected and you are not experiencing problems. You can rerun the script from the identification section:  (INV17-ident.sql) uploaded into this document.

Note: You may also need to submit any good, remaining transactions. For example, you could check for unprocessed records, resubmit any you can via the form, rerun the inventory manager, rerun trip stop, etc. See Note:1069492.1 Resolving Period Close Pending Transaction R12 that includes SQL to update transactions as well.

For example, this SQL could resubmit unprocessed pending transactions that you cannot see via the form because they are transaction mode 8:

update mtl_material_transactions_temp
 set process_flag = 'Y',
 lock_flag = 'N',
 transaction_mode = 3,
 error_code = NULL,
 error_explanation = NULL
where process_flag in ('Y','E')


References

NOTE:568012.1 - FAQ: Inventory Standard Datafixes
NOTE:280400.1 - Stuck Transaction Interface Sales Order Issues: An Error Occured While Relieving Reservations (INV_RSV_RLF_FAILED)
NOTE:294391.1 - What do the transaction mode (like transaction_mode = 8) numbers mean in the pending transactions table (MTL_MATERIAL_TRANSACTIONS_TEMP)?



Attachments