Beruflich Dokumente
Kultur Dokumente
CHANGE HISTORY
==============
VERSION DATE
AUTHOR
CHANGE DESCRIPTION
------- ----------- --------------- ------ -----------------------------------1.0
01-Jul-2013 Siva Prasad
initial Release
1.1
16-Jul-2013 Siva
Removed
insert to HFM interface table
1.2
12-AUG-2013 Siva
Changes to accounts from P13
to have '_ADJ'
1.3
04-SEP-2013 Harjit
Removed delete from ICAP_HFM
_AIF_OPEN_INTERFACE statements.
Now using a procedure in rem
ote database instead.
1.4
11-SEP-2013 Vinod Durbhaka
Added a wrapper
FUNCTION submit_hfm_stat_actuals
to submit the concurrent program from command line.
Logic includes supplying any parameters when
not passed. They will be picked from the table
ICAP_GAA_PARAMETERS.
*****************************************************************************
**/
-- Global variables section
g_debug
VARCHAR2(1);
TYPE t_error IS RECORD(error_date DATE
,error_location VARCHAR2(100)
,error_message VARCHAR2(4000)
);
TYPE t_errors IS TABLE OF t_error INDEX BY BINARY_INTEGER;
g_errors
t_errors;
/****************************************************************************
*
PROCEDURE:
write_log
writes the date, location of the program and the message to the
log.
PARAMETERS:
NAME
--------------1. p_location
2. p_message
TYPE
-------VARCHAR2
VARCAHR2
DESCRIPTION
--------------------------------------Location of the log within the program
Message to be written
*****************************************************************************
/
PROCEDURE write_log(p_location IN VARCHAR2
,p_message IN VARCHAR2) IS
BEGIN
FND_FILE.PUT_LINE(FND_FILE.LOG
,fnd_date.date_to_displayDT(sysdate)
|| ' ' || p_location || '
);
' || p_message
END write_log;
/* *************************************************************************
***
PROCEDURE:
write_output
TYPE
-------VARCHAR2
VARCAHR2
DESCRIPTION
--------------------------------------Location of the log within the program
Message to be written
****************************************************************************
*/
PROCEDURE write_output(p_message
IN VARCHAR2) IS
BEGIN
FND_FILE.PUT_LINE(FND_FILE.OUTPUT, p_message);
END write_output;
/* ****************************************************************************
PROCEDURE: debug
DESCRIPTION: Writes a string to the concurrent request log if the debug
parameter has been set in the package.
PARAMETERS:
NAME
---------------
TYPE
--------
DESCRIPTION
---------------------------------------
1. p_location
2. p_message
VARCHAR2
VARCAHR2
****************************************************************************
*/
PROCEDURE debug(p_location IN VARCHAR2
,p_message IN VARCHAR2) IS
BEGIN
IF nvl(g_debug, 'N') = 'Y' THEN
write_log(p_location => p_location, p_message => p_message);
END IF;
END debug;
/* **************************************************************************
**
PROCEDURE:
write_error
DESCRIPTION: Writes an error message to the concurrent request log and stores
the error message in the global errors collection.
PARAMETERS:
NAME
--------------1. p_location
2. p_message
TYPE
-------VARCHAR2
VARCHAR2
DESCRIPTION
--------------------------------------Location of the error within the program
Message to be written
****************************************************************************
*/
PROCEDURE write_error(p_location IN VARCHAR2
,p_message IN VARCHAR2) IS
v_date
DATE;
v_text
VARCHAR2(2000);
v_location VARCHAR2(30) := 'output_report';
BEGIN
v_date := sysdate;
g_errors(g_errors.count+1).error_date := sysdate;
g_errors(g_errors.count).error_location := p_location;
g_errors(g_errors.count).error_message := p_message;
write_log(p_location => p_location, p_message => '*** ERROR *** ' || p_mes
sage);
END write_error;
/* *************************************************************************
***
PROCEDURE:
Delete_HFM_DATA
PARAMETERS: period
NAME
---------------
TYPE
--------
DESCRIPTION
---------------------------------------
****************************************************************************
*/
PROCEDURE DELETE_HFM_DATA(p_period IN VARCHAR2 )
IS
lc_curr_proc
VARCHAR2(40) := 'DELETE HFM BALANCES';
lc_period_num
VARCHAR2(10);
lc_year
VARCHAR2(4);
ln_err_cnt
NUMBER := 0;
ln_rec_cnt
NUMBER := 0;
LN_START
number := 0;
ln_env_name
varchar2(10);
BEGIN
select period_num,period_year into lc_period_num, lc_year
from gl_periods
where period_name=p_period
and period_set_name = 'ICAP-Calendar'
and rownum =1;
select value into ln_env_name from V$PARAMETER where name ='instance_name' a
nd rownum=1;
debug(lc_curr_proc, '-------------------------------------');
ln_start := dbms_utility.get_time;
write_output('Delete existing HFM balances for period : '||p_period);
debug(lc_curr_proc, 'Delete existing HFM balances for period : '||p_period);
/* below procedure call now delete the data in remote database (added by Ha
rjit) */
ICAP_HFM_DEL_ERPI_OI.DELETE_HFM_STAT_INTERFACE('HFM_Stat_'||ln_env_name,'AC
T');
COMMIT;
write_output('HFM Balance rows Deleted');
-- write_output('HFM Balance rows Deleted : '||ln_rec_cnt);
-- debug(lc_curr_proc, 'HFM Balance rows Deleted for period('||p_period||')
:'||ln_rec_cnt);
debug(lc_curr_proc, 'Time taken for Deleting HFM Balances(secs) :'||to_cha
r((dbms_utility.get_time-ln_start)/100));
EXCEPTION
WHEN OTHERS THEN
write_error(lc_curr_proc,'Error in DELETE_HFM_DATA:'||SQLERRM);
END DELETE_HFM_DATA;
/* ***********************************************************************
*****
PROCEDURE: LOAD_HFM_DATA
DESCRIPTION: This procedure is used to refresh the interface table
for the GAA Mgmt Overnight view for a given period
PARAMETERS: period
NAME
---------------
TYPE
--------
DESCRIPTION
---------------------------------------
****************************************************************************
*/
PROCEDURE LOAD_HFM_DATA(p_period
IS
lc_curr_proc
lc_period_num
lc_year
lc_month
ln_err_cnt
ln_start
ln_rec_cnt
ln_count
ln_env_name
--ln_temp
ln_curr_period
IN VARCHAR2)
VARCHAR2(40) := 'LOAD_HFM_DATA';
VARCHAR2(10);
VARCHAR2(4);
VARCHAR2(2);
NUMBER := 0;
NUMBER := 0;
NUMBER := 0;
number :=0;
varchar2(30);
varchar2(10);
varchar2(10);
BEGIN
debug(lc_curr_proc, '-------------------------------------');
select period_num,period_year into lc_period_num, lc_year
from gl_periods
where period_name=p_period
and period_set_name = 'ICAP-Calendar'
and rownum =1;
--SELECT substr(period_name,1,3) into ln_curr_period
--FROM GL_PERIODS GP
-- WHERE TRUNC(sysdate) BETWEEN START_DATE AND END_DATE
-- and ADJUSTMENT_PERIOD_FLAG <> 'Y'
-- AND period_set_name = 'ICAP-Calendar'
-- and rownum=1;
ln_curr_period :='APR';
select value into ln_env_name from V$PARAMETER where name ='instance_name' a
nd rownum=1;
ln_start := dbms_utility.get_time;
debug(lc_curr_proc,'Start loading HFM Balances into staging table for period
: '||p_period);
write_output('Start loading HFM Balances into staging table for period : '||p
_period);
EXECUTE IMMEDIATE 'TRUNCATE TABLE ICAP.ICAP_TBL_FACT_ACT_HFM_STG';
if (p_period like 'MAR%' and ln_curr_period like 'APR%') then
INSERT INTO ICAP.ICAP_TBL_FACT_ACT_HFM_STG
with
ADJ_PER_HIGH_LOW(ADJ_PERIOD_YEAR_HIGH,
ADJ_PERIOD_YEAR_LOW,
ADJ_START_DTAE,
adj_end_date)
as
(select PERIOD_YEAR-2
, PERIOD_YEAR-5 ,YEAR_START_DATE , end_date from GL_PERIODS
where PERIOD_NAM
E=p_period
and PERIOD_SET_N
AME='ICAP-Calendar'),
hfm_view as (
select to_number(fin_year) fin_year
,SUBSTR(time,1,3) time
,to_number(fin_month) fin_month
,functionalcurrency
,scenario
,account
,account_type
,company
,costcentre
,intercompany
,product
,project
,erpi_resp_id
,erpi_resp_appl_id
,erpi_balance_type
,erpi_sob_id
,erpi_period
,erpi_code_combination_id
,NVL(FUNCTCURR_DATA_YTD,0) FUNCT
CURR_DATA_YTD
from ICAP.ICAP_TBL_FACT_ACT_HFM_
MAR_V where
fin_year=lc_year
and fin_month=lc_period_num
and replace(time,'_','-') = p_pe
riod
and functionalcurrency <>'STAT'
union all
select to_number(lc_year) fin_year
,SUBSTR(p_period,1,3) time
, to_number(lc_period_num) fin_month
,functionalcurrency
,scenario
,account||'_ADJ' account
,account_type
,company
,costcentre
,intercompany
,product
,project
,erpi_resp_id
,erpi_resp_appl_id
,erpi_balance_type
,erpi_sob_id
,p_period erpi_period
,erpi_code_combination_id
,NVL(FUNCTCURR_DATA_PTD,0) FUNC
TCURR_DATA_YTD
from
ICAP.ICAP_TBL_FACT_ACT_HFM_MAR_V ita , gl_per
iods gp
where
((gp.period_year =lc_year and gp.period_num <=
lc_period_num)
or gp.period_year <lc_year)
and ita.time like 'P13%'
and account_type in ('E','R')
and replace(ita.postingperiod,'_','-')= gp.perio
d_name
and gp.PERIOD_SET_NAME = 'ICAP-Calendar'
and ita.functionalcurrency <>'STAT'
union all
select TO_NUMBER(LC_YEAR) FIN_YEAR
,SUBSTR(P_PERIOD,1,3) time
, to_number(lc_period_num) fin_month
,functionalcurrency
,scenario
,account||'_ADJ' account
,account_type
,company
,costcentre
,intercompany
,product
,project
,erpi_resp_id
,erpi_resp_appl_id
,erpi_balance_type
,ERPI_SOB_ID
,p_period erpi_period
,erpi_code_combination_id
,NVL(FUNCTCURR_DATA_PTD,0) FUNC
TCURR_DATA_YTD
from
ICAP.ICAP_TBL_FACT_ACTUALS ita , gl_periods g
p ,ADJ_PER_HIGH_LOW ahl
where
ITA.FIN_YEAR between AHL.ADJ_PERIOD_YEAR_LOW
and ADJ_PERIOD_YEAR_HIGH
and gp.start_date between ahl.ADJ_START_DTAE a
nd ahl.adj_end_date
and ita.time like 'P13%'
and account_type in ('E','R')
and replace(ITA.POSTINGPERIOD,'_','-')= GP.PERIO
D_NAME
and gp.PERIOD_SET_NAME = 'ICAP-Calendar'
E=p_period
and PERIOD_SET_N
AME='ICAP-Calendar'),
hfm_view as (
select to_number(fin_year) fin_year
,SUBSTR(time,1,3) time
,to_number(fin_month) fin_month
,functionalcurrency
,scenario
,account
,account_type
,company
,costcentre
,intercompany
,product
,project
,erpi_resp_id
,erpi_resp_appl_id
,erpi_balance_type
,erpi_sob_id
,erpi_period
,erpi_code_combination_id
,NVL(FUNCTCURR_DATA_YTD,0) FUNCT
CURR_DATA_YTD
from ICAP.ICAP_TBL_FACT_ACT_HFM_
OVR_V where
fin_year=lc_year
and fin_month=lc_period_num
and replace(time,'_','-') = p_pe
riod
and functionalcurrency <>'STAT'
union all
select to_number(lc_year) fin_year
,SUBSTR(p_period,1,3) time
, to_number(lc_period_num) fin_month
,functionalcurrency
,scenario
,account||'_ADJ' account
,account_type
,company
,costcentre
,intercompany
,product
,project
,erpi_resp_id
,erpi_resp_appl_id
,erpi_balance_type
,erpi_sob_id
,p_period erpi_period
,erpi_code_combination_id
,NVL(FUNCTCURR_DATA_PTD,0) FUNC
TCURR_DATA_YTD
from
ICAP.ICAP_TBL_FACT_ACT_HFM_OVR_V ita , gl_per
iods gp
where
((gp.period_year =lc_year and gp.period_num <=
lc_period_num)
or gp.period_year <lc_year)
and ita.time like 'P13%'
,erpi_period ATTR5
,erpi_code_combination_id ATTR6
,SUM(NVL(FUNCTCURR_DATA_YTD,0)) AMOUNT
from hfm_view
-- where account_type in ('E','R')
group by fin_year
,SUBSTR(time,1,3)
,fin_month
,functionalcurrency
,scenario
,account
,company
,costcentre
,intercompany
,product
,project
,erpi_resp_id
,erpi_resp_appl_id
,erpi_balance_type
,erpi_sob_id
,erpi_period
,erpi_code_combination_id;
ln_rec_cnt := SQL%ROWCOUNT;
COMMIT;
end if;
WRITE_OUTPUT('HFM Balance rows loaded : '||LN_REC_CNT);
DEBUG(LC_CURR_PROC, 'HFM Balance rows loaded into staging table for period(
'||P_PERIOD||') :'||LN_REC_CNT);
DEBUG(LC_CURR_PROC, 'Time taken for loading HFM Balances into staging table
(secs) :'||TO_CHAR((DBMS_UTILITY.GET_TIME-LN_START)/100));
ln_start := dbms_utility.get_time;
debug(lc_curr_proc,'Start loading HFM Balances for period : '||p_period);
write_output('Start loading HFM Balances for period : '||p_period);
insert into ICAP_HFM_AIF_OPEN_INTERFACE (
BATCH_NAME
,YEAR
,PERIOD
,PERIOD_NUM
,DATAVIEW
,CURRENCY
,DESC1
,COL01
,COL02
,COL04
,COL06
,COL10
,COL14
,COL16
,ATTR1
,ATTR2
,ATTR3
,ATTR4
,ATTR5
,ATTR6
,AMOUNT)
select * from ICAP.ICAP_TBL_FACT_ACT_HFM_STG;
ln_rec_cnt := SQL%ROWCOUNT;
COMMIT;
write_output('HFM Balance rows loaded : '||ln_rec_cnt);
debug(lc_curr_proc, 'HFM Balance rows loaded for period('||p_period||') :'|
|ln_rec_cnt);
debug(lc_curr_proc, 'Time taken for loading HFM Balances(secs) :'||to_char
((dbms_utility.get_time-ln_start)/100));
EXCEPTION
WHEN OTHERS THEN
write_error(lc_curr_proc,'Error in LOAD_HFM_DATA:'||SQLERRM);
RAISE;
END LOAD_HFM_DATA;
/**************************************************************************
***
PROCEDURE:
MAIN
In VARCHAR2)
IS
lc_curr_proc
VARCHAR2(40) := 'MAIN
';
BEGIN
g_debug := p_debug;
debug(lc_curr_proc, 'Starting HFM Load program main, Period :'||p_per
iod);
write_output('Starting HFM Load program main');
LOAD_HFM_DATA(p_period);
EXCEPTION
WHEN OTHERS THEN
write_error(lc_curr_proc,'Error in main:'||SQLCODE||' ,Error: '||SQLERRM)
;
retcode := 2;
END MAIN;
/*****************************************************************************
FUNCTION: submit_hfm_stat_actuals
DESCRIPTION: This function can be directly called from the command line.
This submits a concurrent program to ensure all
the information