Negative Ledger Id Dfix - SQL
Negative Ledger Id Dfix - SQL
+================================================================================+
REM |
|
REM | File Name : Negative_ledger_id_dfix.txt
|
REM |
|
REM | Issue: Data exists in GL with Negative ledger_id.
|
REM | |
REM | Fix Approach : Run this script to purge the negative ledger_id data in GL.
|
REM | This script has to be run only by providing primary ledger_id.
|
REM |
|
REM | USAGE
|
REM | Supply the following when prompted:
|
REM | 1) P_File_name : Provide file_name in .html format
|
REM | 2) P_Ledger_id : Provide Primary_ledger_id
|
REM | 3) P_Bug_Number: Provide Bug number
|
REM | (Provide only numbers without wild card characters)
|
REM | 4) P_je_source_name: Provide Journal Entry Soruce_name
|
REM
*================================================================================*/
set verify off
set linesize 20000
Set ECHO OFF
set heading on
Set MARKUP HTML ON SPOOL ON
Set trimspool on
set pagesize 500;
set serveroutput on;
SPOOL &p_file_name
PROMPT
PROMPT
update gl_je_batches
set budgetary_control_status = 'R'
where je_batch_id in
(select distinct je_batch_id from gl_invalid_jrnls_&P_BUG_NUMBER )
and actual_flag in ('A', 'E')
and budgetary_control_status = 'P';
PROMPT
declare
CURSOR rev_batch is
select distinct b.rowid, b.je_batch_id ,b.name
from gl_je_batches b,
gl_invalid_jrnls_&P_BUG_NUMBER b1
where b.je_batch_id = b1.je_batch_id;
x_row_id VARCHAR2(1000);
x_je_batch_id number;
x_name VARCHAR2(1000);
begin
DBMS_OUTPUT.ENABLE(null);
loop
fetch rev_batch into x_row_id, x_je_batch_id, x_name;
exit when rev_batch%NOTFOUND;
end loop;
exception
when others then
DBMS_OUTPUT.PUT_LINE('error for batch name: '||x_name||' '|| SQLERRM);
end;
/
UNDEFINE P_FILE_NAME
UNDEFINE P_LEDGER_ID
UNDEFINE P_BUG_NUMBER
UNDEFINE P_JE_SOURCE_NAME