Friday, January 28, 2011

Upload/Download XML RTF Templates in Oracle from UNIX

For Downloading RTF template:

java oracle.apps.xdo.oa.util.XDOLoader DOWNLOAD
-DB_USERNAME
-DB_PASSWORD
-JDBC_CONNECTION
-LOB_TYPE
-APPS_SHORT_NAME
-LOB_CODE
-LANGUAGE
-TERRITORY
-LOG_FILE

For Uploading RTF template:

java oracle.apps.xdo.oa.util.XDOLoader UPLOAD
-DB_USERNAME
-DB_PASSWORD
-JDBC_CONNECTION
-LOB_TYPE
-APPS_SHORT_NAME
-LOB_CODE
-LANGUAGE
-TERRITORY
-XDO_FILE_TYPE
-NLS_LANG
-FILE_CONTENT_TYPE
-FILE_NAME
-OWNER
-CUSTOM_MODE [FORCE|NOFORCE]
-LOG_FILE

Tuesday, January 25, 2011

Oracle R12: Script to update Serial Numbers on Install Base

/* Formatted on 2011/01/25 14:10 (Formatter Plus v4.8.0) */
DECLARE
CURSOR ib_cur
IS
SELECT cii.instance_id, cii.serial_number, cii.inventory_item_id,
cii.object_version_number
FROM csi_item_instances cii
WHERE 1 = 1 AND cii.instance_id = :ip_instance_id
ORDER BY 1;

TYPE ib_rec_tbl_type IS TABLE OF ib_cur%ROWTYPE;

ib_rec_tbl ib_rec_tbl_type;
l_api_version CONSTANT NUMBER := 1.0;
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
l_msg_index NUMBER;
l_instance_id_lst csi_datastructures_pub.id_tbl;
l_instance_header_rec csi_datastructures_pub.instance_header_rec;
l_party_header_tbl csi_datastructures_pub.party_header_tbl;
l_party_acct_header_tbl csi_datastructures_pub.party_account_header_tbl;
l_org_unit_header_tbl csi_datastructures_pub.org_units_header_tbl;
l_instance_rec csi_datastructures_pub.instance_rec;
l_party_tbl csi_datastructures_pub.party_tbl;
l_account_tbl csi_datastructures_pub.party_account_tbl;
l_pricing_attrib_tbl csi_datastructures_pub.pricing_attribs_tbl;
l_org_assignments_tbl csi_datastructures_pub.organization_units_tbl;
l_asset_assignment_tbl csi_datastructures_pub.instance_asset_tbl;
l_ext_attrib_values_tbl csi_datastructures_pub.extend_attrib_values_tbl;
l_pricing_attribs_tbl csi_datastructures_pub.pricing_attribs_tbl;
l_ext_attrib_tbl csi_datastructures_pub.extend_attrib_values_tbl;
l_ext_attrib_def_tbl csi_datastructures_pub.extend_attrib_tbl;
l_asset_header_tbl csi_datastructures_pub.instance_asset_header_tbl;
l_txn_rec csi_datastructures_pub.transaction_rec;
l_return_status VARCHAR2 (5);
lc_init_msg_lst VARCHAR2 (1) := 'T';
ln_validation_level NUMBER;
lc_error_text VARCHAR2 (4000);
BEGIN
OPEN ib_cur;

FETCH ib_cur
BULK COLLECT INTO ib_rec_tbl;

CLOSE ib_cur;

IF ib_rec_tbl.COUNT > 0
THEN
DBMS_OUTPUT.put_line ('Begin loop');

FOR i IN ib_rec_tbl.FIRST .. ib_rec_tbl.LAST
LOOP
l_instance_header_rec.instance_id := ib_rec_tbl (i).instance_id;
csi_item_instance_pub.get_item_instance_details
(p_api_version => l_api_version,
p_commit => fnd_api.g_false,
p_init_msg_list => fnd_api.g_false,
p_validation_level => fnd_api.g_valid_level_full,
p_instance_rec => l_instance_header_rec,
p_get_parties => fnd_api.g_true,
p_party_header_tbl => l_party_header_tbl,
p_get_accounts => fnd_api.g_true,
p_account_header_tbl => l_party_acct_header_tbl,
p_get_org_assignments => fnd_api.g_true,
p_org_header_tbl => l_org_unit_header_tbl,
p_get_pricing_attribs => fnd_api.g_false,
p_pricing_attrib_tbl => l_pricing_attribs_tbl,
p_get_ext_attribs => fnd_api.g_false,
p_ext_attrib_tbl => l_ext_attrib_tbl,
p_ext_attrib_def_tbl => l_ext_attrib_def_tbl,
p_get_asset_assignments => fnd_api.g_false,
p_asset_header_tbl => l_asset_header_tbl,
p_resolve_id_columns => fnd_api.g_false,
p_time_stamp => SYSDATE,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
lc_error_text := NULL;
l_instance_rec.instance_id := l_instance_header_rec.instance_id;
l_txn_rec.transaction_id := fnd_api.g_miss_num;
l_txn_rec.transaction_date := SYSDATE;
l_txn_rec.source_transaction_date := SYSDATE;
l_txn_rec.transaction_type_id := 205;
l_instance_rec.serial_number := :ip_new_serial_number;
l_instance_rec.object_version_number :=
l_instance_header_rec.object_version_number;
DBMS_OUTPUT.put_line ( 'Updating IB record for IB# '
|| ib_rec_tbl (i).instance_id
);
csi_item_instance_pub.update_item_instance
(p_api_version => l_api_version,
p_commit => 'F',
p_init_msg_list => lc_init_msg_lst,
p_validation_level => ln_validation_level,
p_instance_rec => l_instance_rec,
p_ext_attrib_values_tbl => l_ext_attrib_values_tbl,
p_party_tbl => l_party_tbl,
p_account_tbl => l_account_tbl,
p_pricing_attrib_tbl => l_pricing_attrib_tbl,
p_org_assignments_tbl => l_org_assignments_tbl,
p_asset_assignment_tbl => l_asset_assignment_tbl,
p_txn_rec => l_txn_rec,
x_instance_id_lst => l_instance_id_lst,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);

IF l_return_status <> 'S'
THEN
DBMS_OUTPUT.put_line
( 'Error updating the install base for IB# '
|| ib_rec_tbl (i).instance_id
);

FOR i IN 1 .. l_msg_count
LOOP
fnd_msg_pub.get (p_msg_index => -1,
p_encoded => 'F',
p_data => l_msg_data,
p_msg_index_out => l_msg_index
);
lc_error_text := lc_error_text
|| (SUBSTR (l_msg_data, 1, 255));
END LOOP;

DBMS_OUTPUT.put_line (lc_error_text);
ELSE
DBMS_OUTPUT.put_line
( 'Install base update successful for IB# '
|| ib_rec_tbl (i).instance_id
);
lc_error_text := 'SUCCESS!';
COMMIT;
END IF;
END LOOP;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('No records to process');
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error in update_ib procedure');
DBMS_OUTPUT.put_line (TO_CHAR (SQLCODE) || ' - ' || SQLERRM);
END;

Thursday, January 20, 2011

Oracle Receivables Module Technical Details

Oracle Accounts Receivable uses the following tables for recording customer account information:

The major tables containing parties and customer accounts information in Oracle Receivables are grouped by business function.
• HZ_PARTIES
• HZ_CUST_ACCOUNTS
• HZ_PARTY_SITES
• HZ_CUST_ACCT_SITES_ALL
• HZ_CUST_SITE_USES_ALL
• HZ_LOCATIONS
• HZ_PARTY_RELATIONSHIPS
• HZ_ORGANIZATION_PROFILES
• HZ_CONTACT_POINTS
• HZ_CUST_ACCOUNT_ROLES
• HZ_PERSON_PROFILES
• HZ_ORG_CONTACTS

Transaction Tables
• RA_CUSTOMER_TRX_ALL
• RA_CUSTOMER_TRX_LINES_ALL
• RA_CUST_TRX_LINE_GL_DIST_ALL
• AR_PAYMENT_SCHEDULES_ALL
• AR_CASH_RECEIPTS_ALL
• AR_CASH_RECEIPT_HISTORY_ALL
• AR_RECEIVABLE_APPLICATIONS_ALL
• AR_ADJUSTMENTS_ALL

HZ_PARTIES
A party is an entity that can enter into a business relationship.
This table stores basic information about parties, which is true regardless of this relationship to the deploying company. Entities are modeled only once in HZ_PARTIES, regardless of how many roles they play. For example, if an organization is a customer, a distributor, and a partner, there is still only one record for them in HZ_PARTIES.

Parties can be one of four types:
Organization - Oracle Corporation
Person - Jane Doe
Group – Doc Household
Relationship - Jane Doe at Oracle Corporation

HZ_LOCATIONS
A location is a point in geographical space described by an address and/or geographical Indicators such as latitude or longitude.
• This table stores information about an address such as: street address and postal code.
• This table provides physical location information about parties (organizations and people) and customer accounts.
• Records in HZ_LOCATIONS can store delivery and postal code information about a location, store latitude and longitude, and can be used to determine the appropriate calculations and tax rates for sales tax and VAT calculations.

HZ_PARTY_SITES
This table links a party (HZ_PARTIES) and a location (HZ_LOCATIONS) and stores location-Specific party information such as a person’s mail stops at their work address.
• One party can point to one or more party sites.
• One location can point to one or more party site.
• Party sites serve as the intersection between parties and locations, allowing for a many-to-many relationship between the two.

HZ_RELATIONSHIPS
This table stores information about relationships between two entities, for example, one party and another party.
• The SUBJECT_ID and OBJECT_ID columns specify the relationship that exists between two parties. For example, if the party relationship type is “Parent Of,” then a holding company could be the “SUBJECT_ID” in the relationship while one of its subsidiaries could be the OBJECT_ID. Creating a party contact causes a party relationship to be created.
• A party can have different relationships with one or more other parties that can change over time.

HZ_ORGANIZATION_PROFILES
This table stores a variety of information about a party of type Organization.
• This table gets populated when a party of type ORGANIZATION is created.
• Historical data is also stored in this table.

HZ_PERSON_PROFILES
This table stores a variety of information about a party of type Person.
• For example, this table could contain the correct spelling and phonetic pronunciation of the person’s name.
• Some information in this table may also be entered into the HZ_PARTIES table.

HZ_ORG_CONTACTS
This table stores a variety of information about an organization contact.
• The records in this table provide information about a contact position such as job title, rank, and department.
• This table is not used to store information about a specific person or organization. For example, this table may include a record for the position of Vice President of Manufacturing that indicates that the contact is a senior executive, but it would not include the name of the person in that position.

HZ_CUST_ACCOUNTS
This table stores information about customer/financial relationships established between a Party and the deploying company.
• Because a party can have multiple customer accounts, this table may contain several records for a single party. For example, an individual person may establish a personal account, a family account, and a professional account for a consulting practice.

HZ_CUST_ACCT_SITES_ALL
This table stores information about customer/financial account sites information.
Stores information about customer sites. One customer account can have multiple sites.

HZ_CUST_SITE_USES_ALL
This table stores information about the business purposes assigned to a customer account site.
• A customer account site can have multiple purposes, but each record in this table only specifies one purpose for a customer account site. For example, a customer account site may be assigned as a ship-to site in one record and as a bill-to site in another record.

HZ_CUST_ACCOUNT_ROLES
This table stores information about a role or function that a party performs as related to a customer account. For example, Jane Doe might be the Legal Contact for a specific customer account of Corporation ABC. Note that account ownership such as financial responsibility for an account is determined by the single party ID that is stored directly on the HZ_CUST_ACCOUNTS table.

HZ_CONTACT_POINTS
This table stores information about how to communicate with parties or party sites using electronic media or methods such as Electronic Data Interchange (EDI), e-mail, telephone, telex, and the Internet.
• Each medium or method should be stored as a separate method in this table. For example, the attributes of a complete telephone number connection should be stored in a record, while EDI information should be stored in a different record.

RA_CUSTOMER_TRX_ALL
This table stores invoice, debit memo, commit-ment, chargeback, bills receivable, and credit memo header information.
• Each row includes general invoice information such as customer, transaction type, and printing instructions.
• You need one row for each invoice, debit memo, commitment, and credit memo you create in Oracle Receivables and these are all distinguished by their transaction types stored in RA_CUST_ TRX_ TYPES_ALL.

RA_CUSTOMER_TRX_LINES_ALL
This table stores information about invoice, debit memo, credit memo, bills receivable, and commitment lines. It describes to the customer the charges that appear on these documents.

AR_PAYMENT_SCHEDULES_ALL
This table stores all transactions except adjust-ments and miscellaneous cash receipts. A miscellaneous cash receipt is one that is not connected to a customer.
• All customer-related activity is logged in this table.
• This table is updated when an activity occurs against an invoice, debit memo, chargeback, credit memo, on-account credit, bills receivable,
receipt, or commitments.

RA_CUST_TRX_TYPES_ALL
This table stores information about each transaction type for all classes of transactions, for example, invoices, commitments, and credit memos.
• Each row includes Auto Accounting information
as well as standard defaults for the resulting invoices. The primary key for this table is CUST_TRX_TYPE_ID.

AR_TRANSACTION_HISTORY_ALL
This table is a Bills Receivable-specific table containing the history of a transaction’s lifecycle.
• A new row is created each time there is activity on the transaction or the status of the transaction has changed.
• This table stores the header for the Receivables posting information.

AR_DISTRIBUTIONS_ALL
This table stores the accounting distributions for cash receipts, miscellaneous receipts, adjustments, credit memo applications, cash receipt applications, and bills receivable transactions.

AR_CASH_RECEIPTS_ALL
This table stores one record for each receipt entry.
• All cash receipts are logged in this table.
• Oracle Receivables creates records concurrently in the AR_CASH _RECEIPT_ HISTORY_ ALL, AR_PAYMENT_ SCHEDULES_ ALL, AR_DISTRI-BUTIONS_ALL, and AR_ RECEIVABLE_ APPLICA-TIONS_ALL tables for invoice-related receipts.
• For receipts that are not related to invoices, records are created in the AR_MISC_CASH_ DISTRIBUTIONS_ALL table instead of the AR_RECEIVABLE_APPLICATIONS_ ALL table.

AR_CASH_RECEIPT_HISTORY_ALL
This table stores all of the activity that is contained for the life cycle of a receipt.
• Each row represents one step.
• The status field for that row tells you which step the receipt has reached.
• Possible statuses are Approved, Confirmed, Remitted, Cleared, and Reversed.

AR_RECEIVABLE_APPLICATIONS_ALL
This table stores all accounting entries for cash and credit memo applications.
• Each row includes the amount applied, status, and accounting flex field information.

AR_MISC_CASH_DISTRIBUTIONS_ALL
This table stores all accounting entries for miscellaneous cash applications.
• Miscellaneous cash cannot be invoiced, such as stock revenue, interest income, and investment income.
• AR_CASH_RECEIPTS_ALL stores one record for each payment, and this table stores one record for each distribution of the receipt.

AR_RECEIPT_CLASSES
This table stores the different receipt classes that you define.
• Receipt classes determine whether the receipt[s] belonging to this class are created manually or automatically, and whether the receipts go through the different steps in a receipt’s life-cycle.

AR_RECEIPT_METHODS
This table stores information about Payment Methods, receipt attributes that you define and assign to Receipt Classes to account for receipts and their applications.
• For automatically created receipts, a Payment Method defines the rules for creating these receipts.
• For manually created receipts, a Payment Method defines a user-definable type for the receipt.
• Each Payment Method is associated with a set of bank accounts, which forms the set of bank accounts you can assign to your receipt.

AR_ADJUSTMENTS_ALL
This table stores information about the adjustment applied to the Invoices.

Puchasing and Payables Module: Technical Details

PO_VENDORS
This table stores information about your suppliers. Oracle Purchasing uses this information to determine active suppliers. The primary key is VENDOR_ID.

PO_VENDOR_SITES_ALL
This table stores information about supplier sites. Oracle Purchasing uses this information to store supplier address information. The primary key is VENDOR_SITE_ID.

PO_VENDOR_CONTACTS
This table stores information about supplier site contacts. The primary key is VENDOR_CONTACT_ID.

PO_REQUISITION_HEADERS_ALL
PO_REQUISITION_HEADERS_ALL stores information about requisition headers. Each row contains the requisition number, preparer status, and description. It is one of three tables that stores requisition information. The primary key is REQUISITION_HEADER_ID.

PO_REQUISITION_LINES_ALL
This table stores information about requisition lines. Each row contains the line number, item number, item category, item description, need-by date, deliver-to location, item quantities, units, prices, requestor, notes, and suggested supplier information for the requisition line. This table is one of three tables that stores requisition information. The primary key is REQUISITION_LINE_ID.

PO_REQ_DISTRIBUTIONS_ALL
PO_REQ_DISTRIBUTIONS_ALL stores information about the accounting distributions associated with each requisition line. Each requisition line must have at least one accounting distribution. Each row includes the Accounting Flex field ID and requisition line quantity. This table is one of three tables that stores requisition information. The primary key is DISTRIBUTION_ID.

PO_HEADERS_ALL
PO_HEADERS_ALL contains information for your purchasing documents. Each row contains buyer information, supplier information, notes, foreign currency information, terms and conditions information, and the document status. Oracle Purchasing uses this information to record information related to a complete document. The primary key is PO-HEADER_ID.

PO_LINES_ALL
PO_LINES_ALL stores current information about each purchase order line. You need one row for each line you attach to a document. Each row includes the line number, item number and category unit, price, tax information, and quantity ordered for the line. Oracle Purchasing uses this information to record and update item and price information for purchase orders, quotations, and RFQs. The primary key is PO_LINE_ID.

PO_LINE_LOCATIONS_ALL
This table contains information about purchase order shipment schedules and blanket agreement price breaks. You must have one row for each schedule or price break you attach to a document line. Each row contains the location, quantity, and dates for each shipment schedule. Oracle Purchasing uses this information to record delivery schedule information for purchase orders and price break information for blanket purchase orders, quotations, and RFQs. The primary key is LINE_LOCATION_ID.

PO_DISTRIBUTIONS_ALL
PO_DISTRIBUTIONS_ALL contains accounting information for a purchase order shipment line. Oracle Purchasing uses this information to record accounting and requisition information for purchase orders and releases. It is one of five tables that stores purchase orders and releases. The primary key is PO_DISTRIBUTION_ID.

RCV_SHIPMENT_HEADERS
This table stores common information about the source of your receipts or expected receipts. You group your receipts by the source type and the source of the receipt. Oracle Purchasing does not allow you to group receipts from different sources under one receipt header. The primary key is SHIPMENT_HEADER_ID.

RCV_SHIPMENT_LINES
This table stores information about items that have been shipped or received from a specific receipt source. This table also stores information about the default destination for in-transit shipments. The primary key is SHIPMENT_LINE_ID.

RCV_TRANSACTIONS
This table stores historical information about receiving transactions that you have performed. When you enter a receiving transaction and the receiving transaction processor processes your transaction, the transaction is recorded in this table.
Once a row has been inserted into this table, it will never be updated. When you correct a transaction, the net transaction quantity is maintained in RCV_SUPPLY. The original transaction does not get updated. You can only delete rows from this table using the Purge feature of Oracle Purchasing. The primary key is TRANSACTION_ID.

PO_RELEASES_ALL
This table contains information about blanket and planned purchase order releases. You need one row for each release you issue for a blanket or planned purchase order. Each row includes the buyer, date, release status, and release number. Each release must have at least one purchase order shipment (PO_LINE_LOCATIONS_ALL). The primary key is PO_RELEASE_ID.

AP_INVOICES_ALL
This table contains records for supplier invoices and has one row for each invoice.
To pass Invoice Validation, the INVOICE_AMOUNT in the AP_INVOICES_ALL table must equal the sum of the AMOUNT columns in the AP_DISTRIBUTIONS_ALL table. The primary key is INVOICE_ID.

AP_INVOICE_DISTRIBUTIONS_ALL
This table holds the distribution line information.
There is a row for each invoice distribution. If matching is used, distribution information is copied from PO_DISTRIBUTIONS_ALL during the matching process.

AP_PAYMENT_SCHEDULES_ALL
This table contains information about scheduled payments for an invoice.
Oracle Payables uses this information to determine when to make payments on an invoice and how much to pay in an automatic payment batch.

AP_HOLDS_ALL
This table contains a record for each hold placed on an invoice.
An invoice might have multiple records in this table.
An invoice cannot be paid until all holds placed on it have been released.

AP_CHECKS_ALL
This table stores information about payments issued to suppliers.
Each row includes the supplier name, address, and bank account name for auditing purposes, in case any of them change after you make the payment.
If the payment is electronic, the supplier bank account information is stored in the payment record.

AP_INVOICE_PAYMENTS_ALL
This table provides the link between a payment (CHECK_ID) and the invoice(s) paid by that payment.
This table contains records of invoice payments that you make to suppliers. Oracle Payables updates this table when you confirm an automatic payment batch, enter a manual payment, or process a Quick Payment. This table contains one row for each payment made for each invoice.
Void payments are also entered into this table as a negative record of the original payment line.

AP_BANK_ACCOUNTS_ALL
This table stores information about your bank accounts and your suppliers’ and customers’ bank accounts. This table contains one row for every bank account, whether it is an internal (supplier) or external (customer) account.

AP_BANK_BRANCHES
This table stores information about the bank branches and details about the branches.

Thanks to my friend Sairam Malla for sharing this technical information

Monday, January 17, 2011

PL/Sql script to add System Administrator responsibility

BEGIN
fnd_user_pkg.addresp
(username => UPPER
('arathod'),
resp_app => 'SYSADMIN',
resp_key => 'SYSTEM_ADMINISTRATOR',
security_group => 'STANDARD',
description => 'DESCRIPTION',
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;
/

Script to create a FND user using PL/SQL

DECLARE
l_responsibility_id NUMBER;
l_application_id NUMBER;
l_user_id NUMBER := fnd_global.user_id;
x_user_id NUMBER;
l_password VARCHAR2 (2000) := 'welcome1';
BEGIN
apps.hr_user_acct_internal.create_fnd_user (p_user_name => 'arathod',
p_password => l_password,
p_employee_id => NULL,
p_user_id => x_user_id,
p_user_start_date => SYSDATE,
p_email_address => NULL,
p_description => NULL,
p_password_date => NULL
);
DBMS_OUTPUT.put_line (x_user_id);

IF x_user_id IS NOT NULL
THEN
UPDATE fnd_user
SET password_lifespan_days = 90
WHERE user_id = x_user_id;

COMMIT;
END IF;
END;

Oracle PO Archive extract

SELECT po_number, creation_date po_date, vendor_num, vendor_name,
revision_num, approved_date, closed_date,
change_type type_of_modification
FROM (SELECT pv.segment1 vendor_num, pv.vendor_name, pha.po_header_id,
pha.segment1 po_number, pha.agent_id, pha.creation_date,
pha.vendor_id, phaa.submit_date, pha.revision_num rev_num,
phaa.revision_num, pha.approved_flag, pha.approved_date,
pha.closed_date, phaa.closed_code, pha.cancel_flag,
CASE
WHEN ( NVL (pha.approved_flag, '01-JAN-1951') <>
'01-JAN-1951'
AND NVL (pha.closed_date, '01-JAN-1951') <>
'01-JAN-1951'
AND NVL (phaa.closed_code, 'OPEN') = 'OPEN'
AND pha.approved_flag <> 'F'
AND phaa.revision_num = pha.revision_num
)
THEN 'APPROVED & CLOSED'
WHEN ( NVL (pha.approved_flag, '01-JAN-1951') <>
'01-JAN-1951'
AND NVL (pha.closed_date, '01-JAN-1951') =
'01-JAN-1951'
AND pha.approved_flag = 'Y'
AND phaa.revision_num = pha.revision_num
)
THEN 'APPROVED'
WHEN ( NVL (phaa.closed_code, 'OPEN') = 'CLOSED'
AND pha.cancel_flag = 'Y'
)
THEN 'CANCELLED'
WHEN (pha.approved_flag = 'F')
THEN 'REJECTED'
WHEN phaa.submit_date IS NULL
THEN 'NEW'
WHEN phaa.revision_num < pha.revision_num
THEN 'CHANGE'
END change_type
FROM po_headers_all pha,
po_headers_archive_all phaa,
po_vendors pv
WHERE 1 = 1
AND phaa.po_header_id(+) = pha.po_header_id
AND pv.vendor_id = pha.vendor_id
ORDER BY pha.po_header_id, phaa.revision_num) po_archive

Enabling AuditTrail Functionality to capture changes to project status

Set profile Option
1. Log in with the responsibility: System Administrator
Navigation Path: System/profile
2. Query on profile option: AuditTrail:Activate

3. Ensure that this profile option is set to yes at site level and not overwriten by a No at application level ( valid values are yes or null when it is defined at site level as indicated above)

Install
1. Log in with the responsibility: System Administrator
Navigation Path: Security/AuditTrail/Install
2. Query on profile option: Oracle Username : PA

3. Ensure that the user account for Oracle Project Accounts is checked as enabled for audit 

Define the Audit Group
1. Log in with the responsibility: System Administrator
Navigation Path: Security/AuditTrail/Groups
2. Create an audit group for the application projects

3. Add PA_PROJECTS_ALL table in the audit tables list

Define the Audit Columns
1. Log in with the responsibility: System Administrator
Navigation Path: Security/AuditTrail/Tables
2. Query on the Table Name PA_PROJECTS_ALL and add the column PROJECT_STATUS_CODE to it


AuditTrail Update tables
1. Log in with the responsibility: System Administrator
Navigation Path: Requests/Run
2. Submit the report: AuditTrail Update Tables

Tables Schema created

select * from dba_objects
where object_name like 'PA_PROJECTS_ALL_A'

AuditTrail Report for Audit Group Validation
1. Log in with the responsibility: System Administrator
Navigation Path: Requests/Run
2. Submit the report: AuditTrail Report for Audit Group Validation by choosing the audit group in parameters

This process creates Shadow Tables with the same data type columns. Shadow Tables have the name _A which mirror the audited tables. (in our example the audited table is PA_PROJECTS_ALL and the shadow table is PA_PROJECTS_ALL _A).It also creates views on the Shadow Tables with the name _AC1 and _AV1 which allow access to the data in the Shadow Tables.