Anda di halaman 1dari 6

How do you undo accounting in R12? [ID 753695.

1]

Modified 02-JUN-2011 Type HOWTO Status PUBLISHED

In this Document
Goal
Solution

Applies to:

Oracle Payables - Version: 12.0.0 to 12.1.2 - Release: 12.0 to 12.1


Information in this document applies to any platform.

Goal

How do you undo accounting in R12?

Solution

R12 does not have any standard functionality to undo accounting. If you find accounting that is incorrect due to a bug, a datafix bug will need to be logged to
provide you a script to undo accounting. If development determines that the accounting is incorrect and needs to be reversed/undone, they will provide you
the appropriate instructions and corresponding scripts/patches.

The ap_undo_acctg.sql is a centralized script for Undo Accounting to be used in AP. If the accounting is transferred, this script will create a manual entry with
a NEW event id that reverses the original entry, change the original entry to a manual entry with a NEW event id, reset the status of the original event to
unprocessed and also reset the posted flags for transactions assigned the original event id. The original event id, the reversed event id and the new event id
are stored in the backup table created , namely AP_undo_event_log. If the accounting is NOT transferred, the script will delete the accounting and reset the
original event to be accounted again, but it will not create a reversing entry. Example of undo for transferred accounting:

Before Undo
=========

1 Event:

Event_id = 123456, Event Type = Invoice Validated, Event Status = P

After Undo
=========

3 Events:

Event_id = 123456, Event Type = Invoice Validated, Event Status = U -- The original event id remains associated with the transaction data and the
accounting status is reset to allow the new/corrected accounting to be created.

Event_id = 234567, Event Type = Manual, Event Status = P -- New event id created for the reversal of the original accounting header and lines.

Event_id = 234568, Event Type = Manual, Event Status = P -- New event id assigned to the original accounting header and lines.

IMPORTANT: If the event_date corresponding to a transferred event is in a closed period, the reversed event and new event event_date will be set based
on the script GL Date parameter. If the GL Date parameter is not populated, the event_date will be set to the latest open period. Make sure the
corresponding period is open for both AP and GL.

IMPORTANT: Undo accounting can affect the Trial Balance report and reconciling Payables to GL. Please see Note 605707.1"UNDERSTANDING HOW
UNDO ACCOUNTING CAN IMPACT RECONCILIATION" for more information on how manual entries created by the undo fix can affect reconciliation.

The script utilizes a new package to undo/reverse accounting. The package name is AP_ACCTG_DATA_FIX_PKG and it should be created/compiled before
running the ap_undo_acctg.sql script. If development provides you the undo script for a datafix, it should include the files for the new package and
instructions to compile the package before running the script e.g.

1. Please download and compile apgdfals.pls and apgdfalb.pls


Or

For R12.0:

Please download and apply patch 8471406 and Pre-Req/Co-Req patch 9177085 to get the latest Generic Datafix Package with the latest undo accounting
code.

For R12.1:

Please download and apply patch 8471406 to get the latest Generic Datafix Package with the latest undo accounting code.

Note: The instance does not need to be brought down to apply this patch, you can apply it in hotpatch mode e.g. adpatch option=hotpatch

2. Run ap_undo_acctg.sql with the following parameters:

 P_EVENT_ID -- This can be null if all of the events related to an invoice or payment are to be unaccounted.
 P_SOURCE_TABLE -- AP_INVOICES or AP_PAYMENTS
 P_SOURCE_ID -- The invoice id or check id to be unaccounted.
 P_BUG_ID -- The bug number under which the fix was provided. This is logged in the AP_undo_event_log table so we can keep track of which
bugs are responsible for the undo of which events.
 GL_DATE -- If transaction is in closed period, then enter GL date to which it has to be swept. Format like 01-APR-2009. If left blank the GL Date
will default to the latest Open Period.
 L_USER_NAME*** -- Your user name (case insensitive)
 L_RESP_NAME ***-- Responsibility Name(Case Sensitive)

***Make sure you are using a responsibility name and user name for a payables responsibility and associated user that have access to run accounting for the
subject transaction.

3. Run the Transfer Journal Entries to GL process to transfer the reversing entries. The reversing entries created by the undo are not automatically
transferred. You MUST run the Transfer Journal Entries to GL program after you run any data fix that uses the undo fix. And you must run with Process
Category parameter = Blank or 'Manual' to pick up the reversing entries.

4. If the undo included transferred accounting, please follow the instructions in Note 553484.1 to rebuild the Trial Balance. This step will remove the
old/undone accounting from the xla_trial_balances table and from the Trial Balance report.

Note: This is just one example of how the instructions for the undo script may be presented in a datafix bug. Please make sure you follow the instruction from
the bug/SR and only use this note as a reference.

Queries to review and compare the incorrect, reversal, and corrected entries:

(If the ap_undo_event_log table is populated)

Note: The scripts provided below use the bug number the undo was ran for to return results. If the undo script ran did not pass a bug number or you want to
see the related entries for a specific check_id, invoice_id, the original event_id, etc... change the where bug_id = &bug_number condition to where invoice_id
= &invoice, where check_id = &check_id, where event_id = &event_id.

1. Query the events updated/created by the undo script

select event_id original_event_id , e2 reversal_event_id,


e3 event_id_related_to_orig_acctg,
decode(status, 'S', 'success', 'U', 'unhandled exception', status) status,
invoice_id, check_id, bug_id
from AP_undo_event_log
where bug_id = &bug_number;

2. Query for original/incorrect accounting

select distinct xeh.event_id, xeh.ledger_id,


xel.*
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e3 = xeh.event_id
and undo.bug_id = &bug_number
order by xeh.event_id, xeh.ledger_id;

select xeh.ledger_id,
sum(xel.accounted_dr), sum(xel.accounted_cr),
count(distinct xeh.ae_header_id), count(distinct xel.ae_header_id||xel.ae_line_num), count(*)
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e3 = xeh.event_id
and undo.bug_id = &bug_number
group by xeh.ledger_id;
3. Query for original/incorrect reversal accounting

select distinct xeh.event_id, xeh.ledger_id,


xel.*
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e2 = xeh.event_id
and undo.bug_id = &bug_number
order by xeh.event_id, xeh.ledger_id;

select xeh.ledger_id,
sum(xel.accounted_dr), sum(xel.accounted_cr),
count(distinct xeh.ae_header_id), count(distinct xel.ae_header_id||xel.ae_line_num), count(*)
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e2 = xeh.event_id
and undo.bug_id = &bug_number
group by xeh.ledger_id;

4. Query for New/correct accounting

select distinct xeh.event_id, xeh.ledger_id,


xel.*
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.event_id = xeh.event_id
and undo.bug_id = &bug_number
order by xeh.event_id, xeh.ledger_id;

select xeh.ledger_id,
sum(xel.accounted_dr), sum(xel.accounted_cr),
count(distinct xeh.ae_header_id), count(distinct xel.ae_header_id||xel.ae_line_num), count(*)
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.event_id = xeh.event_id
and undo.bug_id = &bug_number
group by xeh.ledger_id;

(If the ap_undo_event_log table is NOT populated)

Invoices

select distinct xte2.*


from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.*
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
)
order by 1;

select *
from xla_events
where application_id = 200
and entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
))
order by event_id;

select *
from xla_ae_headers
where application_id = 200
and event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
)))
order by ae_header_id;

select *
from xla_ae_lines
where application_id = 200
and ae_header_id in (
select xeh.ae_header_id
from xla_ae_headers xeh
where xeh.application_id = 200
and xeh.event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
))))
order by ae_header_id;

Payments

select distinct xte2.*


from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.*
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
)
order by 1;

select *
from xla_events
where application_id = 200
and entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
))
order by event_id;

select *
from xla_ae_headers
where application_id = 200
and event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
)))
order by ae_header_id;

select *
from xla_ae_lines
where application_id = 200
and ae_header_id in (
select xeh.ae_header_id
from xla_ae_headers xeh
where xeh.application_id = 200
and xeh.event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
))))
order by ae_header_id;

Troubleshooting ap_undo_acctg.sql

1. Make sure you are using a responsibility name and user name for a payables responsibility and associated user that have access to run accounting for
the subject transaction.

2. If the event undone is in a closed period, make sure the GL Date entered or the default date corresponds with an open period in AP and GL.

3. Make sure the account numbers corresponding to the event to be undone are valid account numbers.

Please run the following query to get the ccid for the accounts:

SELECT code_combination_id CCID


FROM gl_code_combinations
WHERE segment1 = '&segment1'
AND segment2 = '&segment2'
AND segment3 = '&segment3'
AND segment4 = '&segment4'
AND segment5 = '&segment5' ;

Then run the following to verify the ccids are valid:

select gcc.code_combination_id, gcc.chart_of_accounts_id, detail_posting_allowed_flag,


detail_budgeting_allowed_flag, account_type, enabled_flag, summary_flag,
start_date_active, end_date_active,
substr(fnd_flex_ext.get_segs('SQLGL','GL#', gsob.chart_of_accounts_id,
gcc.code_combination_id),1,35) account
from gl_code_combinations gcc,
gl_sets_of_books gsob
where gsob.set_of_books_id = 1
and gsob.chart_of_accounts_id = gcc.chart_of_accounts_id
and gcc.code_combination_id in (&ccid);

4. Check the Undo package version

select *
from dba_source
where line = 2
and name = 'AP_ACCTG_DATA_FIX_PKG';

5. Get the FND Debug log for the ap_undo_acctg.sql script.

5.1. Navigate Responsibility: System Administrator > Profile > System > Query

User: Enter the username the script will be ran for (L_USER_NAME)
Profile: FND:%Debug%

Set the following Profile values at the user level

FND: Debug Log Enabled = Yes


FND: Debug Log Level = Statement
FND: Debug Log Module = %

5.2. Get the current log sequence in the FND table.

select max(log_sequence) from fnd_log_messages ; -- start

5.3. Run ap_undo_acctg.sql

5.4. Get the log sequence in the FND table after the undo script completes.

select max(log_sequence) from fnd_log_messages ; -- end

5.5. Get the FND Debug log data for the undo script.

select * from fnd_log_messages where log_sequence between <start> and <end>;

5.6. Spool this into an xls file.

6. Review the log file created by the ap_undo_acctg.sql script. Use the following script to determine
the location of the log file:

SELECT decode(instr(value,','),0,value, SUBSTR (value,1,instr(value,',') - 1))


FROM v$parameter
WHERE name = 'utl_file_dir';

Related

Products

 Oracle E-Business Suite > Financial Management > Procure to Pay > Oracle Payables

Back to top

Anda mungkin juga menyukai