Thursday, October 9, 2014

R12 Patching Internals (12.1.3) - Reverting adpatch


R12 Patching Internals (12.1.3) - Reverting adpatch 

Have you ever applied a patch and later realized you need to rollback? Yes some of us do this mistake and badly want to revert back. If you approach oracle they would say its not possible.

Well yes not all patches can be reverted but few can be reverted. To understand this we need to know what does an adpatch session do?

Every adpatch session has 3 major portions in patch application
1. copy phase
2. generate phase
3. Database phase

During copy phase all the files in the patch are compared with the files in the file system for Header versions. If the header version of the file in the patch folder is found to be greater it takes a copy of the file in backup folder created under patch directory and then it copies the file over to file system from patch directory.

During generate phase all the forms, reports ,  libraries, jarfiles etc are generated.

During Database phase all the database actions such as  running pls,sql files , performing schema compare and creating database objects using odf files etc ...happens along with inserting applied patch records in database.

What types of patches can be reverted?
 Only patches that has Phases 1 & 2 can be reverted. All database portions cannot be reverted.So Check the patch actions and if it involves only copy and regenerate or generate phase you can revert patch.

You can never revert the adpatch history related data in the database.

How do we revert patches?
Patch revert process is manual and should be used only when you are sure of what you are doing.
Of course after reverting patch you can still reapply patch on the same system and get the changes back into ERP.

From the backup folder copy back all the files to their respective file system. The backup directory makes it easy to identify from where this file is backed up as it maintains the same directory structure as that of ERP.

You will often observe that java files are copied using adjava so you will notice that and undoScript.cmd is created which contains how to revert the java files copied via adjava command.

To revert such class files use the below command:

adjava -mx256m oracle.apps.ad.jri.adjcopy @undoScript.cmd

verify the undoLog.log and undoReport.log for any errors

Sample undo log looks as below:

About to Load metadata from master archive : Thu Oct 09 2014 15:08:33
Loading metadata from archive /ebs/EBS1213/VISCB/apps/apps_st/comn/java/classes

Done Loading metadata from master archive : Thu Oct 09 2014 15:08:38
------------------------------------------------------------------------------
About to Merge meta data of delta archive 1 and master archive : Thu Oct 09 2014 15:08:38
Loading metadata from archive /ebs/Installers/16884442/backup/VISCB/scbdev3/java

This delta archive replaces the following elements:
oracle/apps/ce/bankaccount/server/AccountSimpleVOImpl [120.11.12010000.2 -> 120.11]  {oracle/apps/ce/bankaccount/server/AccountSimpleVOImpl.class }
oracle/apps/ce/bankaccount/webui/AccountAccessCO [120.8.12010000.4 -> 120.8]  {oracle/apps/ce/bankaccount/webui/AccountAccessCO.class }
oracle/apps/ce/bankaccount/webui/AccountAccessOptCO [120.22.12010000.6 -> 120.22.12010000.3]  {oracle/apps/ce/bankaccount/webui/AccountAccessOptCO.class }
oracle/apps/ce/bankaccount/webui/AccountAccessOrgCO [120.21.12010000.5 -> 120.21]  {oracle/apps/ce/bankaccount/webui/AccountAccessOrgCO.class }
oracle/apps/ce/bankaccount/webui/AccountContactCO [120.8.12010000.5 -> 120.8.12010000.2]  {oracle/apps/ce/bankaccount/webui/AccountContactCO.class }
oracle/apps/ce/bankaccount/webui/AccountControlCO [120.13.12010000.8 -> 120.13]  {oracle/apps/ce/bankaccount/webui/AccountControlCO.class }
oracle/apps/ce/bankaccount/webui/AccountInfoCO [120.23.12010000.15 -> 120.23.12010000.4]  {oracle/apps/ce/bankaccount/webui/AccountInfoCO.class }
oracle/apps/ce/bankaccount/webui/AccountOwnerUseCO [120.18.12010000.10 -> 120.18]  {oracle/apps/ce/bankaccount/webui/AccountOwnerUseCO.class }
oracle/apps/ce/bankaccount/webui/AccountSimpleCO [120.18.12010000.13 -> 120.18.12010000.6]  {oracle/apps/ce/bankaccount/webui/AccountSimpleCO.class }

Done Merging meta data of delta archive 1 and master archive : Thu Oct 09 2014 15:08:39

About to Remove resource units from merged meta data : Thu Oct 09 2014 15:08:39
-------------------------------------------------------------------------------
Getting the list of Resource Units to be removed from /ebs/Installers/16884442/backup/VISCB/scbdev3/java.txt

None of the resource units/packages specified in java.txt(-removeRUs option) are removed.

Done Removing resource units from merged meta data : Thu Oct 09 2014 15:08:39

About to Update master archive : Thu Oct 09 2014 15:08:39
Updating master archive /ebs/EBS1213/VISCB/apps/apps_st/comn/java/classes

Done Updating master archive : Thu Oct 09 2014 15:08:43
Successfully created touch file.
All processing successful; exiting with status 0


Sample undoReport.log is as below:

#--------------------------------------------------------------------------
# This file contains detailed information about changes made to the master
# archive specified on the adjcopy command line.
#
# If -mode is CHECK_ONLY, the information in this file describes what would
# have happened if adjcopy was run with -mode set to APPLY.
#
# For an AutoPatch run, this file describes changes made to apps.zip
# by the 'jcopy' actions in this patch.
#
# The format of this file is:
#
# <Type> <Master Archive Name> <Master Archive Version> \
# <Archive Name> <Archive Version> <Action> <Resource Unit Name>
#
# where:
#
#    <Type> is:
#       - Update: Applying a delta archive to the master archive
#
#    <Master Archive Name> is:
#       The name of the Master Archive (usually apps.zip)
#
#    <Master Archive Version> is:
#       The version of the resource unit in the master archive
#       If version is not available this is 'None'.
#
#    <Archive Name> is:
#       The name of the other archive
#       For 'Update' actions, this is the name of the delta archive.
#
#    <Archive Version> is:
#         The version of the resource unit in the other archive
#         If version is not available this is 'None'.
#
#    <Action> is one of:
#       - Add     : New resource unit added to the master archive
#       - Replace : Existing resource unit in the master archive replaced
#       - Remove  : Remove existing resource unit in the master archive
#
#    <Resource Unit Name> is:
#       The name of the resource unit
#
#  The following parameters are used in the run:
#
#    -masterArchive  /ebs/EBS1213/VISCB/apps/apps_st/comn/java/classes
#    -deltaArchives /ebs/Installers/16884442/backup/VISCB/scbdev3/java
#    -removeRUs     /ebs/Installers/16884442/backup/VISCB/scbdev3/java.txt
#    -favorLowRevisions
#    -mode APPLY
#    -logfile /ebs/Installers/16884442/backup/VISCB/scbdev3/undoLog.log
#    -reportfile /ebs/Installers/16884442/backup/VISCB/scbdev3/undoReport.log
#
#--------------------------------------------------------------------------
#    -deltaArchive  java

Update classes 120.11.12010000.2 java 120.11 Replace oracle/apps/ce/bankaccount/server/AccountSimpleVOImpl.class
Update classes 120.8.12010000.4 java 120.8 Replace oracle/apps/ce/bankaccount/webui/AccountAccessCO.class
Update classes 120.22.12010000.6 java 120.22.12010000.3 Replace oracle/apps/ce/bankaccount/webui/AccountAccessOptCO.class
Update classes 120.21.12010000.5 java 120.21 Replace oracle/apps/ce/bankaccount/webui/AccountAccessOrgCO.class
Update classes 120.8.12010000.5 java 120.8.12010000.2 Replace oracle/apps/ce/bankaccount/webui/AccountContactCO.class
Update classes 120.13.12010000.8 java 120.13 Replace oracle/apps/ce/bankaccount/webui/AccountControlCO.class
Update classes 120.23.12010000.15 java 120.23.12010000.4 Replace oracle/apps/ce/bankaccount/webui/AccountInfoCO.class
Update classes 120.18.12010000.10 java 120.18 Replace oracle/apps/ce/bankaccount/webui/AccountOwnerUseCO.class
Update classes 120.18.12010000.13 java 120.18.12010000.6 Replace oracle/apps/ce/bankaccount/webui/AccountSimpleCO.class

#--------------------------------------------------------------------------
#    -removeRUs  java.txt

# This removeRU file does not remove any elements of the master archive

Ensure to run generate jar files after the reversal of java files to ensure that jar files are rebuild after the copy.
All forms and reports reverted needs to be regenerated.

Hope this helps all....