Você está na página 1de 72

CREATE OR REPLACE PACKAGE BODY XXYH_TRIT_PKG AS

--
/*******************************************************************************
*********
** TITLE :- XXYH_TRIT_PKG
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :- XXYH_TRIT_PKG.pls
** AUTHOR :- Haribabu
** VERSION :- 1.0
** CONTENTS :- Package creation script
** DESCRIPTION :- This is common package which has all the code units for
** Trintech extracts
** INPUTS :- all the procedures in one package
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 30-JUN-08 Balajee Kalla Initial Version of Code
** 29-JUL-08 Haribabu Pantakapu recon_net_disbursements
** 16-SEP-08 Haribabu Pantakapu Companies to be included: based on GL Bala
nce extract value listing
** Accounts to be included: only include 15xx
xx or 16xxxx accounts from FA subledger
** 29-SEP-08 Haribabu Pantakapu rcn dv reconciliation, rcn_dv_gen, rcn_dv_
ap, rcn_dv_ar
** 28-OCT-08 Haribabu Pantakapu Change Requests - Reconnet Reconciliation
** 14-NOV-08 Haribabu Pantakapu Reverse the sign on the amounts for Accumu
lated Depr accounts
** 18-NOV-08 Haribabu Pantakapu ASN GL Extract
** Exclude enabled_flag and end_date condit
ion for value set YGLOBAL_ACCOUNT
** ASN AP Extract
** Enabled Flag and end_date condition shou
ld be added to all the
** XXYH value sets and exclude for YGLOBAL_
ACCOUNT
** FA SubLedget Extract
** Exclude enabled_flag and end_date condit
ion for value set YGLOBAL_ACCOUNT
** Reconnet disbursement program,Reconnet Dep
osits Extract program
** The two programs will be removed from Trin
tech Package, will be no longer used.
** Yahoo! Trintech Reconnet Reconciliation re
placement for two programs.
** 08-Dec-08 Haribabu Pantakapu Change Request
** 1) Extract File Name change for all extrac
ts
** 2) DFFs and Value Sets for Selection and G
rouping rules change
** for all assurenet extracts
** 20-Jan-09 Haribabu Pantakapu Change Request
** 1) DFF at Set of Books to exclude the STAT
set of books
** 26-Jan-09 Haribabu Pantakapu Change Request
1) Exclude the FA books from the collapsed
entities
view defined based on FA_BOOK_CONTROLS
to exclude
** 10-Feb-09 Haribabu Pantakapu 1) AX Changes - for Reconnet AR and AP.
** 20-NOV-08 Haribabu/Kthakur Changes to xxyh_trin_get_trial_bal_data
call to process ap trial bal for 11.5.10 CRP
** 09-Mar-09 Haribabu Pantakapu 1) Added new function to get gl_date - get
_max_gl_date
This function is copied from ap_invoice
_payments_pkg
2) Added 3 new columns void_date, cleared_
date and gl_date
ap extract, rcn_dv_gen, rcn_dv_ap proce
dure modified
** 19-Mar-09 Haribabu Pantakapu 1) Removed the function get_max_gl_date.
** 14-SEP-2009 Sai Prasad Added Latam logic for GL
** 17-SEP-09 Gowtam Kamath Created procedure asn_gl_trx
********************************************************************************
**********/
x_progress VARCHAR2(250);
x_rec_cnt NUMBER;
x_rec_sum NUMBER;
x_user_id NUMBER := fnd_global.user_id;
x_request_id NUMBER := fnd_global.conc_request_id;
x_prog_appl_id NUMBER := fnd_global.prog_appl_id;
x_conc_program_id NUMBER := fnd_global.conc_program_id;
x_resp_id NUMBER := fnd_global.resp_id;
x_resp_appl_id NUMBER := fnd_global.resp_appl_id;
--
x_sfile VARCHAR2(50);
x_dfile VARCHAR2(50);
--
x_tfile VARCHAR2(50) := 'Y';

--
FUNCTION clean_str(in_string in varchar2) RETURN VARCHAR2
IS
out_string varchar2(4000);
remove_char varchar2(100);
BEGIN
remove_char:='(!@#$%^&*?):;,?~'; -- added few other special characters
SELECT TRANSLATE(in_string,remove_char , ' ') INTO out_string FROM dual;
RETURN (out_string);
END;
--
PROCEDURE println (p_mode NUMBER, p_string IN VARCHAR2) IS
BEGIN
IF p_mode = 1 THEN
fnd_file.put_line(fnd_file.output, p_string);
ELSIF p_mode = 2 THEN
fnd_file.put_line(fnd_file.log, p_string);
ELSIF p_mode = 3 THEN
fnd_file.put_line(fnd_file.output, p_string);
fnd_file.put_line(fnd_file.log, p_string);
END IF;
END println;
--
PROCEDURE cp_output(p_prg VARCHAR2, p_sfile VARCHAR2, p_dfile VARCHAR2)
IS
lv_conreq_id NUMBER := 0;
lv_resp_id NUMBER;
BEGIN
--ReturnCode := FND_REQUEST.SET_MODE(TRUE);
println(2,'Program : '|| p_prg);
println(2,'S File : '||p_sfile);
println(2,'D File '||p_dfile);
fnd_global.apps_initialize (
user_id => x_user_id,
resp_appl_id => x_resp_appl_id,
resp_id => x_resp_id);

IF x_tfile = 'Y' THEN


lv_conreq_id := FND_REQUEST.SUBMIT_REQUEST('CP', 'XXYH_FTP_TRN_FILE_COPY',
'', SYSDATE+0.001
, FALSE,
p_prg, p_sfile, p_dfile); /*,
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','');*/
END IF;
IF lv_conreq_id IS NULL THEN
println(2, 'Error occured in copying the file ');
ELSE
println(2, 'concurrent program id : '||lv_conreq_id);
END IF;
END cp_output;
--
/*******************************************************************************
*********
** TITLE :- PROCEDURE asn_gl_trx
** FILE NAME :-
** AUTHOR :- Gowtam Kamath
** VERSION :- 0.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This procedure is to extract GL Transactions
** INPUTS :- p_posting_date (mandatory)
,p_period_name (mandatory)
** ,p_entity (mandatory)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 17-SEP-09 Gowtam Kamath Created procedure asn_gl_trx
********************************************************************************
**********/
PROCEDURE asn_gl_trx(errbuf OUT NOCOPY VARCHAR2
,retcode OUT NOCOPY NUMBER
,p_posting_date IN VARCHAR2
,p_period_name IN VARCHAR2
,p_entity IN VARCHAR2
)
AS
-- declare cursor
CURSOR lcu_gl_trxs(posting_date IN VARCHAR2,
period IN VARCHAR2,
entity IN VARCHAR2
)
IS
SELECT gcc.segment1,
gcc.segment2,
gcc.segment3,
gcc.segment4,
gcc.segment5,
gcc.segment6,
gcc.segment7,
gcc.segment8,
gcc.segment9,
gcc.segment10,
last_day ('01-'||gjh.period_name) effective_date,
gsb.currency_code ccy2code,
NVL(gjl.accounted_dr,0)-NVL(gjl.accounted_cr,0) ccy2_balance,
gjh.currency_code ccy3code,
NVL(gjl.entered_dr,0)-NVL(gjl.entered_cr,0) ccy3_balance,
gjh.name journal,
gjh.description journal_description,
gjh.period_name,
gjh.je_source,
gcc.concatenated_segments string,
git.transaction_number ic_number,
ssub.name ic_sender,
rsub.name ic_receiver,
git.type_name ic_type,
git.currency_code ic_currency,
git.description ic_description,
git.note ic_note,
gjh.posted_date
FROM gl_je_headers gjh,
gl_je_lines gjl,
gl_iea_transaction_lines gil,
gl_iea_transactions_v git,
gl_sets_of_books gsb,
xxyh_trit_sob_v gsob,
gl_code_combinations_kfv gcc,
gl_iea_subsidiaries ssub,
gl_iea_subsidiaries rsub,
fnd_flex_value_sets ffvs, fnd_flex_values ffv
WHERE gjl.je_header_id = gjh.je_header_id
AND gjl.reference_1 = git.transaction_number
AND ssub.subsidiary_id = git.sending_subsidiary_id
AND rsub.subsidiary_id = git.receiving_subsidiary_id
AND ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffvs.flex_value_set_name = 'YGLOBAL_COMPANY'
AND ffv.flex_value = gcc.segment1
AND NVL(ffv.attribute14, 'Y') = 'Y'
AND gjl.reference_2 = TO_CHAR(git.transaction_id)
AND gil.sender_receiver_code = DECODE (gjl.reference_5, 'SENDER', 'S', 'RECEI
VER', 'R')
AND gjl.code_combination_id = gcc.code_combination_id
AND git.transaction_id = gil.transaction_id
AND gsb.set_of_books_id = gjh.set_of_books_id
AND gsob.set_of_books_id = gjh.set_of_books_id
-- AND gjl.code_combination_id = 142789
AND gcc.segment2 IN (SELECT flex_value FROM fnd_flex_values_vl
where flex_value_set_id IN (SELECT flex_value_set_id FROM fnd_flex_value_sets
where flex_value_set_name like 'XXYH_TRINTECH_IC_ACCOUNTS'
) )
AND TRUNC(gjh.posted_date) = TO_DATE(posting_date,'YYYY/MM/DD HH24:MI:SS')
AND gjh.period_name = period
AND ((entity = 'XXYH_TRIT_US' AND GSOB.currency_code = 'USD') OR (entity = 'X
XYH_TRIT_EU' AND GSOB.currency_code <> 'USD'))
UNION
SELECT gcc.segment1,
gcc.segment2,
gcc.segment3,
gcc.segment4,
gcc.segment5,
gcc.segment6,
gcc.segment7,
gcc.segment8,
gcc.segment9,
gcc.segment10,
last_day ('01-'||gjh.period_name) effective_date,
gsb.currency_code ccy2code,
NVL(gjl.accounted_dr,0)-NVL(gjl.accounted_cr,0) ccy2_balance,
gjh.currency_code ccy3code,
NVL(gjl.entered_dr,0)-NVL(gjl.entered_cr,0) ccy3_balance,
gjh.name journal,
gjh.description journal_description,
gjh.period_name,
gjh.je_source,
gcc.concatenated_segments string,
NULL ic_number,
NULL ic_sender,
NULL ic_receiver,
NULL ic_type,
NULL ic_currency,
NULL ic_description,
NULL ic_note,
gjh.posted_date
FROM gl_je_headers gjh,
gl_je_lines gjl,
gl_sets_of_books gsb,
xxyh_trit_sob_v gsob,
gl_code_combinations_kfv gcc,
fnd_flex_value_sets ffvs, fnd_flex_values ffv
WHERE gjl.je_header_id = gjh.je_header_id
AND gjl.code_combination_id = gcc.code_combination_id
AND gsb.set_of_books_id = gjh.set_of_books_id
AND gjl.reference_2 IS NULL
AND ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffvs.flex_value_set_name = 'YGLOBAL_COMPANY'
AND ffv.flex_value = gcc.segment1
AND NVL(ffv.attribute14, 'Y') = 'Y'
-- AND gjh.je_source = 'Revaluation'
AND gsob.set_of_books_id = gjh.set_of_books_id
-- AND gjl.code_combination_id = 142789
AND gcc.segment2 IN (SELECT flex_value FROM fnd_flex_values_vl
where flex_value_set_id IN (SELECT flex_value_set_id FROM fnd_flex_value_sets
where flex_value_set_name like 'XXYH_TRINTECH_IC_ACCOUNTS'
) )
AND TRUNC(gjh.posted_date) = TO_DATE(posting_date,'YYYY/MM/DD HH24:MI:SS')
AND gjh.period_name = period
AND ((entity = 'XXYH_TRIT_US' AND GSOB.currency_code = 'USD') OR (entity = 'X
XYH_TRIT_EU' AND GSOB.currency_code <> 'USD'));
CURSOR lcu_ccy1_data(currency IN VARCHAR2,
amount IN NUMBER,
period IN VARCHAR2
)
IS
SELECT GDR.conversion_rate,
ROUND(amount * GDR.conversion_rate,2) converted_amount
FROM gl_daily_rates GDR
WHERE 1 = 1
AND GDR.from_currency = currency
AND GDR.to_currency = 'USD'
AND GDR.conversion_type = 'Corporate'
AND GDR.conversion_date = last_day('01-'||period);
-- declare variables
lv_stage VARCHAR2(100);
lv_rec VARCHAR2(1000);
lv_header VARCHAR2(1000);
lv_footer VARCHAR2(200);
ln_counter NUMBER;
ln_conv_rate NUMBER;
ln_conv_amount NUMBER;
ln_conv_total_amount NUMBER;
lkv_CCY1_CODE_USD VARCHAR2(5) := 'USD';
lv_extract_date VARCHAR2(20) := TO_CHAR(SYSDATE,'YYYYMMDD');
lkv_ACCOUNT_SEGMENT1 CONSTANT VARCHAR2(20) := 'Account Segment1';
lkv_ACCOUNT_SEGMENT2 CONSTANT VARCHAR2(20) := 'Account Segment2';
lkv_ACCOUNT_SEGMENT3 CONSTANT VARCHAR2(20) := 'Account Segment3';
lkv_ACCOUNT_SEGMENT4 CONSTANT VARCHAR2(20) := 'Account Segment4';
lkv_ACCOUNT_SEGMENT5 CONSTANT VARCHAR2(20) := 'Account Segment5';
lkv_ACCOUNT_SEGMENT6 CONSTANT VARCHAR2(20) := 'Account Segment6';
lkv_ACCOUNT_SEGMENT7 CONSTANT VARCHAR2(20) := 'Account Segment7';
lkv_ACCOUNT_SEGMENT8 CONSTANT VARCHAR2(20) := 'Account Segment8';
lkv_ACCOUNT_SEGMENT9 CONSTANT VARCHAR2(20) := 'Account Segment9';
lkv_ACCOUNT_SEGMENT10 CONSTANT VARCHAR2(20) := 'Account Segment10';
lkv_EFFECTIVE_DATE CONSTANT VARCHAR2(20) := 'Effective Date';
lkv_DATE1 CONSTANT VARCHAR2(10) := 'Date1';
lkv_DATE2 CONSTANT VARCHAR2(10) := 'Date2';
lkv_CCY1_CODE CONSTANT VARCHAR2(10) := 'CCY1 Code';
lkv_CCY1_GLEND_BALANCE CONSTANT VARCHAR2(20) := 'CCY1 GL End Balance';
lkv_CCY2_CODE CONSTANT VARCHAR2(10) := 'CCY2 Code';
lkv_CCY2_GLEND_BALANCE CONSTANT VARCHAR2(20) := 'CCY2 GL End Balance';
lkv_CCY3_CODE CONSTANT VARCHAR2(10) := 'CCY3 Code';
lkv_CCY3_GLEND_BALANCE CONSTANT VARCHAR2(20) := 'CCY3 GL End Balance';
lkv_GL_DESCRIPTION CONSTANT VARCHAR2(20) := 'GL Description';
lkv_GL_PERIOD CONSTANT VARCHAR2(20) := 'GL Period';
lkv_GL_SOURCE CONSTANT VARCHAR2(20) := 'GL Source';
lkv_GL_STRING CONSTANT VARCHAR2(20) := 'GL String';
lkv_GL_JOURNAL CONSTANT VARCHAR2(20) := 'GL Journal';
lkv_IC_NUMBER CONSTANT VARCHAR2(20) := 'IC Number';
lkv_IC_SENDER CONSTANT VARCHAR2(20) := 'IC Sender';
lkv_IC_RECEIVER CONSTANT VARCHAR2(20) := 'IC Receiver';
lkv_IC_TYPE CONSTANT VARCHAR2(20) := 'IC Type';
lkv_IC_CURRENCY CONSTANT VARCHAR2(20) := 'IC Currency';
lkv_IC_DESCRIPTION CONSTANT VARCHAR2(20) := 'IC Description';
lkv_IC_NOTE CONSTANT VARCHAR2(20) := 'IC Note';
lkv_FOOTER CONSTANT VARCHAR2(20) := 'FOOTER';
lkv_FILE_NAME_SUFFIX CONSTANT VARCHAR2(20) := 'GL_transactions';
BEGIN
println(2,'asn_gl_trx BEGIN');
println(2,'p_posting_date = '||p_posting_date);
println(2,'p_period_name = '||p_period_name);
println(2,'p_entity = '||p_entity);
lv_stage := '10';
ln_counter := 0;
ln_conv_total_amount :=0;
--Populate Extract Header
lv_header := NULL;
lv_header := lkv_ACCOUNT_SEGMENT1
||','||lkv_ACCOUNT_SEGMENT2
||','||lkv_ACCOUNT_SEGMENT3
||','||lkv_ACCOUNT_SEGMENT4
||','||lkv_ACCOUNT_SEGMENT5
||','||lkv_ACCOUNT_SEGMENT6
||','||lkv_ACCOUNT_SEGMENT7
||','||lkv_ACCOUNT_SEGMENT8
||','||lkv_ACCOUNT_SEGMENT9
||','||lkv_ACCOUNT_SEGMENT10
||','||lkv_EFFECTIVE_DATE
||','||lkv_DATE1
||','||lkv_DATE2
||','||lkv_CCY1_CODE
||','||lkv_CCY1_GLEND_BALANCE
||','||lkv_CCY2_CODE
||','||lkv_CCY2_GLEND_BALANCE
||','||lkv_CCY3_CODE
||','||lkv_CCY3_GLEND_BALANCE
||','||lkv_GL_JOURNAL
||','||lkv_GL_DESCRIPTION
||','||lkv_GL_PERIOD
||','||lkv_GL_SOURCE
||','||lkv_GL_STRING
||','||lkv_IC_NUMBER
||','||lkv_IC_SENDER
||','||lkv_IC_RECEIVER
||','||lkv_IC_TYPE
||','||lkv_IC_CURRENCY
||','||lkv_IC_DESCRIPTION
||','||lkv_IC_NOTE;
println(1,lv_header);
lv_stage := '20';
lv_header := p_period_name||'_'||TO_CHAR(TO_DATE(posting_date,'YYYY/MM/DD HH
24:MI:SS'), 'YYYYMMDD');
println(1,lv_header);
println(2,'Extract Header Populated');
lv_stage := '30';
--Populate Extract Body
FOR lr_rec IN lcu_gl_trxs(p_posting_date
,p_period_name
,p_entity)
LOOP
ln_conv_amount := ROUND(lr_rec.ccy3_balance,2);
IF lr_rec.ccy2code <> 'USD' THEN
OPEN lcu_ccy1_data(lr_rec.ccy2code,
lr_rec.ccy2_balance,
p_period_name
);
FETCH lcu_ccy1_data INTO ln_conv_rate,ln_conv_amount;
CLOSE lcu_ccy1_data;
END IF;
lv_rec := NULL;
ln_conv_total_amount := ln_conv_total_amount + ln_conv_amount;
lv_rec := NVL(lr_rec.segment1,NULL)
||','||NVL(lr_rec.segment2,NULL)
||','||NVL(lr_rec.segment3,NULL)
||','||NVL(lr_rec.segment4,NULL)
||','||NVL(lr_rec.segment5,NULL)
||','||NVL(lr_rec.segment6,NULL)
||','||NVL(lr_rec.segment7,NULL)
||','||NVL(lr_rec.segment8,NULL)
||','||NVL(lr_rec.segment9,NULL)
||','||NVL(lr_rec.segment10,NULL)
||','||TO_CHAR(lr_rec.effective_date, 'MM/DD/YYYY')
||','||TO_CHAR(lr_rec.effective_date,'MM/DD/YYYY')
||','||NULL
||','||lkv_CCY1_CODE_USD
||','||ln_conv_amount
||','||lr_rec.ccy2code
||','||ROUND(lr_rec.ccy2_balance,2)
||','||lr_rec.ccy3code
||','||ROUND(lr_rec.ccy3_balance,2)
||','||NVL(REPLACE(lr_rec.journal,',', ' '),NULL)
||','||NVL(REPLACE(lr_rec.journal_description,',', ' '),NULL)
||','||NVL(lr_rec.period_name,NULL)
||','||NVL(lr_rec.je_source,NULL)
||','||NVL(REPLACE(lr_rec.string,',', ' '),NULL)
||','||NVL(REPLACE(lr_rec.ic_number,',', ' '),NULL)
||','||NVL(REPLACE(lr_rec.ic_sender,',', ' '),NULL)
||','||NVL(REPLACE(lr_rec.ic_receiver,',', ' '),NULL)
||','||NVL(REPLACE(lr_rec.ic_type,',', ' '),NULL)
||','||NVL(lr_rec.ic_currency,NULL)
||','||NVL(REPLACE(lr_rec.ic_description,',', ' '),NULL)
||','||NVL(REPLACE(lr_rec.ic_note,',', ' '),NULL);

println(1,lv_rec);
ln_counter := ln_counter+1;
END LOOP;
lv_stage := '40';
--Populate Extract Footer
lv_footer := lkv_FOOTER||','||ln_counter||','||ln_conv_total_amount;
println(1,lv_footer);
println(2,'Extract Footer Populated');
lv_stage := '50';
-- Launch FileCopy program
println(2,'launching XXYH_FTP_TRN_FILE_COPY program ...');
x_sfile := 'o'||x_request_id||'.out';
x_dfile := lkv_FILE_NAME_SUFFIX||'_'||p_period_name||'_'||TO_CHAR(TO_DATE(p_
posting_date,'YYYY/MM/DD HH24:MI:SS'),'YYYYMMDD')||'_'||lv_extract_date||'.csv';
lv_stage := '60';
cp_output('TRIT-OUT', x_sfile, x_dfile);
println(2,'launching XXYH_FTP_TRN_FILE_COPY program done');
lv_stage := '70';
println(2,'asn_gl_trx END');
EXCEPTION
WHEN OTHERS THEN
println(2,'Program reached the stage '||lv_stage);
println(2,'Error Code = '||SQLCODE||' Error Message = '||SQLERRM);
END asn_gl_trx;
/*******************************************************************************
*********
** TITLE :- PROCEDURE fx_rates_extract
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :-
** AUTHOR :- Tanay Behera
** VERSION :- 1.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This is used to fetch data on a monthly basis for
** FX rates for Trintech
** INPUTS :- p_period_name (mandatory)
** ,p_sob_id (optional)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 09-JUN-08 Tanay Behera Initial Version of Code
** 20-Jan-09 Haribabu Pantakapu Change Request
** 1) DFF at Set of Books to exclude the STAT
set of books
********************************************************************************
**********/
PROCEDURE asn_fx_rates
( errbuf OUT VARCHAR2
,retcode OUT NUMBER
,p_period_name IN VARCHAR2
,p_sob_id IN NUMBER)
AS
-- This cursor is to select the info for the extract.
CURSOR lcu_fx_rates
( name_period IN VARCHAR2
,sobs_id IN NUMBER)
IS
SELECT DISTINCT
to_char(to_date('01-'||GLR.period_name),'MM-DD-YYYY') Effec
tive_Date
,GSOB.currency_code CCY1C
ode
,GLR.to_currency_code CCY2C
ode
,GLR.eop_rate Rate
-- GLR.avg_rate
,'Monthly' Rate_
Type
FROM gl_translation_rates GLR
,xxyh_trit_sob_v GSOB
WHERE GLR.set_of_books_id = GSOB.set_of_books_id
AND GLR.period_name = name_period
AND GSOB.set_of_books_id = NVL(sobs_id,GSOB.set_of_books_id)
AND GLR.actual_flag = 'A'
UNION
SELECT DISTINCT
to_char(to_date('01-'||name_period),'MM-DD-YYYY') Effective
_Date
,GSOB.currency_code CCY1Code
,GSOB.currency_code CCY2Code
,1 Rate
,'Monthly' Rate_Type
FROM xxyh_trit_sob_v GSOB
WHERE GSOB.set_of_books_id = NVL(sobs_id,GSOB.set_of_books_id)
ORDER BY 2,3;
-- declaration of variables.
ln_counter NUMBER;
ln_rate_total NUMBER;
lv_err_stage VARCHAR2(4000);
lv_rec VARCHAR2(200);
--
BEGIN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Entering the loop: ' || SYSDATE);
FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Date,'
||'CCY1Code,'
||'CCY1Code,'
||'Rate,'
||'Rate Type');
ln_counter := 0;
ln_rate_total := 0;
-- Start of the for loop
FOR lr_rec IN lcu_fx_rates
( p_period_name
,p_sob_id)
LOOP
lv_err_stage := 'Printing the values to a output file.';
lv_rec := NULL;
ln_counter := ln_counter + 1;
ln_rate_total := ln_rate_total + lr_rec.Rate;
lv_rec := lr_rec.Effective_Date ||','||lr_rec.CCY1Code||','||lr_rec
.CCY2Code||','||lr_rec.Rate||','||lr_rec.Rate_Type;
-- FND_FILE.PUT_LINE(FND_FILE.LOG, 'The values are: ' || lv_rec);
println(1, lv_rec);
END LOOP;
-- End of the for loop
lv_err_stage := 'Printing the values for the total rate value and re
cord count.';
println(1, 'FOOTER,'|| ln_counter||','||ln_rate_total);
-- launch concurrent program to cp out put to trintech directory
println(2, 'launching cp program ...');
x_sfile := 'o'||x_request_id||'.out';
x_dfile := 'FXRATES_'||to_char(to_date(p_period_name, 'MON-YY'), 'MMYYYY')||T
O_CHAR(SYSDATE,'MMDDYYYY')||'.csv';
--
cp_output('TRIT-OUT', x_sfile, x_dfile);
println(2, 'launching cp program done');
--
EXCEPTION
WHEN OTHERS
THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END asn_fx_rates;
--
FUNCTION xxyh_trin_get_trial_bal_data
(p_sob_id IN NUMBER
,p_request_id IN NUMBER
,p_acctng_date IN DATE
)
RETURN BOOLEAN IS
lv_p_org_where_alb VARCHAR2(2000);
lv_p_org_where_ael VARCHAR2(2000);
lv_p_org_where_asp VARCHAR2(2000);
ld_from_date DATE;
--variable added in CRP 11.5.10 as change in process date 20-Nov-2008
lv_supp_det_alb_where VARCHAR2(100);
lv_supp_acc_where VARCHAR2(100);
lv_supp_ax_acc_where VARCHAR2(100);
--where clause added in CRP 11.5.10 as change in process date 20-Nov-2008
BEGIN
ld_from_date := NULL;
XLA_MO_REPORTING_API.Initialize('1000',p_sob_id,'AUTO');
lv_p_org_where_alb := XLA_MO_REPORTING_API.Get_Predicate('alb',null);
lv_p_org_where_ael := XLA_MO_REPORTING_API.Get_Predicate('ael',null);
lv_p_org_where_asp := XLA_MO_REPORTING_API.Get_Predicate('asp',null);
-- added in CRP 11.5.10 as change in process date 20-Nov-2008
lv_supp_det_alb_where := ' AND 1 = 1 ';
lv_supp_acc_where := ' AND 1 = 1 ';
lv_supp_ax_acc_where := ' AND 1 = 1 ';
-- added in CRP 11.5.10 as change in process date 20-Nov-2008
-- Since the Multi org API, hard codes the value ":p_reporting_entity_id" as a
-- part of the return string, this will work fine with the reports. But for th
e
-- trial balance performance enhancements we have moved the reports side logic
to
-- the server side logic. So we cannot direclty use the bind variables. So
-- used the database REPLACE function on the same strings to replace the
-- hard coded ":p_reporting_entity_id" to the actual value itself. And the sam
e is
-- passed to the server side code.
lv_p_org_where_ael := REPLACE(lv_p_org_where_ael ,
':p_reporting_entity_id',
p_sob_id);
lv_p_org_where_alb := REPLACE(lv_p_org_where_alb,
':p_reporting_entity_id',
p_sob_id);
lv_p_org_where_asp := REPLACE(lv_p_org_where_asp,
':p_reporting_entity_id',
p_sob_id);
IF (AP_TRIAL_BALANCE_PKG.Process_Trial_Balance( p_accounting_date =>
p_acctng_date
,p_from_date =>
ld_from_date
,p_request_id =>
p_request_id
,p_reporting_entity_id =>
p_sob_id
,p_org_where_alb =>
lv_p_org_where_alb
,p_org_where_ael =>
lv_p_org_where_ael
,p_org_where_asp =>
lv_p_org_where_asp
,p_neg_bal_only =>
'N'
,p_debug_switch =>
'Y'
,p_supp_det_alb_where =>
lv_supp_det_alb_where -- Changed for CRP By Kthakur/Haribabu on 20-Nov-2008
,p_supp_acc_where =>
lv_supp_acc_where -- Changed for CRP By Kthakur/Haribabu on 20-Nov-2008
,p_supp_ax_acc_where =>
lv_supp_ax_acc_where -- Changed for CRP By Kthakur/Haribabu on 20-Nov-2008
) <> TRUE) THEN
RETURN FALSE;
END IF;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Occured in Get_Trial_Bal_Data');
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Code :'||SQLCODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Message :'||SQLERRM);
RETURN FALSE;
END;
/*******************************************************************************
*********
** TITLE :- XXYH_AP_SUBLEDGER_RECON_PKG
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :- XXYH_AP_SUBLEDGER_RECON.plb
** AUTHOR :- Tanay Behera
** VERSION :- 1.0
** CONTENTS :- Package creation script
** DESCRIPTION :- This is used to fetch data for Trintech
** INPUTS :- p_account_number (mandatory)
** ,p_sob_id (mandatory)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 21-JUN-08 Tanay Behera Initial Version of Code
** 18-Nov-08 Haribabu Pantakapu Enabled Flag and end_date condition should be
added to all the
XXYH value sets and exclude for â¿¿YGLOBAL_ACCOUNTâ¿¿.
** 08-Dec-08 Haribabu Pantakapu DFFs and Value Sets for selection and groupin
g rules change
** File name change to include sysdate
** 20-Jan-09 Haribabu Pantakapu Change Request
** 1) DFF at Set of Books to exclude the STAT
set of books
** 20-NOV-08 Haribabu/Kthakur Changes to xxyh_trin_get_trial_bal_data
call to process ap trial bal for 11.5.10 CRP
********************************************************************************
**********/
PROCEDURE asn_ap
( errbuf OUT VARCHAR2
,retcode OUT NUMBER
,p_period_name IN VARCHAR2
,p_extract_type IN VARCHAR2
)
AS
-- This cursor is to select the info for all the SOB's
CURSOR lcu_sobs
IS
SELECT set_of_books_id
FROM xxyh_trit_sob_v;
--WHERE set_of_books_id = 42 ; --in (145,446); ---used this for testing
-- This cursor is to select the info for the extract.
CURSOR lcu_subledger_extract
IS
SELECT XASE.*
,XASE.rowid
FROM XXYH_TRIT_AP_SBL_EXT_TMP XASE
ORDER BY 1,2,3,4;
-- declaration of variables.
ln_user_id NUMBER;
ln_request_id NUMBER;
lv_err_stage VARCHAR2(2000);
lv_rec VARCHAR2(2000);
lv_period_name GL_PERIODS.PERIOD_NAME%TYPE;
ln_period_year GL_PERIODS.PERIOD_YEAR%TYPE;
ld_start_date GL_PERIODS.START_DATE%TYPE;
ld_end_date GL_PERIODS.END_DATE%TYPE;
ln_counter NUMBER;
ld_accntg_date GL_PERIODS.START_DATE%TYPE;
--
BEGIN
ln_request_id := FND_GLOBAL.CONC_REQUEST_ID ;
lv_period_name:= NULL;
ln_period_year:= NULL;
ld_start_date := NULL;
ln_counter := NULL;
--ln_request_id := 999999999;
-- Delete all the records from the interim table XXYH_TRIT_AP_TRIAL_BAL
_TMP.
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE XXYH.XXYH_TRIT_AP_TRIAL_BAL_TMP
';
EXCEPTION
WHEN OTHERS THEN
DELETE FROM XXYH_TRIT_AP_TRIAL_BAL_TMP;
COMMIT;
END;
BEGIN
SELECT period_name
,period_year
,start_date
,end_date
INTO lv_period_name
,ln_period_year
,ld_start_date
,ld_end_date
FROM gl_periods
WHERE period_name = p_period_name
AND period_set_name = 'Accounting';
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Code :'||SQLCODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Message :'||SQLERRM);
END;
-- this is to cover all the SOBs
FOR lr_sob_rec IN lcu_sobs
LOOP
BEGIN
--DELETE FROM ap_trial_bal;
DELETE FROM ap_trial_bal_gt;
COMMIT;
lv_err_stage := 'Inserting data by calling the standard Oracle package
for SOB:'|| lr_sob_rec.set_of_books_id;
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Inserting data by calling the standar
d Oracle package for SOB:'|| lr_sob_rec.set_of_books_id ||' '|| ln_re
quest_id);
IF (xxyh_trin_get_trial_bal_data (lr_sob_rec.set_of_books_id, ln_reque
st_id, ld_end_date) != TRUE) THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'This is not success');
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Inserting data by calling the stan
dard Oracle package for SOB:'|| lr_sob_rec.set_of_books_id);
ELSE
BEGIN
lv_err_stage := 'Inserting data into the interim table:'|| lr_sob_r
ec.set_of_books_id;
FND_FILE.PUT_LINE(FND_FILE.LOG, 'This is success for SOB:'|| lr_sob
_rec.set_of_books_id);
INSERT INTO XXYH_TRIT_AP_TRIAL_BAL_TMP
SELECT invoice_id
,code_combination_id
,remaining_amount
,vendor_id
,set_of_books_id
,org_id
,request_id
,invoice_amount
--FROM ap_trial_bal;
FROM ap_trial_bal_gt -- ap_trial_ba
l; -- change for 11.5.10 upgrade
WHERE set_of_books_id = lr_sob_rec.set_of_books_id; --where clause
added in CRP as change in process date 20-Nov-2008
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Code :'||SQLCODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Message :'||SQLERRM);
END;
END IF;
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Code :'||SQLCODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error Message :'||SQLERRM);
END;
END LOOP;
-- end of this is to cover all the SOBs
COMMIT;
FND_FILE.PUT_LINE(FND_FILE.LOG, 'This is success');
lv_err_stage := 'After Inserting data by calling the standard Oracle pack
age';
-- Delete all the records from the interim table.
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE XXYH.XXYH_TRIT_AP_SBL_EXT_TMP';
EXCEPTION
WHEN OTHERS THEN
DELETE FROM XXYH_TRIT_AP_SBL_EXT_TMP;
COMMIT;
END;
ln_user_id := FND_GLOBAL.USER_ID;
FOR lr_inst_rec IN lcu_sobs
LOOP
BEGIN
lv_err_stage := 'Inserting Data for all the Records';
INSERT INTO XXYH_TRIT_AP_SBL_EXT_TMP
( legal_entity
,operating_unit
,concatenated_segments
,supplier_name
,invoice_number
,invoice_date
,invoice_curr
,invoice_amount
,remaining_amount
,accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
--,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amount
,local_amount
,reporting_amount
,period_name
,period_year
,gl_set_of_books_id
,sob_currency
,last_update_date
,last_updated_by
)
SELECT le.name
,ou.name
,gcc.concatenated_segments
,pv.vendor_name
,ai.invoice_num
,ai.invoice_date
,ai.invoice_currency_code
,atb.invoice_amount
,atb.remaining_amount
,gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
-- ,REPLACE(REPLACE(REPLACE(XTAV.flex_desc, ',',''),':',''),
';','')
,ai.invoice_currency_code
,NULL
,NULL
,0 --ai.invoice_amount--,atb.invoice_amount
,atb.remaining_amount -- NULL
,NULL
,lv_period_name
,ln_period_year
,lr_inst_rec.set_of_books_id
,gsob.currency_code
,SYSDATE
,ln_user_id
FROM hr_organization_information OI
,hr_all_organization_units_tl LE
,hr_all_organization_units_tl OU
,XXYH_TRIT_AP_TRIAL_BAL_TMP ATB
,po_vendors PV
,ap_system_parameters_all ASP
,ap_invoices_all AI
,gl_code_combinations_kfv GCC
--,xxyh_trit_account_v XTAV
,xxyh_trit_sob_v GSOB
WHERE NVL(ATB.org_id,-99) = NVL(AI.org_id,-99)
AND NVL(ATB.org_id,-99) = NVL(ASP.org_id,-99)
AND ATB.vendor_id = PV.vendor_id
AND ATB.invoice_id = AI.invoice_id
AND ATB.code_combination_id = GCC.code_combination_
id -- tanay added
AND ATB.set_of_books_id = lr_inst_rec.set_of_bo
oks_id
AND GSOB.set_of_books_id = lr_inst_rec.set_of_bo
oks_id
AND ATB.org_id = OI.organization_id
AND OI.org_information_context = 'Operating Unit Infor
mation'
AND DECODE(LTRIM(OI.org_information3,'0123456789'), NULL
, TO_NUMBER(OI.org_information3)
, NULL ) = lr_inst_rec.set_of_bo
oks_id
AND DECODE(LTRIM(OI.org_information2,'0123456789'), NULL
, TO_NUMBER(OI.org_information2)
, NULL ) = LE.organization_id
AND OU.organization_id = OI.organization_id
AND OU.language = USERENV('LANG')
AND LE.language = USERENV('LANG')
/*AND GCC.segment2 = XTAV.flex_value
AND XTAV.entity IN ('US','EU')
AND GCC.segment1 IN (SELECT XTCV.flex_value
FROM xxyh_trit_company_v XTCV
WHERE XTCV.entity IN ('XXYH_TRIT_US','XX
YH_TRIT_EU')
)*/
AND EXISTS (SELECT 'X'
FROM xxyh_trit_account_v XTAV
WHERE XTAV.flex_value = GCC.segment2
AND ROWNUM = 1)
AND EXISTS (SELECT 'X'
FROM xxyh_trit_company_v XCTV
WHERE XCTV.flex_value = GCC.segment1
AND ROWNUM = 1)
AND GCC.segment2 NOT IN (SELECT ffv.flex_value
FROM fnd_flex_values_vl ffv
,fnd_flex_value_sets ffvs
WHERE ffv.flex_value_set_id = ffvs.f
lex_value_set_id
AND ffvs.flex_value_set_name = 'X
XYH_TRIT_ASN_AP_ACCS'
-- Condition Added By Haribabu on 18-N
ov-2008
AND ffv.enabled_flag = 'Y'
AND SYSDATE BETWEEN nvl(ffv.start
_date_active, SYSDATE)
AND nvl(ffv.end_date_active, S
YSDATE));
EXCEPTION
WHEN OTHERS THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END;
END LOOP;
-- this commit is to make the changes permanent.
COMMIT;
UPDATE XXYH_TRIT_AP_SBL_EXT_TMP XASE
SET accountname = (SELECT REPLACE(REPLACE(REPLACE(XTAV.flex_desc, ',
',''),':',''),';','')
FROM xxyh_trit_account_v XTAV
WHERE XTAV.flex_value = XASE.accountsegment2
AND ROWNUM = 1
);
COMMIT;
-- This it to update for the functional currency and amount
BEGIN
lv_err_stage := 'This it to update for the functional currency and amo
unt for entered_cur = sob_currency ';
UPDATE XXYH_TRIT_AP_SBL_EXT_TMP XASE
SET (--XASE.local_amount,
XASE.local_cur) = (SELECT --XASE1.entered_amount
XASE1.entered_cur
FROM XXYH_TRIT_AP_SBL_EXT_TMP XASE1
WHERE XASE.accountsegmen
t1 = XASE1.accountsegment1
AND NVL(XASE.accountse
gment2,'$') = NVL(XASE1.accountsegment2,'$')
AND NVL(XASE.accountse
gment3,'$') = NVL(XASE1.accountsegment3,'$')
AND NVL(XASE.accountse
gment4,'$') = NVL(XASE1.accountsegment4,'$')
AND NVL(XASE.accountse
gment5,'$') = NVL(XASE1.accountsegment5,'$')
AND NVL(XASE.accountse
gment6,'$') = NVL(XASE1.accountsegment6,'$')
AND NVL(XASE.accountse
gment7,'$') = NVL(XASE1.accountsegment7,'$')
AND NVL(XASE.accountse
gment8,'$') = NVL(XASE1.accountsegment8,'$')
AND XASE.operating_uni
t = XASE1.operating_unit
AND XASE.invoice_numbe
r = XASE1.invoice_number
AND XASE.supplier_name
= XASE1.supplier_name
AND XASE.entered_cur = XASE
1.sob_currency
)
WHERE XASE.entered_cur = XASE.sob_currency ;
lv_err_stage := 'This it to update for the functional currency and amo
unt for entered_cur <> sob_currency ';
UPDATE XXYH_TRIT_AP_SBL_EXT_TMP XASE
SET (--XASE.local_amount,
XASE.local_cur) =(SELECT -- NVL(XASE1.entered_amount,0)*NVL(GT
R.eop_rate,0),
XASE1.sob_currency
FROM XXYH_TRIT_AP_SBL_EXT_TMP XASE1
,gl_translation_rates
GTR
WHERE XASE.accountsegment
1 = XASE1.accountsegment1
AND NVL(XASE.accountseg
ment2,'$') = NVL(XASE1.accountsegment2,'$')
AND NVL(XASE.accountseg
ment3,'$') = NVL(XASE1.accountsegment3,'$')
AND NVL(XASE.accountseg
ment4,'$') = NVL(XASE1.accountsegment4,'$')
AND NVL(XASE.accountseg
ment5,'$') = NVL(XASE1.accountsegment5,'$')
AND NVL(XASE.accountseg
ment6,'$') = NVL(XASE1.accountsegment6,'$')
AND NVL(XASE.accountseg
ment7,'$') = NVL(XASE1.accountsegment7,'$')
AND NVL(XASE.accountseg
ment8,'$') = NVL(XASE1.accountsegment8,'$')
AND XASE.operating_unit
= XASE1.operating_unit
AND XASE.invoice_number
= XASE1.invoice_number
AND XASE.supplier_name
= XASE1.supplier_name
AND XASE.entered_cur
<> XASE1.sob_currency
AND GTR.period_name
= p_period_name
AND GTR.to_curren
cy_code = XASE.entered_cur
AND GTR.set_of_bo
oks_id = XASE.gl_set_of_books_id
AND GTR.set_of_books_id = XASE1
.gl_set_of_books_id
)
WHERE XASE.entered_cur <> XASE.sob_currency ;
-- This it to update for the transactional currency and amount
lv_err_stage := 'This it to update for the transactional currency and
amount for local_cur = USD ';
UPDATE XXYH_TRIT_AP_SBL_EXT_TMP XASE
SET (XASE.reporting_amount,
XASE.reporting_cur) = (SELECT XASE1.local_amount
,XASE1.local_cur
FROM XXYH_TRIT_AP_SBL
_EXT_TMP XASE1
WHERE XASE.accountse
gment1 = XASE1.accountsegment1
AND NVL(XASE.accou
ntsegment2,'$') = NVL(XASE1.accountsegment2,'$')
AND NVL(XASE.accountsegment3,'$') =
NVL(XASE1.accountsegment3,'$')
AND NVL(XASE.accou
ntsegment4,'$') = NVL(XASE1.accountsegment4,'$')
AND NVL(XASE.accou
ntsegment5,'$') = NVL(XASE1.accountsegment5,'$')
AND NVL(XASE.accou
ntsegment6,'$') = NVL(XASE1.accountsegment6,'$')
AND NVL(XASE.accou
ntsegment7,'$') = NVL(XASE1.accountsegment7,'$')
AND NVL(XASE.accou
ntsegment8,'$') = NVL(XASE1.accountsegment8,'$')
AND XASE.operating
_unit = XASE1.operating_unit
AND XASE.invoice_n
umber = XASE1.invoice_number
AND XASE.supplier_name =
XASE1.supplier_name
AND XASE.local_cur
= XASE1.local_cur
AND XASE.local_cur
= 'USD'
)
WHERE XASE.local_cur = 'USD' ;
lv_err_stage := 'This it to update for the transactional currency and
amount for local_cur <> USD ';
UPDATE XXYH_TRIT_AP_SBL_EXT_TMP XASE
SET (XASE.reporting_amount,
XASE.reporting_cur) = (SELECT NVL(XASE1.local_amount,0)*NVL(GT
R.eop_rate,0)
, GTR.to_currency_code
FROM XXYH_TRIT_AP_SBL
_EXT_TMP XASE1
, gl_translation
_rates GTR
WHERE XASE.accountse
gment1 = XASE1.accountsegment1
AND NVL(XASE.accou
ntsegment2,'$') = NVL(XASE1.accountsegment2,'$')
AND NVL(XASE.accountsegment3,'$') =
NVL(XASE1.accountsegment3,'$')
AND NVL(XASE.accou
ntsegment4,'$') = NVL(XASE1.accountsegment4,'$')
AND NVL(XASE.accou
ntsegment5,'$') = NVL(XASE1.accountsegment5,'$')
AND NVL(XASE.accou
ntsegment6,'$') = NVL(XASE1.accountsegment6,'$')
AND NVL(XASE.accou
ntsegment7,'$') = NVL(XASE1.accountsegment7,'$')
AND NVL(XASE.accou
ntsegment8,'$') = NVL(XASE1.accountsegment8,'$')
AND XASE.operating
_unit = XASE1.operating_unit
AND XASE.invoice_n
umber = XASE1.invoice_number
AND XASE.supplier_
name = XASE1.supplier_name
AND GTR.period_nam
e = p_period_name
AND GTR.to_c
urrency_code = 'USD'
AND GTR.set_
of_books_id = XASE1.gl_set_of_books_id
AND GTR.set_
of_books_id = XASE.gl_set_of_books_id
)
WHERE XASE.local_cur <> 'USD' ;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END;
-- Printing the Header here.
-- processing the summay
IF p_extract_type = 'Y' THEN
INSERT INTO XXYH_TRIT_AP_SBL_EXT_TMP
(
legal_entity
,operating_unit
,concatenated_segments
,supplier_name
,invoice_number
,invoice_date
,invoice_curr
,invoice_amount
,remaining_amount
,invoice_description
,accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,local_cur
,entered_cur
,reporting_cur
,entered_amount
,local_amount
,reporting_amount
,period_type
,period_name
,period_year
,period_num
--,last_update_date
--,last_updated_by
,gl_set_of_books_id
,sob_currency
--,user_id
--,date_created
)
SELECT
null --legal_entity
,null --,operating_unit
,null --,concatenated_segments
,null --,supplier_name
,null --,invoice_number
,null --,invoice_date
,null --,invoice_curr
,null --,invoice_amount
,null --,remaining_amount
,null --,invoice_description
,accountsegment1
,accountsegment2
,accountsegment3
,null --,accountsegment4
,null --,accountsegment5
,null --,accountsegment6
,null --,accountsegment7
,null --,accountsegment8
,null --,accountsegment9
,null --,accountsegment10
,accountname
,local_cur
,'USD' -- entered_cur
,reporting_cur
,SUM(entered_amount)
,SUM(local_amount)
,SUM(reporting_amount)
,period_type
,period_name
,period_year
,period_num
--,last_update_date
--,last_updated_by
,gl_set_of_books_id
,sob_currency
--,user_id
--,date_created
FROM XXYH_TRIT_AP_SBL_EXT_TMP
GROUP BY
accountsegment1
,accountsegment2
,accountsegment3
,accountname
,local_cur
-- ,entered_cur
,reporting_cur
,period_type
,period_name
,period_year
,period_num
,gl_set_of_books_id
,sob_currency;
delete from XXYH_TRIT_AP_SBL_EXT_TMP where legal_entity is not null;
commit;
END IF;
-- end processing summary

-- Printing the Header here.


println(2, 'Printing the Header Info: ' || SYSDATE);
println(1, ' AccountSegment1,'
||'AccountSegment2,'
||'AccountSegment3,'
||'AccountSegment4,'
||'AccountSegment5,'
||'AccountSegment6,'
||'AccountSegment7,'
||'AccountSegment8,'
||'AccountSegment9,'
||'AccountSegment10,'
||'Account_Name,'
||'CCY1Code,'
||'CCY1GLEndBalance,'
||'CCY2Code,'
||'CCY2GLEndBalance,'
||'CCY3Code,'
||'CCY3GLEndBalance,'
||'Period,'
||'Year'
);
-- Start of the for loop
x_rec_cnt := 0;
x_rec_sum := 0;
FOR lr_rec IN lcu_subledger_extract
LOOP
lv_err_stage := 'Printing the values to a output file.';
lv_rec := NULL;
/*lv_rec := lr_rec.legal_entity ||','||lr_rec.operating_unit||','||
lr_rec.concatenated_segments
||','||clean_str(lr_rec.supplier_name)||','||lr_rec.invoice_numb
er||','||to_char(lr_rec.invoice_date,'DD-MON-YYYY')
||','||lr_rec.invoice_curr||','||lr_rec.invoice_amount||','||lr_
rec.remaining_amount
||','||xxyhclean_str(lr_rec.invoice_description);*/
lv_rec := lr_rec.accountsegment1||','||lr_rec.accountsegment2||','|
|lr_rec.accountsegment3
||','||lr_rec.accountsegment4||','||lr_rec.accountsegment5||','|
|lr_rec.accountsegment6
||','||lr_rec.accountsegment7||','||lr_rec.accountsegment8||','|
|lr_rec.accountsegment9
||','||lr_rec.accountsegment10||','||clean_str(lr_rec.accountnam
e)
||','||lr_rec.reporting_cur||','||round(lr_rec.reporting_amount,
2)*-1
||','||lr_rec.local_cur||','||round(lr_rec.local_amount,2)*-1
||','||lr_rec.entered_cur||','||round(lr_rec.entered_amount,2)*-
1
||','||to_char(to_date(lr_rec.period_name, 'MON-YY'), 'MM')||','
||lr_rec.period_year;

println(1, lv_rec);
x_rec_cnt := x_rec_cnt + 1;
x_rec_sum := x_rec_sum + round(lr_rec.reporting_amount,2)*-1;

END LOOP;
-- End of the for loop
println(1,'FOOTER,'||x_rec_cnt||','||x_rec_sum);
-- launch concurrent program to cp out put to trintech directory
println(2, 'launching cp program ...');
x_sfile := 'o'||x_request_id||'.out';
x_dfile := 'APBAL_'||to_char(to_date(p_period_name, 'MON-YY'), 'MMYYYY')||TO_
CHAR(SYSDATE,'MMDDYYYY')||'.csv';
--
cp_output('TRIT-OUT', x_sfile, x_dfile);
println(2, 'launching cp program done');
--
EXCEPTION
WHEN OTHERS
THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END asn_ap;
--
PROCEDURE asn_gl_USSOB(p_period_name IN VARCHAR2,
p_entity IN VARCHAR2
)
AS
BEGIN
INSERT INTO xxyh_trit_tmp
( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,final_yn
,attribute16
,attribute15
)
SELECT gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,1
,SUM( ( NVL(GB.begin_balance_dr,0) + NVL(GB.period_net_dr,0)
) - ( NVL(GB.begin_balance_cr,0) + NVL(GB.period_net_cr,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr
_beq,0) ) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr
_beq,0) ) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) ))
,GB.period_name
,GB.period_year
,'N'
,XTAV.group_by --attribute16
,XTAV.eu_entered -- attribute15
FROM gl_balances GB
,gl_code_combinations GCC
,xxyh_trit_sob_v GSOB
,xxyh_trit_account_v XTAV
,xxyh_trit_company_v XTCV
WHERE GB.set_of_books_id = GSOB.set_of_books_id
AND GSOB.chart_of_accounts_id = GCC.chart_of_accounts_id
AND GCC.code_combination_id = GB.code_combination_id
AND GCC.segment2 = XTAV.flex_value
AND XTAV.entity = p_entity--SUBSTR(lv_value_set,11,
2)
--AND GSOB.name NOT IN ('YAHOO! CONSOLIDATED',
'YAHOO! DUMMY')
AND GB.period_name = p_period_name
AND NVL(GB.translated_flag,'R') = 'R'
AND GB.currency_code != 'STAT' -- Added By Haribabu
AND GCC.segment1 = XTCV.flex_value
AND XTCV.entity = p_entity--lv_value_set
/*AND EXISTS (SELECT 'X'
FROM xxyh_trit_company_v XTCV
WHERE XTCV.flex_value = GCC.segment1
AND XTCV.entity = lv_value_set
)*/
and gsob.currency_code = 'USD'
GROUP BY
gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,GB.period_name
,GB.period_year
,1
--,decode(GSOB.currency_code,GTR.to_currency_code,1,NVL(GTR.e
op_rate,0))
,XTAV.group_by
,XTAV.eu_entered;
fnd_file.put_line(fnd_file.log,'Total Recs'||SQL%ROWCOUNT);
END asn_gl_USSOB;
/*******************************************************************************
******************************
** TITLE :- PROCEDURE gl_balances_extract
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :-
** AUTHOR :- Tanay Behera
** VERSION :- 1.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This is used to fetch data on a monthly basis for
** GL Balances for Trintech
** INPUTS :- p_period_name,p_value_set (mandatory)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 11-JUN-08 Tanay Behera Initial Version of Code
** 19-JUN-08 Tanay Behera Code modified not to include consolidated SOB
** 20-JUN-08 Tanay Behera Code modified to have year to date info.
** 10-JUL-08 Balajee Kalla clean_str added and few changes related flex val
ues validations
** 11-JUL-08 Tanay Behera Made changes to the function clean_str and other
changes for issues raised
** 04-AUG-08 Tanay Behera Added a new interim table to improve performance
, i.e. XXYH_TRIN_TECH_INT
** 27-AUG-08 Haribabu Pantakapu Added condition to handle Unchecked and end da
ted flex values for XXYH_TRIT_ASN_EU_GL_ACCS
** 29-AUG-08 Haribabu Pantakapu Added condition to exclude STAT currencies.
** 10-OCT-08 Haribabu Pantakapu Uncommented Group By clause in the insert stmt
to fix the issue in PROD
** 10-OCT-08 Haribabu Pantakapu Incorporate the new value set to derive the fu
nctional amts XXYH_TRIT_ASN_US_GL_GB_ACC
** 18-NOV-08 Haribabu Pantakapu Exclude enabled_flag and end_date condition fo
r value set YGLOBAL_ACCOUNT
** 08-DEC-08 Haribabu Pantakapu Change to DFFs Sets for Selection Grouping Rul
es
** File name convention to include the entity and
sysdate
** 20-Jan-09 Haribabu Pantakapu Change Request
** 1) DFF at Set of Books to exclude the STAT
set of books
********************************************************************************
********************************/
PROCEDURE asn_gl
( errbuf OUT VARCHAR2
,retcode OUT NUMBER
,p_period_name IN VARCHAR2
,p_value_set IN VARCHAR2
)
AS
-- This cursor is to select the info for the extract.
CURSOR lc_dat_cur
IS
SELECT XTTE.*
,XTTE.rowid
FROM xxyh_trit_tmp XTTE
where final_yn = 'Y';
-- commented by Balajee
-- WHERE NVL(XTTE.entered_amount, 0) <> 0 ;
--ORDER BY accountsegment1
-- ,accountsegment2
-- ,accountsegment3 ;

--- declaration of variables.


ln_counter NUMBER;
ln_user_id NUMBER;
lv_value_set VARCHAR2(100);
ln_rate_total VARCHAR2(100);
lv_err_stage VARCHAR2(1000);
lv_rec VARCHAR2(500);
--
BEGIN
x_progress := 'XXYH_TRIT_PKG.ASN_GL:10';
println(2, x_progress);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'The Value of the Period Name is: ' || p
_period_name);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'The Value of the Value Set Name is: ' |
| p_value_set);
-- Delete all the records from the interim table.
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE xxyh.xxyh_trit_tmp';
EXCEPTION
WHEN OTHERS THEN
DELETE FROM xxyh_trit_tmp;
COMMIT;
END;
ln_user_id := FND_GLOBAL.USER_ID;
lv_value_set := p_value_set ;
IF lv_value_set = 'XXYH_TRIT_US' THEN
-- First we are handling for the US related cases
x_progress := 'XXYH_TRIT_PKG.ASN_GL:20';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,final_yn
,attribute16
,attribute15 -- New Added for EU Entered
)
SELECT gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc -- FLEX_DESC -- Added By Haribabu on 08-Dec-2008
,GB.currency_code
,GSOB.currency_code
,GSOB.currency_code
,SUM( ( NVL(GB.begin_balance_dr,0) + NVL(GB.period_net_dr,0) ) - ( NV
L(GB.begin_balance_cr,0) + NVL(GB.period_net_cr,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr_beq,0)
) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr_beq,0)
) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) ))
,GB.period_name
,GB.period_year
--
,'N'
,XTAV.group_by --attribute16 -- Changed on 08-Dec-2008 By Haribab
u
,XTAV.eu_entered -- attribute15
FROM gl_balances GB
,gl_code_combinations GCC
,xxyh_trit_sob_v GSOB
,xxyh_trit_account_v XTAV -- Added By Haribabu on 08-Dec-2008
,xxyh_trit_company_v XTCV
WHERE GB.set_of_books_id = GSOB.set_of_books_id
AND GSOB.chart_of_accounts_id = GCC.chart_of_accounts_id
AND GCC.code_combination_id = GB.code_combination_id
AND GCC.segment2 = XTAV.flex_value
--AND GSOB.name NOT IN ('YAHOO! CONSOLIDATED', 'YAHOO!
DUMMY') -- 19-JUN-08 Tanay Behera -- "YAHOO! DUMMY" ADDED BY BALAJEE
AND XTAV.entity = 'US'--SUBSTR(lv_value_set,11,2)
AND GB.period_name = p_period_name
AND NVL(GB.translated_flag,'R') = 'R'
AND GB.currency_code != 'STAT' -- Added By Haribabu
AND GCC.segment1 = XTCV.flex_value
AND XTCV.entity = 'US'--lv_value_set
-- Added By Haribabu on 08-Dec-2008
/*AND EXISTS (SELECT 'X'
FROM xxyh_trit_company_v XTCV
WHERE XTCV.flex_value = GCC.segment1
AND XTCV.entity = lv_value_set
)*/
GROUP BY
gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,GSOB.currency_code
,GB.period_name
,GB.period_year
,XTAV.group_by --attribute16; Changed on 08-Dec-2008 By Haribabu
,XTAV.eu_entered; -- Added By Haribabu on 08-Dec-2008 By Haribabu
ELSIF lv_value_set = 'XXYH_TRIT_EU' THEN
-- Here we are handling for the EU related cases
x_progress := 'XXYH_TRIT_PKG.ASN_GL:30';
println(2, x_progress);
INSERT INTO xxyh_trit_tmp
( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,final_yn
,attribute16
,attribute15
)
SELECT gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,NVL(GTR.eop_rate,0)
,SUM( ( NVL(GB.begin_balance_dr,0) + NVL(GB.period_net_dr,0) ) - ( NV
L(GB.begin_balance_cr,0) + NVL(GB.period_net_cr,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr_beq,0)
) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr_beq,0)
) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) )) * NVL(GTR
.eop_rate,0)
,GB.period_name
,GB.period_year
,'N'
,XTAV.group_by --attribute16
,XTAV.eu_entered -- attribute15
FROM gl_balances GB
,gl_code_combinations GCC
,xxyh_trit_sob_v GSOB
,gl_translation_rates GTR
,xxyh_trit_account_v XTAV
,xxyh_trit_company_v XTCV
WHERE GB.set_of_books_id = GSOB.set_of_books_id
AND GSOB.set_of_books_id = GTR.set_of_books_id
AND GSOB.chart_of_accounts_id = GCC.chart_of_accounts_id
AND GCC.code_combination_id = GB.code_combination_id
AND GCC.segment2 = XTAV.flex_value
AND XTAV.entity = 'EU'--SUBSTR(lv_value_set,11,2)
--AND GSOB.name NOT IN ('YAHOO! CONSOLIDATED', 'YAHOO!
DUMMY') -- 19-JUN-08 Tanay Behera -- "YAHOO! DUMMY" ADDED BY BALAJEE
AND GB.period_name = p_period_name
AND NVL(GB.translated_flag,'R') = 'R'
AND GB.currency_code != 'STAT' -- Added By Haribabu
AND GCC.segment1 = XTCV.flex_value
AND XTCV.entity = 'EU'--lv_value_set
/*AND EXISTS (SELECT 'X'
FROM xxyh_trit_company_v XTCV
WHERE XTCV.flex_value = GCC.segment1
AND XTCV.entity = lv_value_set
)*/
AND NVL(GTR.period_name,p_period_name) = p_period_name
AND NVL(GTR.to_currency_code,'USD') = 'USD'
GROUP BY
gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,GB.period_name
,GB.period_year
,NVL(GTR.eop_rate,0)
,XTAV.group_by -- Added By Haribabu on 08-Dec-2008
,XTAV.eu_entered; -- Added By Haribabu on 08-Dec-2008
ELSIF lv_value_set = 'XXYH_TRIT_LA' THEN
-- Here we are handling for the EU related cases
x_progress := 'XXYH_TRIT_PKG.ASN_GL:30';
println(2, x_progress);
INSERT INTO xxyh_trit_tmp
( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,final_yn
,attribute16
,attribute15
)
SELECT gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,NVL(GTR.eop_rate,0)
,SUM( ( NVL(GB.begin_balance_dr,0) + NVL(GB.period_net_dr,0) ) - ( NV
L(GB.begin_balance_cr,0) + NVL(GB.period_net_cr,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr_beq,0)
) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) ))
,SUM( ( NVL(GB.begin_balance_dr_beq,0) + NVL(GB.period_net_dr_beq,0)
) - ( NVL(GB.begin_balance_cr_beq,0) + NVL(GB.period_net_cr_beq,0) )) * NVL(GTR
.eop_rate,0)--decode(GSOB.currency_code,GTR.to_currency_code,1,NVL(GTR.eop_rate,
0))
,GB.period_name
,GB.period_year
,'N'
,XTAV.group_by --attribute16
,XTAV.eu_entered -- attribute15
FROM gl_balances GB
,gl_code_combinations GCC
,xxyh_trit_sob_v GSOB
,gl_translation_rates GTR
,xxyh_trit_account_v XTAV
,xxyh_trit_company_v XTCV
WHERE GB.set_of_books_id = GSOB.set_of_books_id
AND GSOB.set_of_books_id = GTR.set_of_books_id
AND GSOB.chart_of_accounts_id = GCC.chart_of_accounts_id
AND GCC.code_combination_id = GB.code_combination_id
AND GCC.segment2 = XTAV.flex_value
AND XTAV.entity = 'LA'--SUBSTR(lv_value_set,11,2)
--AND GSOB.name NOT IN ('YAHOO! CONSOLIDATED', 'YAHOO!
DUMMY')
AND GB.period_name = p_period_name
AND NVL(GB.translated_flag,'R') = 'R'
AND GB.currency_code != 'STAT' -- Added By Haribabu
AND GCC.segment1 = XTCV.flex_value
AND XTCV.entity = 'LA'--lv_value_set
/*AND EXISTS (SELECT 'X'
FROM xxyh_trit_company_v XTCV
WHERE XTCV.flex_value = GCC.segment1
AND XTCV.entity = lv_value_set
)*/
AND NVL(GTR.period_name,p_period_name) = p_period_name
AND NVL(GTR.to_currency_code,'USD') = 'USD'
GROUP BY
gcc.segment1
,gcc.segment2
,gcc.segment3
,gcc.segment4
,gcc.segment5
,gcc.segment6
,gcc.segment7
,gcc.segment8
,gcc.segment9
,gcc.segment10
,XTAV.flex_desc
,GB.currency_code
,GSOB.currency_code
,GB.period_name
,GB.period_year
,NVL(GTR.eop_rate,0)
--,decode(GSOB.currency_code,GTR.to_currency_code,1,NVL(GTR.eop_rate,
0))
,XTAV.group_by
,XTAV.eu_entered;

asn_gl_USSOB(p_period_name => p_period_name


,p_entity => 'LA'
);
END IF;
--- This commit is to commit the data into interim table
COMMIT;
-- This is to update the values for the data.
x_progress := 'XXYH_TRIT_PKG.ASN_GL:40';
println(2, x_progress);
BEGIN
lv_err_stage := 'Update Part to get the correct balance' ;
UPDATE xxyh_trit_tmp f1
SET f1.entered_amt = f1.entered_amt - NVL((SELECT SUM(f2.local_amt)
FROM xxyh_trit_tmp f2
WHERE f2.accountsegment1 =
f1.accountsegment1
AND NVL(f2.accountsegment
2,'$') = NVL(f1.accountsegment2,'$')
AND NVL(f2.accountsegment
3,'$') = NVL(f1.accountsegment3,'$')
AND NVL(f2.accountsegment
4,'$') = NVL(f1.accountsegment4,'$')
AND NVL(f2.accountsegment
5,'$') = NVL(f1.accountsegment5,'$')
AND NVL(f2.accountsegment
6,'$') = NVL(f1.accountsegment6,'$')
AND NVL(f2.accountsegment
7,'$') = NVL(f1.accountsegment7,'$')
AND NVL(f2.accountsegment
8,'$') = NVL(f1.accountsegment8,'$')
AND f2.accountname = f1.a
ccountname
AND f2.period_year = f1.p
eriod_year
AND f2.period_name = f1.p
eriod_name
AND f2.entered_cur <> f1.
entered_cur
AND f2.local_cur = f1.loc
al_cur
),0)
WHERE f1.local_cur = f1.entered_cur;
lv_err_stage := 'Update Part to get the correct balance for same currency
';
COMMIT;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:50';
println(2, x_progress);

UPDATE xxyh_trit_tmp f1
SET f1.local_amt = NVL((SELECT SUM(f2.entered_amt)
FROM xxyh_trit_tmp f2
WHERE f2.accountsegment1 = f1.accountsegment
1
AND NVL(f2.accountsegment2,'$') = NVL(f1.a
ccountsegment2,'$')
AND NVL(f2.accountsegment3,'$') = NVL(f1.a
ccountsegment3,'$')
AND NVL(f2.accountsegment4,'$') = NVL(f1.a
ccountsegment4,'$')
AND NVL(f2.accountsegment5,'$') = NVL(f1.a
ccountsegment5,'$')
AND NVL(f2.accountsegment6,'$') = NVL(f1.a
ccountsegment6,'$')
AND NVL(f2.accountsegment7,'$') = NVL(f1.a
ccountsegment7,'$')
AND NVL(f2.accountsegment8,'$') = NVL(f1.a
ccountsegment8,'$')
AND f2.accountname = f1.accountname
AND f2.period_year = f1.period_year
AND f2.period_name = f1.period_name
AND f2.entered_cur = f1.entered_cur
AND f2.local_cur = f1.local_cur
),0)
WHERE f1.local_cur = f1.entered_cur;
COMMIT;
IF p_value_set = 'XXYH_TRIT_US'
THEN
UPDATE xxyh_trit_tmp f1
SET f1.reporting_amt = NVL((SELECT SUM((f2.local_amt))
FROM xxyh_trit_tmp f2
WHERE f2.accountsegment1 = f1.accountsegme
nt1
AND NVL(f2.accountsegment2,'$') = NVL(f1
.accountsegment2,'$')
AND NVL(f2.accountsegment3,'$') = NVL(f1
.accountsegment3,'$')
AND NVL(f2.accountsegment4,'$') = NVL(f1
.accountsegment4,'$')
AND NVL(f2.accountsegment5,'$') = NVL(f1
.accountsegment5,'$')
AND NVL(f2.accountsegment6,'$') = NVL(f1
.accountsegment6,'$')
AND NVL(f2.accountsegment7,'$') = NVL(f1
.accountsegment7,'$')
AND NVL(f2.accountsegment8,'$') = NVL(f1
.accountsegment8,'$')
AND f2.accountname = f1.accountname
AND f2.period_year = f1.period_year
AND f2.period_name = f1.period_name
AND f2.entered_cur = f1.entered_cur
AND f2.local_cur = f1.local_cur
),0)
WHERE f1.reporting_cur = f1.local_cur;
END IF;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:60';
println(2, x_progress);
COMMIT;
IF p_value_set IN ('XXYH_TRIT_EU','XXYH_TRIT_LA')
THEN
UPDATE xxyh_trit_tmp f1
SET f1.reporting_amt = NVL((SELECT SUM((f2.local_amt*f1.reporting_cu
r)) -- SUM ADDED BY BALAJEE KALLA
FROM xxyh_trit_tmp f2
WHERE f2.accountsegment1 = f1.accountsegme
nt1
AND NVL(f2.accountsegment2,'$') = NVL(f1
.accountsegment2,'$')
AND NVL(f2.accountsegment3,'$') = NVL(f1
.accountsegment3,'$')
AND NVL(f2.accountsegment4,'$') = NVL(f1
.accountsegment4,'$')
AND NVL(f2.accountsegment5,'$') = NVL(f1
.accountsegment5,'$')
AND NVL(f2.accountsegment6,'$') = NVL(f1
.accountsegment6,'$')
AND NVL(f2.accountsegment7,'$') = NVL(f1
.accountsegment7,'$')
AND NVL(f2.accountsegment8,'$') = NVL(f1
.accountsegment8,'$')
AND f2.accountname = f1.accountname
AND f2.period_year = f1.period_year
AND f2.period_name = f1.period_name
AND f2.entered_cur = f1.entered_cur
AND f2.local_cur = f1.local_cur
),0)
WHERE f1.local_cur = f1.entered_cur;
END IF;

EXCEPTION
WHEN OTHERS THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END;
--- This commit is to commit the data into interim table
COMMIT;
BEGIN
lv_err_stage := 'The currency USD for all CCY1Code' ;
UPDATE xxyh_trit_tmp f1
SET f1.reporting_cur = 'USD'
WHERE f1.reporting_amt IS NOT NULL
AND f1.reporting_cur <> 'USD';
EXCEPTION
WHEN OTHERS THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END;
--- This commit is to commit the data into interim table after inserting th
e translated value.
COMMIT;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:70';
println(2, x_progress);

-- check for the entered currency group by


IF lv_value_set IN ('XXYH_TRIT_EU','XXYH_TRIT_LA') THEN
UPDATE xxyh_trit_tmp
SET entered_cur = 'USD'
, entered_amt = 0
WHERE NVL(attribute15,'N') = 'N';
END IF;
COMMIT;
-- Added By Haribabu on 10-OCT-2008.
x_progress := 'XXYH_TRIT_PKG.ASN_GL:72';
UPDATE xxyh_trit_tmp
SET attribute1 = accountsegment1||'-'||accountsegment2||'-'||accountseg
ment3||'-'||accountsegment4||'-'||accountsegment5||'-'||accountsegment6;
COMMIT;
-- Added By Haribabu on 10-OCT-2008 for US
x_progress := 'XXYH_TRIT_PKG.ASN_GL:75';
IF lv_value_set = 'XXYH_TRIT_US' THEN
UPDATE xxyh_trit_tmp
SET entered_cur = 'USD'
,entered_amt = 0
WHERE attribute1 NOT IN (SELECT ffv.flex_value
FROM fnd_flex_values_vl ffv
,fnd_flex_value_sets ffvs
WHERE ffv.flex_value_set_id = ffvs.flex_val
ue_set_id
AND ffvs.flex_value_set_name = 'XXYH_TRIT_A
SN_US_GL_GB_ACC'
AND ffv.enabled_flag = 'Y'
AND sysdate between nvl(ffv.start_date_activ
e, sysdate) and nvl(ffv.end_date_active, sysdate));
END IF;
COMMIT;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:76';
-- End 10-OCT-2008
-- Printing the Header here.
-- begin compute group by
-- segment1
INSERT INTO xxyh_trit_tmp
( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT1'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:80';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT2'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:90';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT3'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:100';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT4'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:110';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,NULL
,NULL
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT5'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;

x_progress := 'XXYH_TRIT_PKG.ASN_GL:120';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,NULL
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT6'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:130';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,NULL
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT7'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;

x_progress := 'XXYH_TRIT_PKG.ASN_GL:140';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountsegment8
,NULL
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT8'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountsegment8
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;

x_progress := 'XXYH_TRIT_PKG.ASN_GL:150';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountsegment8
,xtte.accountsegment9
,NULL
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT9'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountsegment8
,xtte.accountsegment9
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;
x_progress := 'XXYH_TRIT_PKG.ASN_GL:160';
println(2, x_progress);

INSERT INTO xxyh_trit_tmp


( accountsegment1
,accountsegment2
,accountsegment3
,accountsegment4
,accountsegment5
,accountsegment6
,accountsegment7
,accountsegment8
,accountsegment9
,accountsegment10
,accountname
,entered_cur
,local_cur
,reporting_cur
,entered_amt
,local_amt
,reporting_amt
,period_name
,period_year
,period_num
,final_yn
)
SELECT xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountsegment8
,xtte.accountsegment9
,xtte.accountsegment10
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,SUM(xtte.entered_amt)
,SUM(xtte.local_amt)
,SUM(xtte.reporting_amt)
,xtte.period_name
,xtte.period_year
,xtte.period_num
,'Y'
FROM xxyh_trit_tmp xtte
WHERE xtte.attribute16 = 'SEGMENT10'
AND xtte.final_yn = 'N'
-- AND valueset_name = lv_value_set
GROUP by xtte.accountsegment1
,xtte.accountsegment2
,xtte.accountsegment3
,xtte.accountsegment4
,xtte.accountsegment5
,xtte.accountsegment6
,xtte.accountsegment7
,xtte.accountsegment8
,xtte.accountsegment9
,xtte.accountsegment10
,xtte.accountname
,xtte.entered_cur
,xtte.local_cur
,xtte.reporting_cur
,xtte.period_name
,xtte.period_year
,xtte.period_num;

x_progress := 'XXYH_TRIT_PKG.ASN_GL:170';
println(2, x_progress);
-- end compute group by

println(2, 'Printing the Header Info: ' || SYSDATE);


println(1, 'AccountSegment1,'
||'AccountSegment2,'
||'AccountSegment3,'
||'AccountSegment4,'
||'AccountSegment5,'
||'AccountSegment6,'
||'AccountSegment7,'
||'AccountSegment8,'
||'AccountSegment9,'
||'AccountSegment10,'
||'AccountName,'
||'CCY1Code,'
||'CCY1GLEndBalance,'
||'CCY2Code,'
||'CCY2GLEndBalance,'
||'CCY3Code,'
||'CCY3GLEndBalance,'
||'Period,'
||'Year');
ln_counter := 0;
ln_rate_total := 0;
--
FOR lr_rec IN lc_dat_cur
LOOP
lv_err_stage := 'Printing the values to a output file.';
lv_rec := NULL;
ln_counter := ln_counter + 1;
ln_rate_total := ln_rate_total + round(lr_rec.reporting_amt,2);
/*lv_rec := '"'||lr_rec.accountsegment1||'"'||','||'"'||lr_rec.accountseg
ment2||'"'||','||'"'||lr_rec.accountsegment3||'"'
||','||'"'||lr_rec.accountsegment4||'"'||','||'"'||lr_rec.accoun
tsegment5||'"'||','||'"'||lr_rec.accountsegment6||'"'
||','||'"'||lr_rec.accountsegment7||'"'||','||'"'||lr_rec.accoun
tsegment8||'"'||','||'"'||lr_rec.accountsegment9||'"'
||','||'"'||lr_rec.accountsegment10||'"'||','||'"'||clean_str(lr
_rec.accountname)||'"'
||','||'"'||lr_rec.reporting_cur||'"'||','||'"'||lr_rec.reportin
g_amount||'"'
||','||'"'||lr_rec.local_cur||'"'||','||'"'||lr_rec.local_amount
||'"'
||','||'"'||lr_rec.entered_cur||'"'
||','||'"'||lr_rec.entered_amount||'"'||','||'"'||lr_rec.period_
name||'"'||','||'"'||lr_rec.period_year||'"';*/
lv_rec := lr_rec.accountsegment1||','||lr_rec.accountsegment2||','|
|lr_rec.accountsegment3
||','||lr_rec.accountsegment4||','||lr_rec.accountsegment5||','|
|lr_rec.accountsegment6
||','||lr_rec.accountsegment7||','||lr_rec.accountsegment8||','|
|lr_rec.accountsegment9
||','||lr_rec.accountsegment10||','||clean_str(lr_rec.accountnam
e)
||','||lr_rec.reporting_cur||','||round(lr_rec.reporting_amt,2)
||','||lr_rec.local_cur||','||round(lr_rec.local_amt,2)
||','||lr_rec.entered_cur||','||round(lr_rec.entered_amt,2)
||','||to_char(to_date(lr_rec.period_name, 'MON-YY'), 'MM')||','
||lr_rec.period_year;
---FND_FILE.PUT_LINE(FND_FILE.LOG, 'The values are: ' || lv_rec
);
println(1, lv_rec);
END LOOP;
lv_err_stage := 'Printing the values for the total rate value and record cou
nt.';
println(1, 'FOOTER,'||ln_counter||','|| round(ln_rate_total,2));
-- launch concurrent program to cp out put to trintech directory
println(2, 'launching cp program ...');
x_sfile := 'o'||x_request_id||'.out';
x_dfile := 'GLBAL_'||to_char(to_date(p_period_name, 'MON-YY'), 'MMYYYY')||SUB
STR(p_value_set,11,2)||'_'||TO_CHAR(SYSDATE,'MMDDYYYY')||'.csv';
--
cp_output('TRIT-OUT', x_sfile, x_dfile);
println(2, 'launching cp program done');
--
EXCEPTION
WHEN OTHERS THEN
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||lv_err_stage;
retcode := 2;
END asn_gl;
--
PROCEDURE rcn_psi_ie(errbuf OUT VARCHAR2
,retcode OUT NUMBER ) AS
CURSOR c_seg
IS
SELECT substr(msi.segment1,instr(msi.segment1, '-')+1) segment1
,gcc.concatenated_segments account
FROM mtl_system_items msi
,org_organization_definitions ood
,gl_code_combinations_kfv gcc
WHERE msi.organization_id = ood.organization_id
AND ood.organization_code = 'PSI'
AND msi.sales_account = gcc.code_combination_id;
BEGIN
x_progress := 'XXYH_TRIT_EXTRACTS_PKG.RCN_PSI_IE:10';
--
println(1,'"Item","Account"');
--
FOR i in c_seg
LOOP
println(1,'"'||i.segment1||'","'||i.account||'"');
END LOOP;
--
-- launch concurrent program to cp out put to trintech directory
println(2, 'launching cp program ...');
x_tfile := 'N';
x_sfile := 'o'||x_request_id||'.out';
x_dfile := 'PSI-'||TO_CHAR(SYSDATE, 'MON-YY') ||'.csv';
--
cp_output('TRIT-OUT', x_sfile, x_dfile);
println(2, 'launching cp program done');
--
EXCEPTION
WHEN OTHERS THEN
println(2, 'Error Occured at : '||x_progress||'-'||sqlerrm);
retcode := 2;
END rcn_psi_ie;
--
/*******************************************************************************
*********
** TITLE :- PROCEDURE asn_fa_bal
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :-
** AUTHOR :- Haribabu
** VERSION :- 1.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This is used to fetch data on a monthly basis for
** FA Subledger Balances
** INPUTS :- p_period_name (mandatory)
** Summary Y/N (mandatory) default to 'Y'
** Company List
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 12-AUG-08 Haribabu Pantakapu Initial Version of Code
** 28-AUG-08 Haribabu Pantakapu Added to fix conversion amount not populat
ed for foreign currencies
** Sum(Ending Balance) of cost and reserve su
mmary match fix.
** 16-SEP-08 Haribabu Pantakapu Companies to be included: based on GL Bala
nce extract value listing
** Accounts to be included: only include 15xx
xx or 16xxxx accounts from FA subledger
** 23-SEP-08 Haribabu Pantakapu Added ROUND function to round the amount c
olumns values format to ####.##
** 14-NOV-08 Haribabu Pantakapu Reverse the sign on the amounts for Accumu
lated Depr accounts
** 18-NOV-08 Haribabu Pantakapu Exclude enabled_flag and end_date conditio
n for YGLOBAL_ACCOUNT Value Set
** 08-DEC-08 Haribabu Pantakapu DFFs and Value Sets for Selection
** File name convention to include the entity
and sysdate
** 20-Jan-09 Haribabu Pantakapu Change Request
** 1) DFF at Set of Books to exclude the STAT
set of books
2) Include only Corporate Books.
** 26-Jan-09 Haribabu Pantakapu Change Request
1) Exclude the FA books from the collapsed
entities
view defined based on FA_BOOK_CONTROLS
to exclude
********************************************************************************
**********/
PROCEDURE asn_fa_bal(errbuf OUT NOCOPY VARCHAR2
,retcode OUT NOCOPY NUMBER
,p_period_name IN VARCHAR2
,p_entity IN VARCHAR2
,p_flag IN VARCHAR2 DEFAULT 'Y'
)
IS
CURSOR period_details
IS
SELECT P1.Period_Counter Period1_PC
,P1.Period_Open_Date Period1_POD
,NVL(P1.Period_Close_Date, SYSDATE) Period1_PCD
,P2.Period_Counter Period2_PC
,NVL(P2.Period_Close_Date, SYSDATE) Period2_PCD
,BC.Distribution_Source_Book Dist_Book
,GSOB.set_of_books_id set_of_books_id
,GSOB.currency_code currency_code
,GSOB.chart_of_accounts_id coa_id
FROM FA_DEPRN_PERIODS P1,
FA_DEPRN_PERIODS P2,
XXYH_TRIT_FA_BOOK_CONTROLS_V BC,
xxyh_trit_sob_v GSOB
WHERE GSOB.set_of_books_id = BC.set_of_books_id
--AND GSOB.name NOT IN ('YAHOO! CONSOLIDATED','YAHOO! DUMMY')
--AND BC.BOOK_CLASS = 'CORPORATE' -- Included this condition in the view x
xyh_trit_fa_book_controls_v
AND P1.Book_Type_Code = BC.Book_Type_Code
AND P1.Period_Name = p_period_name
AND P2.Book_Type_Code = BC.Book_Type_Code
AND P2.Period_Name = p_period_name
AND (p_entity = 'XXYH_TRIT_US' AND GSOB.currency_code = 'USD'
OR p_entity = 'XXYH_TRIT_EU' AND GSOB.currency_code <> 'USD');
l_period_rec period_details%ROWTYPE;
CURSOR l_data_output
IS
SELECT *
FROM xxyh_trit_tmp
WHERE final_YN = p_flag;
l_data VARCHAR2(4000);
ln_counter NUMBER := 0;
ln_rate_total NUMBER := 0;
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE XXYH.XXYH_TRIT_TMP DROP STORAGE';
FOR l_period_rec IN period_details
LOOP
-- FND_FILE PRINT OF L PERIOD REC Record For Debugging.
FND_FILE.PUT_LINE(FND_FILE.LOG,'Dist_Book - '||l_period_rec.Dist_Book
);
FND_FILE.PUT_LINE(FND_FILE.LOG,'Period1_PC - '||l_period_rec.Period1_P
C);
FND_FILE.PUT_LINE(FND_FILE.LOG,'Period1_POD - '||l_period_rec.Period1_P
OD);
FND_FILE.PUT_LINE(FND_FILE.LOG,'Period1_PCD - '||l_period_rec.Period1_P
CD);
FND_FILE.PUT_LINE(FND_FILE.LOG,'Period2_PC - '||l_period_rec.Period2_P
C);
FND_FILE.PUT_LINE(FND_FILE.LOG,'Period2_PCD - '||l_period_rec.Period2_P
CD);
FND_FILE.PUT_LINE(FND_FILE.LOG,'set_of_books_id - '||l_period_rec.set_of_bo
oks_id);
FND_FILE.PUT_LINE(FND_FILE.LOG,'currency_code - '||l_period_rec.currency_
code);
FND_FILE.PUT_LINE(FND_FILE.LOG,'coa_id - '||l_period_rec.coa_id);
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:10';
INSERT INTO xxyh_trit_tmp(ATTRIBUTE16
,ACCOUNTSEGMENT1
,ACCOUNTSEGMENT2
,LOCAL_CUR
,ENTERED_CUR
,REPORTING_CUR
,LOCAL_AMT
,ENTERED_AMT
,REPORTING_AMT
,PERIOD_NAME
,PERIOD_YEAR
,PERIOD_NUM
,USE_NUMBER_REP_1
,USE_NUMBER_REP_2
,USE_NUMBER_REP_3
,LAST_UPDATE_DATE
,LAST_UPDATED_BY
,FINAL_YN
)
SELECT /*+ index(dd FA_DEPRN_DETAIL_U1) */
'COST'
,GLCC.segment1
,CB.Asset_Cost_Acct
,l_period_rec.currency_code
,'USD'
,'USD'
,DD.cost
,0
,DECODE(l_period_rec.currency_code,'USD',DD.cost,0)
,p_period_name
,TO_CHAR(TO_DATE(p_period_name,'MON-YY'),'YY')
,TO_CHAR(TO_DATE(p_period_name,'MON-YY'),'MM')
,DH.Asset_ID
,DH.Code_Combination_ID
,l_period_rec.set_of_books_id
,SYSDATE
,x_user_id
,p_flag
FROM FA_DISTRIBUTION_HISTORY DH,
GL_CODE_COMBINATIONS GLCC,
FA_DEPRN_DETAIL DD,
FA_ASSET_HISTORY AH,
FA_CATEGORY_BOOKS CB,
FA_BOOKS BK,
XXYH_TRIT_COMPANY_V XTCV
WHERE DH.Book_Type_Code = l_period_rec.Dist_Book
AND GLCC.CODE_COMBINATION_ID = DH.CODE_COMBINATION_ID
AND GLCC.chart_of_accounts_id = l_period_rec.coa_id
AND l_period_rec.Period2_PCD BETWEEN DH.Date_Effective A
ND NVL(DH.Date_Ineffective, SYSDATE)
AND DD.Asset_ID = DH.Asset_ID
AND DD.Book_Type_Code = l_period_rec.Dist_Book
AND DD.Distribution_ID = DH.Distribution_ID
AND DD.Period_Counter <= l_period_rec.Period2_PC
AND DD.Deprn_Source_Code = 'D'
AND DD.Period_Counter = (SELECT MAX (SUB_DD.Period_Coun
ter)
FROM FA_DEPRN_DETAIL SUB_DD
WHERE SUB_DD.Book_Type_Code =
l_period_rec.Dist_Book
AND SUB_DD.Distribution_ID
= DH.Distribution_ID
AND DH.Distribution_ID
= DD.Distribution_ID
AND SUB_DD.Period_Counter
<= l_period_rec.Period2_PC
)
AND AH.Asset_ID = DH.Asset_ID
AND AH.Asset_Type != 'EXPENSED'
AND l_period_rec.Period2_PCD BETWEEN AH.Date_Effective AN
D NVL(AH.Date_Ineffective, SYSDATE)
AND CB.Category_ID = AH.Category_ID
AND CB.Book_Type_Code = DD.book_type_code -- changed from
book var to column
AND BK.Book_Type_Code = CB.book_type_code
AND BK.Asset_ID = DD.Asset_ID -- changed from
book var to column
AND l_period_rec.Period2_PCD BETWEEN BK.Date_Effective AN
D NVL(BK.Date_Ineffective, SYSDATE)
AND NVL(BK.Period_Counter_Fully_Retired, l_period_rec.Per
iod2_PC+1) > l_period_rec.Period2_PC-1
AND DECODE(AH.Asset_Type, 'CAPITALIZED', CB.Asset_Cost_Ac
ct, NULL) IS NOT NULL
AND XTCV.flex_value = GLCC.segment1
AND XTCV.entity = SUBSTR(p_entity,11,2)
AND (CB.Asset_Cost_Acct LIKE '15%' OR CB.Asset_Cost_Acct
LIKE '16%')
UNION ALL
SELECT /*+ index(dd FA_DEPRN_DETAIL_U1) */
'RESERVE'
,GLCC.segment1
,CB.Deprn_Reserve_Acct
,l_period_rec.currency_code
,'USD'
,'USD'
,-1*DD.Deprn_Reserve
,0
,DECODE(l_period_rec.currency_code,'USD',-1*DD.Deprn
_Reserve,0)
,p_period_name
,TO_CHAR(TO_DATE(p_period_name,'MON-YY'),'YY')
,TO_CHAR(TO_DATE(p_period_name,'MON-YY'),'MM')
,DH.Asset_ID
,DH.Code_Combination_ID
,l_period_rec.set_of_books_id
,SYSDATE
,x_user_id
,p_flag
FROM FA_DISTRIBUTION_HISTORY DH,
GL_CODE_COMBINATIONS GLCC,
FA_DEPRN_DETAIL DD,
FA_ASSET_HISTORY AH,
FA_CATEGORY_BOOKS CB,
FA_BOOKS BK,
XXYH_TRIT_COMPANY_V XTCV
WHERE DH.Book_Type_Code = l_period_rec.Dist_Book
AND GLCC.CODE_COMBINATION_ID = DH.CODE_COMBINATION_ID
AND GLCC.chart_of_accounts_id = l_period_rec.coa_id
AND l_period_rec.Period2_PCD BETWEEN DH.Date_Effective A
ND NVL(DH.Date_Ineffective, SYSDATE)
AND DD.Asset_ID = DH.Asset_ID
AND DD.Book_Type_Code = l_period_rec.Dist_Book
AND DD.Distribution_ID = DH.Distribution_ID
AND DD.Period_Counter <= l_period_rec.Period2_PC
AND DD.Deprn_Source_Code = 'D'
AND DD.Period_Counter = (SELECT MAX (SUB_DD.Period_Count
er)
FROM FA_DEPRN_DETAIL SUB_DD
WHERE SUB_DD.Book_Type_Code =
l_period_rec.Dist_Book
AND SUB_DD.Distribution_ID =
DH.Distribution_ID
AND DH.Distribution_ID =
DD.Distribution_ID
AND SUB_DD.Period_Counter <
= l_period_rec.Period2_PC
)
AND AH.Asset_ID = DH.Asset_ID
AND AH.asset_type = 'CAPITALIZED'
AND l_period_rec.Period2_PCD BETWEEN AH.Date_Effective A
ND NVL(AH.Date_Ineffective, SYSDATE)
AND CB.Category_ID = AH.Category_ID
AND CB.Book_Type_Code = DD.book_type_code -- changed fro
m book var to column
AND BK.Book_Type_Code = CB.book_type_code -- changed fro
m book var to column
AND BK.Asset_ID = DD.Asset_ID
AND l_period_rec.Period2_PCD BETWEEN BK.Date_Effective A
ND NVL(BK.Date_Ineffective, SYSDATE)
AND NVL(BK.Period_Counter_Fully_Retired, l_period_rec.Pe
riod2_PC+1) > l_period_rec.Period2_PC-1
AND CB.Deprn_Reserve_Acct IS NOT NULL
AND XTCV.flex_value = GLCC.segment1
AND XTCV.entity = SUBSTR(p_entity,11,2)
AND (CB.Deprn_Reserve_Acct LIKE '15%' OR CB.Deprn_Reserve
_Acct LIKE '16%');
COMMIT;
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:15';
UPDATE xxyh_trit_tmp xtt
SET accountname = (SELECT XTAV.flex_desc
FROM xxyh_trit_account_v XTAV
WHERE XTAV.flex_value = xtt.accountsegment2
AND XTAV.entity = SUBSTR(p_entity,11,2)
)
WHERE xtt.local_cur = l_period_rec.currency_code
AND xtt.use_number_rep_3 = l_period_rec.set_of_books_id;
COMMIT;
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:20';
IF l_period_rec.currency_code <> 'USD' THEN
UPDATE xxyh_trit_tmp xtt
SET xtt.reporting_amt = local_amt * (SELECT gtr.eop_rate
FROM gl_translation_rates gt
r
WHERE gtr.to_currency_code =
xtt.reporting_cur
AND gtr.to_currency_code = '
USD'
AND gtr.period_name = p
_period_name
AND gtr.set_of_books_id = l
_period_rec.set_of_books_id
)
WHERE xtt.local_cur = l_period_rec.currency_code
AND xtt.use_number_rep_3 = l_period_rec.set_of_books_id
AND xtt.local_amt <> 0;
COMMIT;
END IF;
END LOOP;
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:30';
IF p_flag = 'Y' THEN
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:40';
UPDATE xxyh_trit_tmp
SET final_yn = 'X';
COMMIT;
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:50';
INSERT INTO xxyh_trit_tmp(accountsegment1
,accountsegment2
,accountname
,reporting_cur
,reporting_amt
,local_cur
,local_amt
,entered_cur
,entered_amt
,final_yn
)
SELECT accountsegment1
,accountsegment2
,accountname
,reporting_cur
,SUM(reporting_amt)
,local_cur
,SUM(local_amt)
,entered_cur
,SUM(entered_amt)
,p_flag
FROM xxyh_trit_tmp
WHERE final_yn = 'X'
GROUP BY accountsegment1
,accountsegment2
,accountname
,reporting_cur
,local_cur
,entered_cur;
COMMIT;
ELSE
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:60';
UPDATE xxyh_trit_tmp
SET final_YN = p_flag;
--
COMMIT;
END IF;

x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:70';
println(2, 'Printing the Header Info: ' || SYSDATE);
println(1, 'AccountSegment1,'
||'AccountSegment2,'
||'AccountSegment3,'
||'AccountSegment4,'
||'AccountSegment5,'
||'AccountSegment6,'
||'AccountSegment7,'
||'AccountSegment8,'
||'AccountSegment9,'
||'AccountSegment10,'
||'AccountName,'
||'CCY1Code,'
||'CCY1GLEndBalance,'
||'CCY2Code,'
||'CCY2GLEndBalance,'
||'CCY3Code,'
||'CCY3GLEndBalance,'
||'Period,'
||'Year');
FOR lr_rec IN l_data_output
LOOP
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:80';
ln_counter := ln_counter + 1;
ln_rate_total := ln_rate_total + lr_rec.reporting_amt;
l_data := lr_rec.accountsegment1||','||
lr_rec.accountsegment2||','||
lr_rec.accountsegment3||','||
lr_rec.accountsegment4||','||
lr_rec.accountsegment5||','||
lr_rec.accountsegment6||','||
lr_rec.accountsegment7||','||
lr_rec.accountsegment8||','||
lr_rec.accountsegment9||','||
lr_rec.accountsegment10||','||
lr_rec.accountname||','||
lr_rec.reporting_cur||','||
ROUND(lr_rec.reporting_amt,2)||','||
lr_rec.local_cur||','||
ROUND(lr_rec.local_amt,2)||','||
lr_rec.entered_cur||','||
ROUND(lr_rec.entered_amt,2)||','||
TO_CHAR(TO_DATE(p_period_name,'MON-YY'),'MM')||','||
TO_CHAR(TO_DATE(p_period_name,'MON-YY'),'YYYY');
println(1, l_data);
END LOOP;
x_progress := 'XXYH_TRIT_PKG.asn_fa_bal:90';
FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'FOOTER,'||ln_counter||','||ROUND(ln_rate_
total,2));
--
-- launch concurrent program to cp out put to trintech directory
println(2, 'launching cp program ...');
x_sfile := 'o'||x_request_id||'.out';
x_dfile := 'FABAL_'||to_char(to_date(p_period_name, 'MON-YY'), 'MMYYYY')||SUB
STR(p_entity,11,2)||'_'||TO_CHAR(SYSDATE,'MMDDYYYY')||'.csv';
--
cp_output('TRIT-OUT', x_sfile, x_dfile);
println(2, 'launching cp program done');
--
errbuf := NULL;
retcode := 0;
--
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'Error Code :'||SQLCODE);
FND_FILE.PUT_LINE(FND_FILE.LOG,'Error Message :'||SUBSTR(SQLERRM,1,500));
errbuf := 'Unexpected Error at : '|| x_progress;
retcode := 2;
END asn_fa_bal;
--
/*******************************************************************************
*********
** TITLE :- PROCEDURE rcn_dv_ar
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :-
** AUTHOR :- Haribabu Pantakapu
** VERSION :- 1.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This is used to fetch data for Trintech ReconNET Reconcil
iation
** Receivables (Receipts)
** INPUTS :- p_date (mandatory)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 26-SEP-2008 Haribabu Pantakapu Initial Version of Code
** 02-OCT-2008 Haribabu Pantakapu Changes to fix issues reported by Busi
ness
** Duplicate extractl lines for Receivabl
es.
** Tran Code is not correct
** 03-OCT-2008 Haribabu Pantakapu Make the amount column ABS
** Fix to Reconcile, Account Analysis Rep
ort
** 06-OCT-2008 Haribabu Pantakapu Fix to Reconcile, Account Analysis Rep
ort
** 28-OCT-2008 Haribabu Pantakapu Adding new column to AR Drilldown - Ba
tch Type
** Change of mapping for AR Drilldown, Ba
tch# moved from
** Item UDF8 to UDF9
********************************************************************************
**********/
PROCEDURE rcn_dv_ar(errbuf OUT NOCOPY VARCHAR2
,retcode OUT NOCOPY NUMBER
,p_date IN VARCHAR2
)
IS
CURSOR C_AR_TRIT_CUR
IS
SELECT use_number_rep_1
,use_number_rep_2
,accountname
,tran_code
,attribute2 batch_name
FROM xxyh_trit_tmp
WHERE attribute3 = 'Receivables'
AND attribute5 = 'AR';
BEGIN
x_progress := 'XXYH_TRIT_PKG.rcn_dv_ar:10';
FOR L_REC IN C_AR_TRIT_CUR
LOOP
INSERT INTO xxyh_trit_tmp(date_effective -- Receipt Date
,reporting_amt -- Amount Functional
,accountname -- Account String
,tran_code -- Tran Code GL-CR or GL-Dr
,attribute1 -- Customer Name
,attribute2 -- Receipt Number
,attribute3 -- Batch Name
,local_cur -- Currency Code
,entered_amt -- Amount Entered
,date_posted -- AR's GL Date
,attribute4 -- Status
,attribute6 -- comments
,attribute5 -- 'AR'
,attribute15 -- Data Source -- 'AR'
,use_number_rep_3 -- cash_receipt_id
)
SELECT TRX_DATE
,ROUND(NVL(ACCOUNTED_DR,ACCOUNTED_CR),2)
,l_rec.accountname
,l_rec.tran_code
,third_party_name
,TRX_NUMBER_C
,l_rec.batch_name -- Batch name
,currency_code
,ROUND(NVL(ENTERED_DR,ENTERED_CR),2)
,accounting_date
,'CHECK'
,COMMENTS
,'AR'
,'AR'
,TRX_HDR_ID
FROM AR_AEL_GL_REC_ALL_V
WHERE application_id = 222
AND je_header_id = l_rec.use_number_rep_1
AND je_line_num = l_rec.use_number_rep_2;
END LOOP;
COMMIT;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_ar:20';
UPDATE xxyh_trit_tmp XTT
SET (attribute4, use_number_rep_4) = (SELECT CRH_CURRENT.status
,CRH_CURRENT.batch_id
FROM AR_CASH_RECEIPT_HISTORY_ALL C
RH_REM,
AR_CASH_RECEIPT_HISTORY_ALL C
RH_CURRENT,
AR_CASH_RECEIPTS_ALL CR,
AR_CASH_RECEIPT_HISTORY_ALL C
RH_FIRST_POSTED
WHERE CRH_REM.CASH_RECEIPT_ID(+)
= CR.CASH_RECEIPT_ID
AND NOT EXISTS
(SELECT CASH_RECEIPT_HISTORY_
ID
FROM AR_CASH_RECEIPT_HISTO
RY_ALL CRH3
WHERE CRH3.STATUS
= 'REMITTED'
AND CRH3.CASH_RECEIPT_ID
= CR.CASH_RECEIPT_ID
AND CRH3.CASH_RECEIPT_HIS
TORY_ID < CRH_REM.CASH_RECEIPT_HISTORY_ID
)
AND CRH_REM.STATUS(+)
= 'REMITTED'
AND CRH_CURRENT.CASH_RECEIPT_ID
= CR.CASH_RECEIPT_ID
AND CRH_CURRENT.CURRENT_RECORD_FLAG
= NVL('Y', CR.RECEIPT_NUMBER)
AND CRH_FIRST_POSTED.CASH_RECEIPT_ID
(+) = CR.CASH_RECEIPT_ID
AND CRH_FIRST_POSTED.FIRST_POSTED_RE
CORD_FLAG(+) = 'Y'
AND CR.cash_receipt_id
= XTT.use_number_rep_3
)
WHERE attribute5 = 'AR'
AND attribute15 = 'AR'
AND attribute4 = 'CHECK';
COMMIT;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_ar:30';
UPDATE xxyh_trit_tmp XTT
SET (attribute7, attribute8) = (SELECT BT.name
,DECODE(BT.TYPE,'MANUAL',
DECODE(BT.BATCH_
APPLIED_STATUS,
'PROCESSED
','MANUAL_REGULAR'
,'POSTBATC
H_WAITING','MANUAL_QUICK'
,'IN_PROCE
SS','MANUAL_QUICK'
,'NULL' )
,BT.TYPE)
FROM AR_BATCHES_ALL BT
WHERE BT.BATCH_ID = XTT.use_number_rep_
4
)
WHERE attribute5 = 'AR'
AND attribute15 = 'AR';
COMMIT;
errbuf := NULL;
retcode := 0;
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.log,x_progress || SUBSTR(SQLERRM,1,200));
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||x_progress;
retcode := 2;
END rcn_dv_ar;
/*******************************************************************************
*********
** TITLE :- PROCEDURE rcn_dv_ap
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :-
** AUTHOR :- Haribabu Pantakapu
** VERSION :- 1.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This is used to fetch data for Trintech ReconNET Reconcil
iation
** Payables (Payments)
** INPUTS :- p_date (mandatory)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 26-SEP-2008 Haribabu Pantakapu Initial Version of Code
** 14-OCT-2008 Haribabu Pantakapu To fix drilldown for EU
** 28-OCT-2008 Haribabu Pantakapu Adding new column to AP Drilldown - Ch
eck Run Name
** 06-FEB-2009 Haribabu Pantakapu Bank Account Name join commented in th
e query
** 10-FEB-2009 Haribabu Pantakapu AP Translator Drilldown - AX Global Ac
counting Engine
** 09-MAR-2009 Haribabu Pantakapu Added 3 new columns 1) void_date, clea
red_date and gl_date
** 19-Mar-2009 Haribabu Pantakapu 1) Removed the call function get_max_
gl_date to get gl_date
2) Accounting Date derived from ap_ae
_headers_all and ax_sle_lines
********************************************************************************
**********/
PROCEDURE rcn_dv_ap(errbuf OUT NOCOPY VARCHAR2
,retcode OUT NOCOPY NUMBER
,p_date IN VARCHAR2
)
IS
--- AX global accounting engine
-- AP Translator
-- Added on 10-Feb-2009 By Haribabu for AP Drilldown for AX
CURSOR C_AP_TRIT_CUR
IS
SELECT attribute7 doc_sequence_id
,attribute8 sle_header_id
,attribute9 gl_transfer_line_num
,accountname accountname
,tran_code tran_code
,attribute2 batch_name
FROM xxyh_trit_tmp
WHERE attribute3 = 'AP Translator'
AND attribute5 = 'AP';
BEGIN
x_progress := 'XXYH_TRIT_PKG.rcn_dv_ap:10';
INSERT INTO xxyh_trit_tmp(date_effective -- check date
,reporting_amt -- Functional
,attribute1 -- Bank Account Number
,attribute2 -- Check Number
,attribute3 -- Payment Method
,attribute4-- Supplier Name
,attribute6 -- Vendor Number
,attribute7 -- Bank Account Name
,local_cur -- Currency Code
,entered_amt -- Entered
,tran_code -- Tran Code GL-DR, GL-CR
,attribute8 -- status
,accountname -- account string
,date_posted -- value date
,attribute9 -- Beneficiary Name
,attribute10 -- Document Type
,attribute11 -- FX Rate
,attribute12 -- Batch Name
,attribute5
,attribute15
,attribute13 -- checkrun name
,void_date -- Added By Haribabu on 09-Mar-2009
,cleared_date -- Added By Haribabu on 09-Mar-2009
,gl_date -- Added By Haribabu on 09-Mar-2009
) -- Batch Name;
SELECT --DECODE(ACA.status_lookup_code,'VOIDED',ACA.void_date,A
CA.check_date) Check_date
ACA.check_date
,NVL(ACA.base_amount,ACA.amount)
,ABA.bank_account_num
,ACA.check_number
,ALC2.meaning
,PV.vendor_name
,PV.segment1
,ACA.bank_account_name
,ACA.currency_code
,ACA.amount
,XTT.tran_code
-- ,DECODE(SIGN(NVL(ACA.amount,0)),-1, 'GL-CR',1, 'GL-DR'
,0,'NONE')
,ALC1.meaning
,XTT.accountname -- Account String
,ACA.anticipated_value_date
,ACA.vendor_name
,ALC2.meaning
,ROUND(ACA.exchange_rate,2)
,XTT.attribute2
,'AP'
,'AP'
,ACA.checkrun_name
,ACA.void_date -- Added By Haribabu on 09-Mar-
2009
,ACA.cleared_date -- Added By Haribabu on 09-Mar-
2009
,AEHA.accounting_date -- Added By Haribabu on 19-Mar-
2009
FROM ap_checks_all ACA
,ap_bank_accounts_all ABA
,po_vendors PV
,fnd_lookup_values ALC1
,fnd_lookup_values ALC2
,ap_ae_headers_all AEHA -- Added By Haribabu on 19
-Mar-2009
,ap_ae_lines_all AELL
,xxyh_trit_tmp XTT
WHERE ABA.bank_account_id = ACA.bank_account_id
--AND ABA.bank_account_name = ACA.bank_account_name
AND ACA.org_id = ABA.org_id
AND ACA.vendor_id = PV.vendor_id
AND ALC1.lookup_type(+) = 'CHECK STATE'
AND ALC1.lookup_code(+) = ACA.status_lookup_code
AND ALC2.lookup_type(+) = 'PAYMENT METHOD'
AND ALC2.lookup_code(+) = ACA.payment_method_lookup_code
AND ACA.check_id = AELL.source_id
AND ACA.org_id = AELL.org_id
-- Commented By Haribabu For EU the doc_sequence_id and doc_sequ
ence_value
-- Is not populated.
--AND ACA.doc_sequence_id = AELL.subledger_doc_sequence_i
d
--AND ACA.doc_sequence_value = AELL.subledger_doc_sequence_v
alue
AND AELL.source_table = 'AP_CHECKS'
AND AELL.gl_sl_link_id = XTT.use_number_rep_5
AND AELL.ae_header_id = AEHA.ae_header_id -- Added By
Haribabu on 19-Mar-2009
AND AELL.org_id = AEHA.org_id -- Added By
Haribabu on 19-Mar-2009
AND XTT.attribute3 = 'Payables';
fnd_file.put_line(fnd_file.log,'SQL%ROWCOUNT AP '||SQL%ROWCOUNT);
COMMIT;
--- AX global accounting engine
-- AP Translator
-- Added on 10-Feb-2009 By Haribabu for AP Drilldown for AX
x_progress := 'XXYH_TRIT_PKG.rcn_dv_ap:20';
FOR L_REC IN C_AP_TRIT_CUR
LOOP
INSERT INTO xxyh_trit_tmp(date_effective -- check date
,reporting_amt -- Functional
,attribute1 -- Bank Account Number
,attribute2 -- Check Number
,attribute3 -- Payment Method
,attribute4-- Supplier Name
,attribute6 -- Vendor Number
,attribute7 -- Bank Account Name
,local_cur -- Currency Code
,entered_amt -- Entered
,tran_code -- Tran Code GL-DR, GL-CR
,attribute8 -- status
,accountname -- account string
,date_posted -- value date
,attribute9 -- Beneficiary Name
,attribute10 -- Document Type
,attribute11 -- FX Rate
,attribute12 -- Batch Name
,attribute5
,attribute15
,attribute13 -- checkrun name
,void_date -- Added By Haribabu on 09-Mar-2009
,cleared_date -- Added By Haribabu on 09-Mar-2009
,gl_date -- Added By Haribabu on 09-Mar-2009
) -- Batch Name;
SELECT --DECODE(aca.status_lookup_code,'VOIDED',aca.void_date
,aca.check_date) Check_date
ACA.check_date check_date
,NVL(aca.base_amount,aca.amount)
,aba.bank_account_num
,aca.check_number
,alc2.meaning
,t.vendor_name
,t.segment1
,aca.bank_account_name
,aca.currency_code
,aca.amount
,l_rec.tran_code
,alc1.meaning
,l_rec.accountname
,aca.anticipated_value_date
,aca.vendor_name
,alc2.meaning
,ROUND(aca.exchange_rate,2)
,l_rec.batch_name
,'AP'
,'AP'
,aca.checkrun_name
,ACA.void_date -- Added By Haribabu on 09-Ma
r-2009
,ACA.cleared_date -- Added By Haribabu on 09-Ma
r-2009
,h.effective_date -- Added By Haribabu on 19-Ma
r-2009
FROM ax_sle_headers h
,fnd_document_sequences d
,ap_checks_all aca
,ap_bank_accounts_all aba
,po_vendor_sites_all pvs
,po_vendors t
,fnd_lookup_values alc1
,fnd_lookup_values alc2
,ax_sle_lines l
WHERE h.journal_sequence_id = d.doc_sequence_id
AND h.application_id = 200
AND l.journal_sequence_id = h.journal_sequence_id
AND l.sle_header_id = h.sle_header_id
AND l.set_of_books_id = h.set_of_books_id
AND l.third_party_id IS NOT NULL
AND l.sub_id IS NOT NULL
AND l.third_party_id = t.vendor_id
AND t.vendor_id = pvs.vendor_id
AND l.sub_id = pvs.vendor_site_id
AND NVL(l.org_id, -99) = NVL(pvs.org_id, -99)
AND NVL(l.org_id, -99) = NVL(aca.org_id, -99)
AND l.source_id = aca.check_id
AND l.source_table = 'AP_CHECKS'
AND aba.bank_account_id = aca.bank_account_id
AND NVL(aca.org_id,-99) = NVL(aba.org_id,-99)
AND alc1.lookup_type(+) = 'CHECK STATE'
AND alc1.lookup_code(+) = aca.status_lookup_code
AND alc2.lookup_type(+) = 'PAYMENT METHOD'
AND alc2.lookup_code(+) = aca.payment_method_lookup
_code
AND d.doc_sequence_id = l_rec.doc_sequence_id
--1824
AND h.sle_header_id = l_rec.sle_header_id
--7761
AND l.gl_transfer_line_num = l_rec.gl_transfer_line_nu
m--391
;
END LOOP;
COMMIT;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_ap:20';
errbuf := NULL;
retcode := 0;

EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.log,x_progress || SUBSTR(SQLERRM,1,200));
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||x_progress;
retcode := 2;
END rcn_dv_ap;

/*******************************************************************************
*********
** TITLE :- PROCEDURE rcn_dv_gen
** $Id: XXYH_TRIT_PKG.pkb,v 1.11 2009/04/28 21:52:10 haribabu Exp $
** FILE NAME :-
** AUTHOR :- Haribabu Pantakapu
** VERSION :- 1.0
** CONTENTS :- Procedure creation script
** DESCRIPTION :- This is used to fetch data for Trintech ReconNET Reconciliat
ion
** For Payroll, Payables (Payments) and Receivables (Receipts)
** INPUTS :- p_date (mandatory), p_extract_type (mandatory)
** OUTPUTS :- extract file
** CREATION DATE :-
** CHANGE HISTORY :-
** Date Changed By Description
** 26-SEP-2008 Haribabu Pantakapu Initial Version of Code
** 30-SEP-2008 Haribabu Pantakapu Changes to output order of columns
** 06-OCT-2008 Haribabu Pantakapu Payroll Extract fix to the output.
** 28-OCT-2008 Haribabu Pantakapu Change Request - Reconnet Reconciliati
on
** 1) Adding to new field to extract outp
ut Item UDF14
** 2) Adding new column to AR Drilldown -
Batch Type
** 3) Change of mapping for AR Drilldown,
Batch# moved from
** Item UDF8 to UDF9
** 4) Adding new column to AP Drilldown -
Check Run Name
** 08-DEC-2008 Haribabu Pantakapu File name convention changed to includ
e 'POSTED DATE'
** i.e p_date parameter to the output fil
e.
** 20-Jan-2009 Haribabu Pantakapu Change Request
** 1) DFF at Set of Books to exclude the S
TAT set of books
** 10-Feb-2009 Haribabu Pantakapu AX Changes - for AP and AR Global Accou
nting Engine
** 24-Feb-2009 Haribabu Pantakapu Tran Code Issue fix.
** Tran Code to be populated based on the
entered as well as
** accounted amount fields, if both are ze
ro then NONE will be
** populated for Tran Code.
** 09-Mar-2009 Haribabu Pantakapu 1) Added 3 new columns to map for AP
** Item UDF15, 16 and 17
********************************************************************************
**********/
PROCEDURE rcn_dv_gen(errbuf OUT NOCOPY VARCHAR2
,retcode OUT NOCOPY NUMBER
,p_entity IN VARCHAR2
,p_date IN VARCHAR2
,p_extract_type IN VARCHAR2
)
AS
-- This cursor is to select the info for the extract.
-- declaration of variables.
CURSOR l_data_output
IS
SELECT *
FROM xxyh_trit_tmp;

l_data VARCHAR2(4000);
lv_value_set VARCHAR2(240);
lv_retcode NUMBER := 0;
lv_errbuf VARCHAR2(200);
lv_trit VARCHAR2(10);
--
BEGIN
fnd_file.put_line(fnd_file.log,'P ENTITY '||p_entity);
fnd_file.put_line(fnd_file.log,'P DATE '||p_date);
fnd_file.put_line(fnd_file.log,'P Extract Type '||p_extract_type);
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:10';
EXECUTE IMMEDIATE 'TRUNCATE TABLE XXYH.XXYH_TRIT_TMP DROP STORAGE';
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:20';
IF p_entity = 'XXYH_TRIT_US' THEN
lv_trit := 'US';
IF p_extract_type = 'Payroll' THEN
lv_value_set := 'XXYH_TRIT_RCN_US_PAYROLL_EXT';
ELSIF p_extract_type = 'Deposits' THEN
lv_value_set := 'XXYH_TRIT_RCN_US_DEPOSITS_EXT';
ELSE
lv_value_set := 'XXYH_TRIT_RCN_US_DISBURSEMENTS_EXT';
END IF;
ELSE
lv_trit := 'EU';
IF p_extract_type = 'Payroll' THEN
lv_value_set := 'XXYH_TRIT_RCN_EU_PAYROLL_EXT';
ELSIF p_extract_type = 'Deposits' THEN
lv_value_set := 'XXYH_TRIT_RCN_EU_DEPOSITS_EXT';
ELSE
lv_value_set := 'XXYH_TRIT_RCN_EU_DISBURSEMENTS_EXT';
END IF;
END IF;
fnd_file.put_line(fnd_file.log,'LV VALUE SET '||lv_value_set);
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:30';
INSERT INTO xxyh_trit_tmp(date_effective
,entered_amt
,accountname
,tran_code
,use_number_rep_1 -- je_header_id
,use_number_rep_2 -- je_line_num
,attribute1 -- je_description
,local_cur -- local_currency_code
,attribute2 -- batch name
,attribute3 -- je_source
,reporting_amt -- Accounted amount
,date_created
,attribute4 -- Journal name
,date_posted -- Posted Date
,use_number_rep_3 -- ccid
,use_number_rep_4 -- je_batch_id
,attribute5 -- 'GL'
,attribute15 -- Data Source -- 'GL'
,use_number_rep_5 -- gl_sl_link_id
,attribute6 -- set_of_books_id
,attribute7 -- subledger_doc_sequence_id
,attribute8 -- subledger_doc_sequence_value
,attribute9 -- reference9
)
SELECT GJH.default_effective_date -- Date_Effe
ctive
,ABS(NVL(GJL.entered_dr,0) - NVL(GJL.entered_cr,0)) -- Local_Amo
unt
,GCCK.concatenated_segments -- GL_Accoun
t
--,DECODE ( SIGN((NVL(GJL.entered_dr,0)
-- - NVL(GJL.entered_cr,0))),
-- '-1', 'GL-CR',
-- '1', 'GL-DR', '0', 'NONE') -- Tran_Co
de
,DECODE ( SIGN((NVL(entered_dr,0) - NVL(entered_cr,0))),
'-1', 'GL-CR',
'1', 'GL-DR',
'0', Decode (Sign((Nvl(accounted_dr,0) - Nvl(account
ed_cr,0))),
'-1','GL-CR',
'1', 'GL-DR',
'0', 'NONE'),
'NONE') -- Tran_Code
,GJL.je_header_id -- Je_Header
_Id -- use_number_rep_1
,GJL.je_line_num -- Je_Line_N
um -- use_number_rep_2
,GJL.description -- Je_Descri
ption
,GJH.currency_code -- Currency_
Code
,GJB.name -- Batch_Nam
e
,GJH.je_source --Je_Source
,ABS(NVL(GJL.accounted_dr,0) - NVL(GJL.accounted_cr,0)) --Reporting
_Amount
,GJH.date_created --Date_Crea
ted
,GJH.name --Journal_N
ame
,GJH.posted_date --Posted_Da
te
,GCCK.code_combination_id --ccid --
use_number_rep_3
,GJB.je_batch_id --use_numbe
r_rep_4
,DECODE(GJH.je_source,'Payables','AP','Receivables','AR','Payroll',
'PAY','AR Translator','GL','AP Translator','AP','GL')
,'GL'
,GJL.gl_sl_link_id
,GJH.set_of_books_id
,GJL.subledger_doc_sequence_id -- attribute7
,GJL.subledger_doc_sequence_value -- attribute8
,GJL.reference_9 -- attribute9
FROM gl_je_headers GJH
,gl_je_lines GJL
,gl_code_combinations_kfv GCCK
,gl_je_batches GJB
,fnd_flex_value_sets FFVS
,fnd_flex_values_vl FFV
,fnd_flex_value_sets FFVS1
,fnd_flex_values_vl FFV1
WHERE GJH.je_header_id = GJL.je_header_id
AND GJH.set_of_books_id = GJL.set_of_books_id
AND GJH.set_of_books_id = GJB.set_of_books_id(+)
AND GJL.code_combination_id = GCCK.code_combination_id
/*AND GJH.set_of_books_id NOT IN ( SELECT set_of_books_id
FROM gl_sets_of_books
WHERE name = 'YAHOO! CONSOLIDATED
' )*/
AND EXISTS (SELECT 'x'
FROM xxyh_trit_sob_v GSOB
WHERE GSOB.set_of_books_id = GJH.set_of_books_id
)
AND GJH.je_batch_id = GJB.je_batch_id(+)
AND FFVS.flex_value_set_id = FFV.flex_value_set_id
AND FFVS.flex_value_set_name = lv_value_set
AND GCCK.concatenated_segments = FFV.flex_value
AND SYSDATE BETWEEN NVL(FFV.start_date_active,SYSDATE) AND NVL(FFV.end_
date_active,SYSDATE)
AND FFV.enabled_flag = 'Y'
AND FFV1.flex_value_set_id = FFVS1.flex_value_set_id
AND FFV1.flex_value = GCCK.segment1
AND FFV1.attribute16 IS NULL
AND SYSDATE BETWEEN NVL(FFV1.start_date_active,SYSDATE) AND NVL(FFV1.en
d_date_active,SYSDATE)
AND FFV1.enabled_flag = 'Y'
AND FFVS1.flex_value_set_name = p_entity
AND TRUNC(GJH.posted_date) = TRUNC(fnd_date.CANONICAL_TO_DATE(p_date
));
COMMIT;
fnd_file.put_line(fnd_file.log,'SQL%ROWCOUNT GL '||SQL%ROWCOUNT);
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:40';
println(2, 'Printing the Header Info: ' || SYSDATE);
println(1,'Source,'
||'Date,'
||'Amount,'
||'GL Account,'
||'Tran Code,'
||'Serial,'
||'Item UDF1,'
||'Item UDF2,'
||'Item UDF3,'
||'Item UDF4,'
||'Item UDF5,'
||'Item UDF6,'
||'Item UDF7,'
||'Item UDF8,'
||'Item UDF9,'
||'Item UDF10,'
||'Item UDF11,'
||'Item UDF12,'
||'Item UDF13,'
||'Item UDF14,'
||'Item UDF15,' -- Added By Haribabu for new AP fields(void_date, c
leared_date and gl_date)
||'Item UDF16,' -- Added By Haribabu for new AP fields(void_date, c
leared_date and gl_date)
||'Item UDF17');-- Added By Haribabu for new AP fields(void_date, c
leared_date and gl_date)
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:50';
FOR lr_rec IN l_data_output
LOOP
l_data := NULL;
IF lr_rec.attribute5 IN ('GL','PAY') AND lr_rec.attribute15 = 'GL' THEN
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:60';
l_data := '"'||lr_rec.attribute5||'"'||','||
'"'||TO_CHAR(lr_rec.date_effective,'DD-MON-YYYY')||'"'||','|| --
- Effective Date
'"'||ROUND(lr_rec.entered_amt,2)||'"'||','|| -- Entered Amount
'"'||lr_rec.accountname||'"'||','|| -- GL Account String
'"'||lr_rec.tran_code||'"'||','|| -- Tran Code 'GL-DR', CR
'"'||ROUND(lr_rec.reporting_amt,2)||'"'||','|| -- Accounted Amou
nt
'"'||lr_rec.local_cur||'"'||','|| -- Currency Code
'"'||lr_rec.attribute1||'"'||','|| -- Journal Line Description
'"'||TO_CHAR(lr_rec.date_posted,'DD-MON-YYYY')||'"'||','|| -- Po
sted Date
'"'||lr_rec.attribute3||'"'||','|| -- Journal Source
'"'||NVL(lr_rec.attribute2,'')||'"'||','|| -- Batch Name
'"'||lr_rec.attribute4||'"'||','|| -- Journal Name
'"'||NULL||'"'||','|| -- Item UDF7
'"'||NULL||'"'||','|| -- Item UDF8
'"'||NULL||'"'||','|| -- Item UDF9
'"'||NULL||'"'||','|| -- Item UDF10
'"'||NULL||'"'||','|| -- Item UDF11
'"'||NULL||'"'||','|| -- Item UDF12
'"'||NULL||'"'||','|| -- Item UDF13
'"'||NULL||'"'||','|| -- Item UDF14
'"'||NULL||'"'||','|| -- Item UDF15 Added By Haribabu for new A
P fields(void_date, cleared_date and gl_date)
'"'||NULL||'"'||','|| -- Item UDF16 Added By Haribabu for new A
P fields(void_date, cleared_date and gl_date)
'"'||NULL||'"'; -- Item UDF17 Added By Haribabu for new A
P fields(void_date, cleared_date and gl_date)
println(1, l_data);
END IF;
END LOOP;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:70';
rcn_dv_ar(errbuf => lv_errbuf
,retcode => lv_retcode
,p_date => p_date
);
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:80';
IF lv_retcode <> 0 THEN
errbuf := 'Unexpected error in Procedure rcn_dv_ar '||p_extract_type;
retcode := 2;
END IF;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:90';
rcn_dv_ap(errbuf => lv_errbuf
,retcode => lv_retcode
,p_date => p_date
);
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:100';
IF lv_retcode <> 0 THEN
errbuf := 'Unexpected error in Procedure rcn_dv_ap '||p_extract_type;
retcode := 2;
END IF;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:110';
FOR lr_rec IN l_data_output
LOOP
l_data := NULL;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:120';
fnd_file.put_line(fnd_file.log,'x_progress '||x_progress);
IF lr_rec.attribute5 = 'AR' and lr_rec.attribute15 = 'AR' THEN
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:130';
fnd_file.put_line(fnd_file.log,'x_progress '||x_progress);
l_data :='"'||lr_rec.attribute5||'"'||','||
'"'||TO_CHAR(lr_rec.date_effective,'DD-MON-YYYY')||'"'||','
|| -- Receipt Date
'"'||ROUND(lr_rec.reporting_amt,2)||'"'||','|| -- Amount Fu
nctional
'"'||lr_rec.accountname||'"'||','|| -- Account String
'"'||lr_rec.tran_code||'"'||','|| -- Tran Code GL-CR or GL
-Dr
'"'||ROUND(lr_rec.entered_amt,2)||'"'||','|| -- Amount Ente
red
'"'||lr_rec.local_cur||'"'||','|| -- Currency Code
'"'||lr_rec.attribute1||'"'||','|| -- Customer Name
'"'||TO_CHAR(lr_rec.date_posted,'DD-MON-YYYY')||'"'||','||
-- AR's GL Date
'"'||lr_rec.attribute4||'"'||','|| -- Status
'"'||lr_rec.attribute6||'"'||','|| -- comments
'"'||NULL||'"'||','|| -- Item UDF6
'"'||lr_rec.attribute2||'"'||','|| -- Receipt Number
'"'||lr_rec.attribute7||'"'||','|| -- Batch # AR
'"'||lr_rec.attribute3||'"'||','|| -- Batch Name GL
'"'||NULL||'"'||','|| -- Item UDF10
'"'||NULL||'"'||','|| -- Item UDF11
'"'||NULL||'"'||','|| -- Item UDF12
'"'||NULL||'"'||','|| -- Item UDF13
'"'||NULL||'"'||','|| -- Item UDF14
'"'||NULL||'"'||','|| -- Item UDF15 Added By Haribabu for
new AP fields(void_date, cleared_date and gl_date)
'"'||NULL||'"'||','|| -- Item UDF16 Added By Haribabu for
new AP fields(void_date, cleared_date and gl_date)
'"'||NULL||'"'; -- Item UDF17 Added By Haribabu for
new AP fields(void_date, cleared_date and gl_date)
println(1, l_data);
ELSIF lr_rec.attribute5 = 'AP' and lr_rec.attribute15 = 'AP' THEN
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:140';
l_data := '"'||lr_rec.attribute5||'"'||','||
'"'||TO_CHAR(lr_rec.date_effective,'DD-MON-YYYY')||'"'||','
|| -- check date
'"'||ROUND(lr_rec.reporting_amt,2)||'"'||','|| -- Function
al
'"'||lr_rec.accountname||'"'||','|| -- account string
'"'||lr_rec.tran_code||'"'||','|| -- Tran Code GL-DR, GL-CR
'"'||ROUND(lr_rec.entered_amt,2)||'"'||','|| -- Entered
'"'||lr_rec.local_cur||'"'||','|| -- Currency Code
'"'||lr_rec.attribute4||'"'||','|| -- Supplier Name
'"'||NVL(TO_CHAR(lr_rec.date_posted,'DD-MON-YYYY'),'')||'"'
||','|| -- value date
'"'||lr_rec.attribute8||'"'||','|| -- status
'"'||lr_rec.attribute3||'"'||','|| -- Payment Method
'"'||lr_rec.attribute7||'"'||','|| -- Bank Account Name
'"'||lr_rec.attribute2||'"'||','|| -- Check Number
'"'||lr_rec.attribute6||'"'||','|| -- Vendor Number
'"'||lr_rec.attribute1||'"'||','|| -- Bank Account Number
'"'||lr_rec.attribute9||'"'||','|| -- Beneficiary Name
'"'||lr_rec.attribute10||'"'||','|| -- Document Type
'"'||lr_rec.attribute11||'"'||','|| -- FX Rate
'"'||lr_rec.attribute12||'"'||','|| -- Batch Name
'"'||lr_rec.attribute13||'"'||','|| -- Check Run Name
'"'||NVL(TO_CHAR(lr_rec.void_date,'DD-MON-YYYY'),'')||'"'||
','|| -- Void Date
'"'||NVL(TO_CHAR(lr_rec.cleared_date,'DD-MON-YYYY'),'')||'"
'||','|| -- Cleared Date
'"'||NVL(TO_CHAR(lr_rec.gl_date,'DD-MON-YYYY'),'')||'"';
-- Gl Date
println(1, l_data);
ELSE
NULL;
END IF;
END LOOP;
x_progress := 'XXYH_TRIT_PKG.rcn_dv_gen:150';
--
-- launch concurrent program to cp out put to trintech directory
println(2, 'launching cp program ...');
x_sfile := 'o'||x_request_id||'.out';
x_dfile := p_extract_type||'_'||lv_trit||TO_CHAR(SYSDATE,'MMDDYYYY')||'_'||
TO_CHAR(TRUNC(fnd_date.CANONICAL_TO_DATE(p_date)),'MMDDYYYY')||'.csv';
--
cp_output('TRIT-RCN-O', x_sfile, x_dfile);
println(2, 'launching cp program done');
--
errbuf := NULL;
retcode := 0;
--
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line(fnd_file.log,x_progress || SUBSTR(SQLERRM,1,200));
errbuf := SUBSTR(SQLERRM, 1, 200)||'at :'||x_progress;
retcode := 2;
END rcn_dv_gen;
--
END XXYH_TRIT_PKG;
/

Você também pode gostar