30: -- Set default directory in case if the profile option
31: -- BIS_DEBUG_LOG_DIRECTORY is not set up
32: ------------------------------------------------------
33: if l_dir is NULL then
34: l_dir := FII_UTIL.get_utl_file_dir;
35: end if;
36:
37: ----------------------------------------------------------------
38: -- FII_UTIL.initialize will get profile options FII_DEBUG_MODE
34: l_dir := FII_UTIL.get_utl_file_dir;
35: end if;
36:
37: ----------------------------------------------------------------
38: -- FII_UTIL.initialize will get profile options FII_DEBUG_MODE
39: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
40: -- the log files and output files are written to
41: ----------------------------------------------------------------
42: FII_UTIL.initialize('FII_CURR_CONV_MAINTAIN_PKG.log',
38: -- FII_UTIL.initialize will get profile options FII_DEBUG_MODE
39: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
40: -- the log files and output files are written to
41: ----------------------------------------------------------------
42: FII_UTIL.initialize('FII_CURR_CONV_MAINTAIN_PKG.log',
43: 'FII_CURR_CONV_MAINTAIN_PKG.out', l_dir,
44: 'FII_CURR_CONV_MAINTAIN_PKG');
45:
46: g_phase := 'Check debug mode';
47:
48: -- Determine if process will be run in debug mode
49: IF (NVL(G_Debug_Mode, 'N') <> 'N') THEN
50: FIIDIM_Debug := TRUE;
51: FII_UTIL.Write_Log ('Debug On');
52: ELSE
53: FIIDIM_Debug := FALSE;
54: FII_UTIL.Write_Log ('Debug Off');
55: END IF;
50: FIIDIM_Debug := TRUE;
51: FII_UTIL.Write_Log ('Debug On');
52: ELSE
53: FIIDIM_Debug := FALSE;
54: FII_UTIL.Write_Log ('Debug Off');
55: END IF;
56:
57: g_phase := 'Obtain FII schema name and user info';
58:
56:
57: g_phase := 'Obtain FII schema name and user info';
58:
59: -- Obtain FII schema name
60: g_schema_name := FII_UTIL.get_schema_name ('FII');
61:
62: -- Obtain user ID, login ID and initialize package variables
63: FII_USER_ID := FND_GLOBAL.USER_ID;
64: FII_LOGIN_ID := FND_GLOBAL.LOGIN_ID;
65:
66: -- If some of the above values is not set, error out
67: IF (FII_User_Id is NULL OR
68: FII_Login_Id is NULL) THEN
69: FII_UTIL.Write_Log ('>>> Failed Intialization');
70: RAISE EX_fatal_err;
71: END IF;
72:
73: g_phase := 'Obtain global start date, currencies and rate types';
78: g_prim_rate_type := bis_common_parameters.get_rate_type;
79: g_sec_rate_type := bis_common_parameters.get_secondary_rate_type;
80:
81: IF (FIIDIM_Debug) THEN
82: FII_UTIL.Write_Log ('g_global_start_date: '|| g_global_start_date);
83: FII_UTIL.Write_Log ('g_prim_currency: '|| g_prim_currency);
84: FII_UTIL.Write_Log ('g_sec_currency: '|| g_sec_currency);
85: FII_UTIL.Write_Log ('g_prim_rate_type: '|| g_prim_rate_type);
86: FII_UTIL.Write_Log ('g_sec_rate_type: '|| g_sec_rate_type);
79: g_sec_rate_type := bis_common_parameters.get_secondary_rate_type;
80:
81: IF (FIIDIM_Debug) THEN
82: FII_UTIL.Write_Log ('g_global_start_date: '|| g_global_start_date);
83: FII_UTIL.Write_Log ('g_prim_currency: '|| g_prim_currency);
84: FII_UTIL.Write_Log ('g_sec_currency: '|| g_sec_currency);
85: FII_UTIL.Write_Log ('g_prim_rate_type: '|| g_prim_rate_type);
86: FII_UTIL.Write_Log ('g_sec_rate_type: '|| g_sec_rate_type);
87: END IF;
80:
81: IF (FIIDIM_Debug) THEN
82: FII_UTIL.Write_Log ('g_global_start_date: '|| g_global_start_date);
83: FII_UTIL.Write_Log ('g_prim_currency: '|| g_prim_currency);
84: FII_UTIL.Write_Log ('g_sec_currency: '|| g_sec_currency);
85: FII_UTIL.Write_Log ('g_prim_rate_type: '|| g_prim_rate_type);
86: FII_UTIL.Write_Log ('g_sec_rate_type: '|| g_sec_rate_type);
87: END IF;
88:
81: IF (FIIDIM_Debug) THEN
82: FII_UTIL.Write_Log ('g_global_start_date: '|| g_global_start_date);
83: FII_UTIL.Write_Log ('g_prim_currency: '|| g_prim_currency);
84: FII_UTIL.Write_Log ('g_sec_currency: '|| g_sec_currency);
85: FII_UTIL.Write_Log ('g_prim_rate_type: '|| g_prim_rate_type);
86: FII_UTIL.Write_Log ('g_sec_rate_type: '|| g_sec_rate_type);
87: END IF;
88:
89: -- If some of the above values is not set, error out
82: FII_UTIL.Write_Log ('g_global_start_date: '|| g_global_start_date);
83: FII_UTIL.Write_Log ('g_prim_currency: '|| g_prim_currency);
84: FII_UTIL.Write_Log ('g_sec_currency: '|| g_sec_currency);
85: FII_UTIL.Write_Log ('g_prim_rate_type: '|| g_prim_rate_type);
86: FII_UTIL.Write_Log ('g_sec_rate_type: '|| g_sec_rate_type);
87: END IF;
88:
89: -- If some of the above values is not set, error out
90: IF (g_global_start_date is NULL OR
89: -- If some of the above values is not set, error out
90: IF (g_global_start_date is NULL OR
91: g_prim_currency is NULL OR
92: g_prim_rate_type is NULL) THEN
93: FII_UTIL.Write_Log ('>>> Failed Intialization');
94: RAISE EX_fatal_err;
95: END IF;
96:
97: g_phase := 'Get the start date of the current period';
107: -- Turn trace on if process is run in debug mode
108: IF (FIIDIM_Debug) THEN
109: -- Program running in debug mode, turning trace on
110: EXECUTE IMMEDIATE 'ALTER SESSION SET SQL_TRACE TRUE';
111: FII_UTIL.Write_Log ('Initialize: Set Trace On');
112: END IF;
113:
114: Exception
115:
113:
114: Exception
115:
116: When others then
117: FII_UTIL.Write_Log ('Unexpected error when calling Initialize...');
118: FII_UTIL.Write_Log ('G_PHASE: ' || G_PHASE);
119: FII_UTIL.Write_Log ('Error Message: '|| substr(sqlerrm,1,180));
120: RAISE;
121:
114: Exception
115:
116: When others then
117: FII_UTIL.Write_Log ('Unexpected error when calling Initialize...');
118: FII_UTIL.Write_Log ('G_PHASE: ' || G_PHASE);
119: FII_UTIL.Write_Log ('Error Message: '|| substr(sqlerrm,1,180));
120: RAISE;
121:
122: END Initialize;
115:
116: When others then
117: FII_UTIL.Write_Log ('Unexpected error when calling Initialize...');
118: FII_UTIL.Write_Log ('G_PHASE: ' || G_PHASE);
119: FII_UTIL.Write_Log ('Error Message: '|| substr(sqlerrm,1,180));
120: RAISE;
121:
122: END Initialize;
123:
234: token_num => 0);
235:
236: end if;
237:
238: FII_UTIL.Write_Output( rpad(' ', 4)
239: || rpad(Missing_Rates_Rec.PERIOD_ID, 14)
240: || rpad(Missing_Rates_Rec.CONVERSION_DATE, 20)
241: || rpad(Missing_Rates_Rec.FROM_CURRENCY, 18)
242: || rpad(Missing_Rates_Rec.TO_CURRENCY, 16)
261:
262: Exception
263:
264: When others then
265: FII_UTIL.Write_Log(
266: 'Unexpected error when calling Detect_Missing_Rates.');
267: FII_UTIL.Write_Log('G_PHASE: ' || G_PHASE);
268: FII_UTIL.Write_Log('Error Message: '|| substr(sqlerrm,1,180));
269: RAISE;
263:
264: When others then
265: FII_UTIL.Write_Log(
266: 'Unexpected error when calling Detect_Missing_Rates.');
267: FII_UTIL.Write_Log('G_PHASE: ' || G_PHASE);
268: FII_UTIL.Write_Log('Error Message: '|| substr(sqlerrm,1,180));
269: RAISE;
270:
271: END Detect_Missing_Rates;
264: When others then
265: FII_UTIL.Write_Log(
266: 'Unexpected error when calling Detect_Missing_Rates.');
267: FII_UTIL.Write_Log('G_PHASE: ' || G_PHASE);
268: FII_UTIL.Write_Log('Error Message: '|| substr(sqlerrm,1,180));
269: RAISE;
270:
271: END Detect_Missing_Rates;
272:
291: END IF;
292:
293: g_phase := 'Truncate table FII_CURR_CONV_RATES';
294:
295: FII_UTIL.truncate_table ('FII_CURR_CONV_RATES', g_schema_name, g_retcode);
296:
297: g_phase := 'Insert into FII_CURR_CONV_RATES';
298:
299: insert into FII_CURR_CONV_RATES (
346: ) cto
347: where prd.end_date >= g_global_start_date;
348:
349: IF (FIIDIM_Debug) THEN
350: FII_UTIL.Write_Log('Inserted ' || SQL%ROWCOUNT ||
351: ' rows into FII_CURR_CONV_RATES');
352: END IF;
353:
354: g_phase := 'Copy missing rates to FII_CURR_CONV_RATES_GT';
377: FROM FII_CURR_CONV_RATES
378: WHERE CONVERSION_RATE < 0;
379:
380: IF (FIIDIM_Debug) THEN
381: FII_UTIL.Write_Log('Inserted ' || SQL%ROWCOUNT ||
382: ' rows into FII_CURR_CONV_RATES_GT');
383: END IF;
384:
385: g_phase := 'Update FII_CURR_CONV_RATES';
396: where CONVERSION_RATE < 0
397: and least(PERIOD_START_DATE, g_current_start_date) > g_global_start_date;
398:
399: IF (FIIDIM_Debug) THEN
400: FII_UTIL.Write_Log('Updated ' || SQL%ROWCOUNT ||
401: ' rows in FII_CURR_CONV_RATES');
402: END IF;
403:
404: g_phase := 'Detect missing rates in FII_CURR_CONV_RATES';
423:
424: EXCEPTION
425:
426: WHEN EX_fatal_err THEN
427: FII_UTIL.Write_Log ('Init_Load -> phase: '|| g_phase);
428: FII_UTIL.Write_Log ('FII_CURR_CONV_MAINTAIN_PKG.Init_Load: '||
429: 'User defined error');
430: -- Rollback
431: FND_CONCURRENT.Af_Rollback;
424: EXCEPTION
425:
426: WHEN EX_fatal_err THEN
427: FII_UTIL.Write_Log ('Init_Load -> phase: '|| g_phase);
428: FII_UTIL.Write_Log ('FII_CURR_CONV_MAINTAIN_PKG.Init_Load: '||
429: 'User defined error');
430: -- Rollback
431: FND_CONCURRENT.Af_Rollback;
432: FII_MESSAGE.Func_Fail(func_name =>
435: ret_val := FND_CONCURRENT.Set_Completion_Status
436: (status => 'ERROR', message => substr(sqlerrm,1,180));
437:
438: WHEN OTHERS THEN
439: FII_UTIL.Write_Log ('Init_Load -> phase: '|| g_phase);
440: FII_UTIL.Write_Log (
441: 'Other error in FII_CURR_CONV_MAINTAIN_PKG.Init_Load: ' ||
442: substr(sqlerrm,1,180));
443:
436: (status => 'ERROR', message => substr(sqlerrm,1,180));
437:
438: WHEN OTHERS THEN
439: FII_UTIL.Write_Log ('Init_Load -> phase: '|| g_phase);
440: FII_UTIL.Write_Log (
441: 'Other error in FII_CURR_CONV_MAINTAIN_PKG.Init_Load: ' ||
442: substr(sqlerrm,1,180));
443:
444: -- Rollback