Escolar Documentos
Profissional Documentos
Cultura Documentos
--
/*******************************************************************************
*********
** 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);
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
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 ;
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);
x_progress := 'XXYH_TRIT_PKG.ASN_GL:120';
println(2, x_progress);
x_progress := 'XXYH_TRIT_PKG.ASN_GL:140';
println(2, x_progress);
x_progress := 'XXYH_TRIT_PKG.ASN_GL:150';
println(2, x_progress);
x_progress := 'XXYH_TRIT_PKG.ASN_GL:170';
println(2, x_progress);
-- end compute group by
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;
/