78: l_stmt VARCHAR2(100);
79: BEGIN
80: l_stmt := 'TRUNCATE table '||g_fii_schema||'.'||p_table_name;
81: if g_debug_flag = 'Y' then
82: FII_UTIL.put_line('g_fii_schema '||g_fii_schema);
83: FII_UTIL.put_line('');
84: FII_UTIL.put_line(l_stmt);
85: end if;
86: EXECUTE IMMEDIATE l_stmt;
79: BEGIN
80: l_stmt := 'TRUNCATE table '||g_fii_schema||'.'||p_table_name;
81: if g_debug_flag = 'Y' then
82: FII_UTIL.put_line('g_fii_schema '||g_fii_schema);
83: FII_UTIL.put_line('');
84: FII_UTIL.put_line(l_stmt);
85: end if;
86: EXECUTE IMMEDIATE l_stmt;
87:
80: l_stmt := 'TRUNCATE table '||g_fii_schema||'.'||p_table_name;
81: if g_debug_flag = 'Y' then
82: FII_UTIL.put_line('g_fii_schema '||g_fii_schema);
83: FII_UTIL.put_line('');
84: FII_UTIL.put_line(l_stmt);
85: end if;
86: EXECUTE IMMEDIATE l_stmt;
87:
88: EXCEPTION
100: l_stmt varchar2(400);
101: BEGIN
102: l_stmt:='DROP table '||g_fii_schema||'.'||p_table_name;
103: if g_debug_flag = 'Y' then
104: FII_UTIL.put_line('');
105: FII_UTIL.put_line(l_stmt);
106: end if;
107: EXECUTE IMMEDIATE l_stmt;
108:
101: BEGIN
102: l_stmt:='DROP table '||g_fii_schema||'.'||p_table_name;
103: if g_debug_flag = 'Y' then
104: FII_UTIL.put_line('');
105: FII_UTIL.put_line(l_stmt);
106: end if;
107: EXECUTE IMMEDIATE l_stmt;
108:
109: EXCEPTION
123: BEGIN
124: g_state := 'Inside the procedure CLEAN_UP';
125:
126: if g_debug_flag = 'Y' then
127: FII_UTIL.put_line('Calling procedure CLEAN_UP');
128: FII_UTIL.put_line('');
129:
130: FII_UTIL.put_line('Truncate table FII_AP_SUM_WORK_JOBS');
131: end if;
124: g_state := 'Inside the procedure CLEAN_UP';
125:
126: if g_debug_flag = 'Y' then
127: FII_UTIL.put_line('Calling procedure CLEAN_UP');
128: FII_UTIL.put_line('');
129:
130: FII_UTIL.put_line('Truncate table FII_AP_SUM_WORK_JOBS');
131: end if;
132: truncate_table('FII_AP_SUM_WORK_JOBS');
126: if g_debug_flag = 'Y' then
127: FII_UTIL.put_line('Calling procedure CLEAN_UP');
128: FII_UTIL.put_line('');
129:
130: FII_UTIL.put_line('Truncate table FII_AP_SUM_WORK_JOBS');
131: end if;
132: truncate_table('FII_AP_SUM_WORK_JOBS');
133:
134: IF (g_truncate_id = 'Y') THEN
132: truncate_table('FII_AP_SUM_WORK_JOBS');
133:
134: IF (g_truncate_id = 'Y') THEN
135: if g_debug_flag = 'Y' then
136: FII_UTIL.put_line('Truncate table FII_AP_INV_ID');
137: end if;
138: truncate_table('FII_AP_INV_ID');
139: END IF;
140:
139: END IF;
140:
141: IF (g_truncate_staging = 'Y') THEN
142: if g_debug_flag = 'Y' then
143: FII_UTIL.put_line('Truncate table FII_AP_INV_DIST_T');
144: end if;
145: truncate_table('FII_AP_INV_DIST_T');
146: END IF;
147:
147:
148: -- haritha
149: IF (g_truncate_rates = 'Y') THEN
150: if g_debug_flag = 'Y' then
151: FII_UTIL.put_line('Truncate table FII_AP_INV_RATES_TEMP');
152: end if;
153: truncate_table('FII_AP_INV_RATES_TEMP');
154: END IF;
155:
177:
178: BEGIN
179: g_state := 'Check if Source Ledger Group set up has changed';
180: if g_debug_flag = 'Y' then
181: FII_UTIL.put_line('');
182: FII_UTIL.put_line( 'Check if Source Ledger Group set up has changed');
183: end if;
184:
185: SELECT DECODE(item_value, 'Y', 'TRUE', 'FALSE')
178: BEGIN
179: g_state := 'Check if Source Ledger Group set up has changed';
180: if g_debug_flag = 'Y' then
181: FII_UTIL.put_line('');
182: FII_UTIL.put_line( 'Check if Source Ledger Group set up has changed');
183: end if;
184:
185: SELECT DECODE(item_value, 'Y', 'TRUE', 'FALSE')
186: INTO l_result
249: -- insert into the temp table.
250: --------------------------------------------------------------------------------
251: g_state := 'Inserting records into FII_AP_INV_ID table from AP log table';
252: IF g_debug_flag = 'Y' then
253: FII_UTIL.put_line('');
254: FII_UTIL.put_line(g_state);
255: fii_util.start_timer;
256: fii_util.put_line('');
257: END IF;
250: --------------------------------------------------------------------------------
251: g_state := 'Inserting records into FII_AP_INV_ID table from AP log table';
252: IF g_debug_flag = 'Y' then
253: FII_UTIL.put_line('');
254: FII_UTIL.put_line(g_state);
255: fii_util.start_timer;
256: fii_util.put_line('');
257: END IF;
258:
251: g_state := 'Inserting records into FII_AP_INV_ID table from AP log table';
252: IF g_debug_flag = 'Y' then
253: FII_UTIL.put_line('');
254: FII_UTIL.put_line(g_state);
255: fii_util.start_timer;
256: fii_util.put_line('');
257: END IF;
258:
259: INSERT INTO FII_AP_INV_ID (INVOICE_ID, SEQUENCE_ID)
252: IF g_debug_flag = 'Y' then
253: FII_UTIL.put_line('');
254: FII_UTIL.put_line(g_state);
255: fii_util.start_timer;
256: fii_util.put_line('');
257: END IF;
258:
259: INSERT INTO FII_AP_INV_ID (INVOICE_ID, SEQUENCE_ID)
260: SELECT
274:
275: l_count := SQL%ROWCOUNT;
276:
277: IF g_debug_flag = 'Y' then
278: FII_UTIL.stop_timer;
279: FII_UTIL.put_line('Inserted ' || SQL%ROWCOUNT||' records in FII_AP_INV_ID');
280: FII_UTIL.print_timer('Duration');
281: END IF;
282:
275: l_count := SQL%ROWCOUNT;
276:
277: IF g_debug_flag = 'Y' then
278: FII_UTIL.stop_timer;
279: FII_UTIL.put_line('Inserted ' || SQL%ROWCOUNT||' records in FII_AP_INV_ID');
280: FII_UTIL.print_timer('Duration');
281: END IF;
282:
283: RETURN l_count;
276:
277: IF g_debug_flag = 'Y' then
278: FII_UTIL.stop_timer;
279: FII_UTIL.put_line('Inserted ' || SQL%ROWCOUNT||' records in FII_AP_INV_ID');
280: FII_UTIL.print_timer('Duration');
281: END IF;
282:
283: RETURN l_count;
284: EXCEPTION
285: WHEN OTHERS THEN
286: g_errbuf:=sqlerrm;
287: g_retcode:= -1;
288: g_exception_msg := g_retcode || ':' || g_errbuf;
289: FII_UTIL.put_line('Error occured while ' || g_state);
290: FII_UTIL.put_line(g_exception_msg);
291: RAISE;
292: END POPULATE_INV_ID_TEMP;
293:
286: g_errbuf:=sqlerrm;
287: g_retcode:= -1;
288: g_exception_msg := g_retcode || ':' || g_errbuf;
289: FII_UTIL.put_line('Error occured while ' || g_state);
290: FII_UTIL.put_line(g_exception_msg);
291: RAISE;
292: END POPULATE_INV_ID_TEMP;
293:
294: -----------------------------------------------------------
299: l_stmt VARCHAR2(1000);
300: BEGIN
301: g_state := 'Populating FII_AP_INV_DIST_T from FII_AP_INV_ID table';
302: if g_debug_flag = 'Y' then
303: FII_UTIL.put_line(g_state);
304: FII_UTIL.start_timer;
305: end if;
306:
307: INSERT INTO FII_AP_INV_DIST_T
300: BEGIN
301: g_state := 'Populating FII_AP_INV_DIST_T from FII_AP_INV_ID table';
302: if g_debug_flag = 'Y' then
303: FII_UTIL.put_line(g_state);
304: FII_UTIL.start_timer;
305: end if;
306:
307: INSERT INTO FII_AP_INV_DIST_T
308: (ACCOUNT_DATE,
385: AND temp.sequence_id <= p_end_range
386: AND aid.accounting_date >= g_start_date;
387:
388: if g_debug_flag = 'Y' then
389: FII_UTIL.put_line('Inserted '||sql%rowcount||' rows INTO FII_AP_INV_DIST_T table');
390: FII_UTIL.stop_timer;
391: FII_UTIL.print_timer('Duration');
392: end if;
393:
386: AND aid.accounting_date >= g_start_date;
387:
388: if g_debug_flag = 'Y' then
389: FII_UTIL.put_line('Inserted '||sql%rowcount||' rows INTO FII_AP_INV_DIST_T table');
390: FII_UTIL.stop_timer;
391: FII_UTIL.print_timer('Duration');
392: end if;
393:
394: COMMIT;
387:
388: if g_debug_flag = 'Y' then
389: FII_UTIL.put_line('Inserted '||sql%rowcount||' rows INTO FII_AP_INV_DIST_T table');
390: FII_UTIL.stop_timer;
391: FII_UTIL.print_timer('Duration');
392: end if;
393:
394: COMMIT;
395:
403: WHEN OTHERS THEN
404: g_errbuf:=sqlerrm;
405: g_retcode:= -1;
406: g_exception_msg := g_retcode || ':' || g_errbuf;
407: FII_UTIL.put_line('Error occured while ' || g_state);
408: FII_UTIL.put_line(g_exception_msg);
409: RAISE;
410:
411: END POPULATE_AP_SUM_STG;
404: g_errbuf:=sqlerrm;
405: g_retcode:= -1;
406: g_exception_msg := g_retcode || ':' || g_errbuf;
407: FII_UTIL.put_line('Error occured while ' || g_state);
408: FII_UTIL.put_line(g_exception_msg);
409: RAISE;
410:
411: END POPULATE_AP_SUM_STG;
412:
422:
423: g_phase := 'Register jobs for workers';
424:
425: if g_debug_flag = 'Y' then
426: FII_UTIL.put_line('Register jobs for workers');
427: end if;
428:
429: SELECT max(sequence_id), min(sequence_id)
430: INTO l_max_number, l_start_number
453: l_start_number := least(l_end_number, l_max_number) + 1;
454: END LOOP;
455:
456: if g_debug_flag = 'Y' then
457: FII_UTIL.put_line('Inserted ' || l_count || ' jobs into FII_AP_SUM_WORK_JOBS table');
458: end if;
459:
460: EXCEPTION
461: WHEN OTHERS THEN
479: BEGIN
480:
481: g_state := 'Inside Launch Worker procedure for worker ' || p_worker_no;
482: if g_debug_flag = 'Y' then
483: FII_UTIL.put_line(g_state);
484: end if;
485:
486:
487: l_request_id := FND_REQUEST.SUBMIT_REQUEST(
509:
510: EXCEPTION
511: WHEN G_NO_CHILD_PROCESS THEN
512: g_retcode := -1;
513: FII_UTIL.put_line('No child process launched');
514: raise;
515: WHEN OTHERS THEN
516: rollback;
517: g_retcode := -2;
671: WHEN OTHERS THEN
672: g_errbuf:=sqlerrm;
673: g_retcode:= -1;
674: g_exception_msg := g_retcode || ':' || g_errbuf;
675: FII_UTIL.put_line('Error occured while ' || g_state);
676: FII_UTIL.put_line(g_exception_msg);
677: RAISE;
678: END VERIFY_MISSING_RATES;
679:
672: g_errbuf:=sqlerrm;
673: g_retcode:= -1;
674: g_exception_msg := g_retcode || ':' || g_errbuf;
675: FII_UTIL.put_line('Error occured while ' || g_state);
676: FII_UTIL.put_line(g_exception_msg);
677: RAISE;
678: END VERIFY_MISSING_RATES;
679:
680: -----------------------------------------------------------
688:
689: g_state := 'Populating FII_AP_INV_DIST_F FROM FII_AP_INV_DIST_T table';
690:
691: if g_debug_flag = 'Y' then
692: FII_UTIL.put_line('');
693: FII_UTIL.put_line('-------------------------------------------------');
694: FII_UTIL.put_line(g_state);
695: end if;
696:
689: g_state := 'Populating FII_AP_INV_DIST_F FROM FII_AP_INV_DIST_T table';
690:
691: if g_debug_flag = 'Y' then
692: FII_UTIL.put_line('');
693: FII_UTIL.put_line('-------------------------------------------------');
694: FII_UTIL.put_line(g_state);
695: end if;
696:
697:
690:
691: if g_debug_flag = 'Y' then
692: FII_UTIL.put_line('');
693: FII_UTIL.put_line('-------------------------------------------------');
694: FII_UTIL.put_line(g_state);
695: end if;
696:
697:
698: -- haritha.
797: stg.Purchasing_Category_ID,
798: stg.Item_Description);
799:
800: if g_debug_flag = 'Y' then
801: FII_UTIL.put_line('Merged ' || SQL%ROWCOUNT || ' records into FII_AP_INV_DIST_F');
802: FII_UTIL.put_line('');
803: end if;
804:
805: DELETE FROM FII_AP_INV_DIST_F bsum
798: stg.Item_Description);
799:
800: if g_debug_flag = 'Y' then
801: FII_UTIL.put_line('Merged ' || SQL%ROWCOUNT || ' records into FII_AP_INV_DIST_F');
802: FII_UTIL.put_line('');
803: end if;
804:
805: DELETE FROM FII_AP_INV_DIST_F bsum
806: WHERE (bsum.UPDATE_SEQUENCE <> seq_id OR bsum.posted_flag = 'Y')
806: WHERE (bsum.UPDATE_SEQUENCE <> seq_id OR bsum.posted_flag = 'Y')
807: AND bsum.invoice_id IN (SELECT id.invoice_id FROM FII_AP_INV_ID id);
808:
809: if g_debug_flag = 'Y' then
810: FII_UTIL.put_line('Deleted ' || SQL%ROWCOUNT || ' records from FII_AP_INV_DIST_F');
811: FII_UTIL.put_line('');
812: end if;
813:
814: FOR i IN 0..31 LOOP --i represents the partition of ap_dbi_log.
807: AND bsum.invoice_id IN (SELECT id.invoice_id FROM FII_AP_INV_ID id);
808:
809: if g_debug_flag = 'Y' then
810: FII_UTIL.put_line('Deleted ' || SQL%ROWCOUNT || ' records from FII_AP_INV_DIST_F');
811: FII_UTIL.put_line('');
812: end if;
813:
814: FOR i IN 0..31 LOOP --i represents the partition of ap_dbi_log.
815:
856: WHEN OTHERS THEN
857: g_errbuf:=sqlerrm;
858: g_retcode:= -1;
859: g_exception_msg := g_retcode || ':' || g_errbuf;
860: FII_UTIL.put_line('Error occured while ' || g_state);
861: FII_UTIL.put_line(g_exception_msg);
862: RAISE;
863:
864: END POPULATE_AP_BASE_SUM;
857: g_errbuf:=sqlerrm;
858: g_retcode:= -1;
859: g_exception_msg := g_retcode || ':' || g_errbuf;
860: FII_UTIL.put_line('Error occured while ' || g_state);
861: FII_UTIL.put_line(g_exception_msg);
862: RAISE;
863:
864: END POPULATE_AP_BASE_SUM;
865:
878: ------------------------------------------------------
879: -- Set default directory in case if the profile option
880: -- BIS_DEBUG_LOG_DIRECTORY is not set up
881: ------------------------------------------------------
882: l_dir:=FII_UTIL.get_utl_file_dir;
883:
884: ----------------------------------------------------------------
885: -- fii_util.initialize will get profile options FII_DEBUG_MODE
886: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
881: ------------------------------------------------------
882: l_dir:=FII_UTIL.get_utl_file_dir;
883:
884: ----------------------------------------------------------------
885: -- fii_util.initialize will get profile options FII_DEBUG_MODE
886: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
887: -- the log files and output files are written to
888: ----------------------------------------------------------------
889: FII_UTIL.initialize(p_object_name||'.log',p_object_name||'.out',l_dir,'FII_AP_INV_DISTRIBUTIONS_B_Worker');
885: -- fii_util.initialize will get profile options FII_DEBUG_MODE
886: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
887: -- the log files and output files are written to
888: ----------------------------------------------------------------
889: FII_UTIL.initialize(p_object_name||'.log',p_object_name||'.out',l_dir,'FII_AP_INV_DISTRIBUTIONS_B_Worker');
890:
891:
892: g_fii_user_id := FND_GLOBAL.User_Id;
893: g_fii_login_id := FND_GLOBAL.Login_Id;
914: -- --------------------------------------------------------
915: -- Find the schema owner (AP)
916: -- --------------------------------------------------------
917:
918: g_ap_schema := FII_UTIL.get_schema_name('SQLAP');
919: if g_debug_flag = 'Y' then
920: FII_UTIL.put_line('g_ap_schema is '||g_ap_schema);
921: end if;
922:
916: -- --------------------------------------------------------
917:
918: g_ap_schema := FII_UTIL.get_schema_name('SQLAP');
919: if g_debug_flag = 'Y' then
920: FII_UTIL.put_line('g_ap_schema is '||g_ap_schema);
921: end if;
922:
923: -- --------------------------------------------------------
924: -- Find the schema owner and tablespace
925: -- FII_AP_INV_B is using
926: -- --------------------------------------------------------
927: g_section := 'Section 20';
928: if g_debug_flag = 'Y' then
929: FII_UTIL.put_line('Section 20');
930: end if;
931:
932: IF(FND_INSTALLATION.GET_APP_INFO('FII', l_status, l_industry, g_fii_schema))
933: THEN NULL;
931:
932: IF(FND_INSTALLATION.GET_APP_INFO('FII', l_status, l_industry, g_fii_schema))
933: THEN NULL;
934: if g_debug_flag = 'Y' then
935: FII_UTIL.put_line('g_fii_schema is '||g_fii_schema);
936: end if;
937: END IF;
938:
939: g_section := 'Section 30';
937: END IF;
938:
939: g_section := 'Section 30';
940: if g_debug_flag = 'Y' then
941: FII_UTIL.put_line('Section 30');
942: end if;
943:
944: /* Commenting out as unncessary. Query affects performance.
945:
951: WHERE table_name = g_table_name
952: AND owner = g_fii_schema;
953:
954: if g_debug_flag = 'Y' then
955: FII_UTIL.put_line('g_tablespace is '||g_tablespace);
956: end if;
957: g_section := 'Section 35';
958: if g_debug_flag = 'Y' then
959: FII_UTIL.put_line('Section 35');
955: FII_UTIL.put_line('g_tablespace is '||g_tablespace);
956: end if;
957: g_section := 'Section 35';
958: if g_debug_flag = 'Y' then
959: FII_UTIL.put_line('Section 35');
960: end if;
961: */
962: -- --------------------------------------------------------
963: -- get minimum accountable unit of the warehouse currency
997: g_sec_rate_type_name := null;
998: end if;
999: exception
1000: when others then
1001: fii_util.write_log(
1002: 'Failed to convert rate_type to rate_type_name' );
1003: raise;
1004: end;
1005:
1007: RAISE G_LOGIN_INFO_NOT_AVABLE;
1008: END IF;
1009:
1010: if g_debug_flag = 'Y' then
1011: FII_UTIL.put_line('User ID: ' || g_fii_user_id || ' Login ID: ' || g_fii_login_id);
1012: end if;
1013:
1014: EXCEPTION
1015: WHEN G_LOGIN_INFO_NOT_AVABLE THEN
1048: l_message VARCHAR2(500) := NULL;
1049: BEGIN
1050: g_state := 'Calling Procedure: VERIFY_CCID_UP_TO_DATE';
1051: if g_debug_flag = 'Y' then
1052: FII_UTIL.put_line('Calling Procedure: VERIFY_CCID_UP_TO_DATE');
1053: FII_UTIL.put_line('');
1054: end if;
1055:
1056: g_phase := 'Verifying if CCID Dimension is up to date';
1049: BEGIN
1050: g_state := 'Calling Procedure: VERIFY_CCID_UP_TO_DATE';
1051: if g_debug_flag = 'Y' then
1052: FII_UTIL.put_line('Calling Procedure: VERIFY_CCID_UP_TO_DATE');
1053: FII_UTIL.put_line('');
1054: end if;
1055:
1056: g_phase := 'Verifying if CCID Dimension is up to date';
1057: if g_debug_flag = 'Y' then
1054: end if;
1055:
1056: g_phase := 'Verifying if CCID Dimension is up to date';
1057: if g_debug_flag = 'Y' then
1058: FII_UTIL.put_line(g_phase);
1059: end if;
1060:
1061: IF(FII_GL_CCID_C.NEW_CCID_IN_GL) THEN
1062: if g_debug_flag = 'Y' then
1059: end if;
1060:
1061: IF(FII_GL_CCID_C.NEW_CCID_IN_GL) THEN
1062: if g_debug_flag = 'Y' then
1063: FII_UTIL.put_line('CCID Dimension is not up to date, calling CCID Dimension update
1064: program');
1065: end if;
1066: g_phase := 'Calling CCID Dimension update program';
1067: l_request_id := FND_REQUEST.SUBMIT_REQUEST('FII',
1085: l_message);
1086:
1087: IF l_result THEN
1088: if g_debug_flag = 'Y' then
1089: FII_UTIL.put_line('CCID Dimension populated successfully');
1090: end if;
1091: ELSE
1092: FII_UTIL.put_line('CCID Dimension populated unsuccessfully');
1093: raise G_CCID_FAILED;
1088: if g_debug_flag = 'Y' then
1089: FII_UTIL.put_line('CCID Dimension populated successfully');
1090: end if;
1091: ELSE
1092: FII_UTIL.put_line('CCID Dimension populated unsuccessfully');
1093: raise G_CCID_FAILED;
1094: END IF;
1095:
1096: ELSE
1094: END IF;
1095:
1096: ELSE
1097: if g_debug_flag = 'Y' then
1098: FII_UTIL.put_line('CCID Dimension is up to date');
1099: FII_UTIL.put_line('');
1100: end if;
1101: END IF;
1102:
1095:
1096: ELSE
1097: if g_debug_flag = 'Y' then
1098: FII_UTIL.put_line('CCID Dimension is up to date');
1099: FII_UTIL.put_line('');
1100: end if;
1101: END IF;
1102:
1103: Exception
1143: execute immediate l_stmt;
1144:
1145: g_state := 'Loading data into staging table';
1146: if g_debug_flag = 'Y' then
1147: fii_util.put_line(' ');
1148: fii_util.put_line('Loading data into staging table');
1149: fii_util.start_timer;
1150: fii_util.put_line('');
1151: end if;
1144:
1145: g_state := 'Loading data into staging table';
1146: if g_debug_flag = 'Y' then
1147: fii_util.put_line(' ');
1148: fii_util.put_line('Loading data into staging table');
1149: fii_util.start_timer;
1150: fii_util.put_line('');
1151: end if;
1152:
1145: g_state := 'Loading data into staging table';
1146: if g_debug_flag = 'Y' then
1147: fii_util.put_line(' ');
1148: fii_util.put_line('Loading data into staging table');
1149: fii_util.start_timer;
1150: fii_util.put_line('');
1151: end if;
1152:
1153:
1146: if g_debug_flag = 'Y' then
1147: fii_util.put_line(' ');
1148: fii_util.put_line('Loading data into staging table');
1149: fii_util.start_timer;
1150: fii_util.put_line('');
1151: end if;
1152:
1153:
1154: INSERT /*+ APPEND PARALLEL(F) */ INTO FII_AP_INV_DIST_T F
1233: and aid.accounting_date >= g_start_date;
1234:
1235:
1236: if g_debug_flag = 'Y' then
1237: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1238: fii_util.stop_timer;
1239: fii_util.print_timer('Duration');
1240: end if;
1241:
1234:
1235:
1236: if g_debug_flag = 'Y' then
1237: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1238: fii_util.stop_timer;
1239: fii_util.print_timer('Duration');
1240: end if;
1241:
1242: commit;
1235:
1236: if g_debug_flag = 'Y' then
1237: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1238: fii_util.stop_timer;
1239: fii_util.print_timer('Duration');
1240: end if;
1241:
1242: commit;
1243:
1251:
1252: BEGIN
1253: g_state := 'Loading data into rates table';
1254: if g_debug_flag = 'Y' then
1255: fii_util.put_line(' ');
1256: fii_util.put_line('Loading data into rates table');
1257: fii_util.start_timer;
1258: fii_util.put_line('');
1259: end if;
1252: BEGIN
1253: g_state := 'Loading data into rates table';
1254: if g_debug_flag = 'Y' then
1255: fii_util.put_line(' ');
1256: fii_util.put_line('Loading data into rates table');
1257: fii_util.start_timer;
1258: fii_util.put_line('');
1259: end if;
1260:
1253: g_state := 'Loading data into rates table';
1254: if g_debug_flag = 'Y' then
1255: fii_util.put_line(' ');
1256: fii_util.put_line('Loading data into rates table');
1257: fii_util.start_timer;
1258: fii_util.put_line('');
1259: end if;
1260:
1261: --modified by ilavenil to handle future dated transaction. The change is usage of least(...,sysdate)
1254: if g_debug_flag = 'Y' then
1255: fii_util.put_line(' ');
1256: fii_util.put_line('Loading data into rates table');
1257: fii_util.start_timer;
1258: fii_util.put_line('');
1259: end if;
1260:
1261: --modified by ilavenil to handle future dated transaction. The change is usage of least(...,sysdate)
1262: insert into fii_ap_inv_rates_temp
1275: from FII_AP_INV_DIST_T
1276: );
1277:
1278: if g_debug_flag = 'Y' then
1279: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1280: fii_util.stop_timer;
1281: fii_util.print_timer('Duration');
1282: end if;
1283:
1276: );
1277:
1278: if g_debug_flag = 'Y' then
1279: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1280: fii_util.stop_timer;
1281: fii_util.print_timer('Duration');
1282: end if;
1283:
1284: END INSERT_RATES;
1277:
1278: if g_debug_flag = 'Y' then
1279: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1280: fii_util.stop_timer;
1281: fii_util.print_timer('Duration');
1282: end if;
1283:
1284: END INSERT_RATES;
1285:
1294:
1295: BEGIN
1296: g_state := 'Loading data into base summary table';
1297: if g_debug_flag = 'Y' then
1298: fii_util.put_line(' ');
1299: fii_util.put_line('Loading data into base summary table');
1300: fii_util.start_timer;
1301: fii_util.put_line('');
1302: end if;
1295: BEGIN
1296: g_state := 'Loading data into base summary table';
1297: if g_debug_flag = 'Y' then
1298: fii_util.put_line(' ');
1299: fii_util.put_line('Loading data into base summary table');
1300: fii_util.start_timer;
1301: fii_util.put_line('');
1302: end if;
1303:
1296: g_state := 'Loading data into base summary table';
1297: if g_debug_flag = 'Y' then
1298: fii_util.put_line(' ');
1299: fii_util.put_line('Loading data into base summary table');
1300: fii_util.start_timer;
1301: fii_util.put_line('');
1302: end if;
1303:
1304: SELECT FII_AP_INV_DIST_F_S.nextval INTO seq_id FROM dual;
1297: if g_debug_flag = 'Y' then
1298: fii_util.put_line(' ');
1299: fii_util.put_line('Loading data into base summary table');
1300: fii_util.start_timer;
1301: fii_util.put_line('');
1302: end if;
1303:
1304: SELECT FII_AP_INV_DIST_F_S.nextval INTO seq_id FROM dual;
1305:
1372: where stg.account_date = rates.trx_date
1373: and stg.inv_currency_code = rates.functional_currency;
1374:
1375: if g_debug_flag = 'Y' then
1376: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1377: fii_util.stop_timer;
1378: fii_util.print_timer('Duration');
1379: end if;
1380:
1373: and stg.inv_currency_code = rates.functional_currency;
1374:
1375: if g_debug_flag = 'Y' then
1376: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1377: fii_util.stop_timer;
1378: fii_util.print_timer('Duration');
1379: end if;
1380:
1381: commit;
1374:
1375: if g_debug_flag = 'Y' then
1376: fii_util.put_line('Processed '||SQL%ROWCOUNT||' rows');
1377: fii_util.stop_timer;
1378: fii_util.print_timer('Duration');
1379: end if;
1380:
1381: commit;
1382:
1491: -- Set default directory in case if the profile option
1492: -- BIS_DEBUG_LOG_DIRECTORY is not set up
1493: ------------------------------------------------------
1494:
1495: l_dir:=FII_UTIL.get_utl_file_dir;
1496:
1497: ----------------------------------------------------------------
1498: -- FII_UTIL.initialize will get profile options FII_DEBUG_MODE
1499: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
1494:
1495: l_dir:=FII_UTIL.get_utl_file_dir;
1496:
1497: ----------------------------------------------------------------
1498: -- FII_UTIL.initialize will get profile options FII_DEBUG_MODE
1499: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
1500: -- the log files and output files are written to
1501: ----------------------------------------------------------------
1502: IF g_program_type = 'L' THEN
1499: -- and BIS_DEBUG_LOG_DIRECTORY and set up the directory where
1500: -- the log files and output files are written to
1501: ----------------------------------------------------------------
1502: IF g_program_type = 'L' THEN
1503: FII_UTIL.initialize('FII_AP_INV_DISTRIBUTIONS_F.log','FII_AP_INV_DISTRIBUTIONS_F.out',l_dir,'FII_AP_INV_DISTRIBUTIONS_B_L');
1504: ELSE
1505: FII_UTIL.initialize('FII_AP_INV_DISTRIBUTIONS_F.log','FII_AP_INV_DISTRIBUTIONS_F.out',l_dir, 'FII_AP_INV_DISTRIBUTIONS_B_I');
1506: END IF;
1507:
1501: ----------------------------------------------------------------
1502: IF g_program_type = 'L' THEN
1503: FII_UTIL.initialize('FII_AP_INV_DISTRIBUTIONS_F.log','FII_AP_INV_DISTRIBUTIONS_F.out',l_dir,'FII_AP_INV_DISTRIBUTIONS_B_L');
1504: ELSE
1505: FII_UTIL.initialize('FII_AP_INV_DISTRIBUTIONS_F.log','FII_AP_INV_DISTRIBUTIONS_F.out',l_dir, 'FII_AP_INV_DISTRIBUTIONS_B_I');
1506: END IF;
1507:
1508: -------------------------------------------------------------
1509: -- Check if FII: DBI Payables Expenses Implementation profile
1528: l_global_param_list(1) := 'BIS_GLOBAL_START_DATE';
1529: l_global_param_list(2) := 'BIS_PRIMARY_CURRENCY_CODE';
1530: l_global_param_list(3) := 'BIS_PRIMARY_RATE_TYPE';
1531: IF (NOT bis_common_parameters.check_global_parameters(l_global_param_list)) THEN
1532: FII_UTIL.put_line(fnd_message.get_string('FII', 'FII_BAD_GLOBAL_PARA'));
1533: retcode := -1;
1534: return;
1535: END IF;
1536:
1538: -- ------------------------------------------
1539: -- Initalize other variables
1540: -- ------------------------------------------
1541: if g_debug_flag = 'Y' then
1542: FII_UTIL.put_line(' ');
1543: FII_UTIL.put_line('-------------------------------------------------');
1544: FII_UTIL.put_line('Initialization');
1545: end if;
1546: INIT;
1539: -- Initalize other variables
1540: -- ------------------------------------------
1541: if g_debug_flag = 'Y' then
1542: FII_UTIL.put_line(' ');
1543: FII_UTIL.put_line('-------------------------------------------------');
1544: FII_UTIL.put_line('Initialization');
1545: end if;
1546: INIT;
1547: if g_debug_flag = 'Y' then
1540: -- ------------------------------------------
1541: if g_debug_flag = 'Y' then
1542: FII_UTIL.put_line(' ');
1543: FII_UTIL.put_line('-------------------------------------------------');
1544: FII_UTIL.put_line('Initialization');
1545: end if;
1546: INIT;
1547: if g_debug_flag = 'Y' then
1548: FII_UTIL.put_line('-------------------------------------------------');
1544: FII_UTIL.put_line('Initialization');
1545: end if;
1546: INIT;
1547: if g_debug_flag = 'Y' then
1548: FII_UTIL.put_line('-------------------------------------------------');
1549: FII_UTIL.put_line(' ');
1550: end if;
1551:
1552: IF p_program_type = 'L' THEN
1545: end if;
1546: INIT;
1547: if g_debug_flag = 'Y' then
1548: FII_UTIL.put_line('-------------------------------------------------');
1549: FII_UTIL.put_line(' ');
1550: end if;
1551:
1552: IF p_program_type = 'L' THEN
1553: g_state := 'Running Initial Load, truncate staging and base summary table.';
1551:
1552: IF p_program_type = 'L' THEN
1553: g_state := 'Running Initial Load, truncate staging and base summary table.';
1554: IF g_debug_flag = 'Y' then
1555: FII_UTIL.put_line('Running Initial Load, truncate staging and base summary table.');
1556: END IF;
1557: TRUNCATE_TABLE('FII_AP_INV_DIST_T');
1558: TRUNCATE_TABLE('FII_AP_INV_DIST_F');
1559: COMMIT;
1586: ---------------------------------------------
1587: IF(CHECK_IF_SET_UP_CHANGE = 'TRUE') THEN
1588: FII_MESSAGE.write_output(msg_name => 'FII_TRUNC_SUMMARY', token_num => 0);
1589:
1590: FII_UTIL.put_line(fnd_message.get_string('FII', 'FII_TRUNC_SUMMARY'));
1591: retcode := -1;
1592: RETURN;
1593: END IF;
1594: ELSIF (p_program_type = 'L') THEN
1632: g_end_date := l_end_date;
1633:
1634: END IF;
1635: if g_debug_flag = 'Y' then
1636: FII_UTIL.put_line(' ');
1637: FII_UTIL.put_line('-------------------------------------------------');
1638: FII_UTIL.put_line('The date range of collection is from ' || to_char(g_start_date, 'MM/DD/YYYY HH24:MI:SS') || '.');
1639: FII_UTIL.put_line('-------------------------------------------------');
1640: FII_UTIL.put_line(' ');
1633:
1634: END IF;
1635: if g_debug_flag = 'Y' then
1636: FII_UTIL.put_line(' ');
1637: FII_UTIL.put_line('-------------------------------------------------');
1638: FII_UTIL.put_line('The date range of collection is from ' || to_char(g_start_date, 'MM/DD/YYYY HH24:MI:SS') || '.');
1639: FII_UTIL.put_line('-------------------------------------------------');
1640: FII_UTIL.put_line(' ');
1641: end if;
1634: END IF;
1635: if g_debug_flag = 'Y' then
1636: FII_UTIL.put_line(' ');
1637: FII_UTIL.put_line('-------------------------------------------------');
1638: FII_UTIL.put_line('The date range of collection is from ' || to_char(g_start_date, 'MM/DD/YYYY HH24:MI:SS') || '.');
1639: FII_UTIL.put_line('-------------------------------------------------');
1640: FII_UTIL.put_line(' ');
1641: end if;
1642:
1635: if g_debug_flag = 'Y' then
1636: FII_UTIL.put_line(' ');
1637: FII_UTIL.put_line('-------------------------------------------------');
1638: FII_UTIL.put_line('The date range of collection is from ' || to_char(g_start_date, 'MM/DD/YYYY HH24:MI:SS') || '.');
1639: FII_UTIL.put_line('-------------------------------------------------');
1640: FII_UTIL.put_line(' ');
1641: end if;
1642:
1643: --------------------------------------------------------------------
1636: FII_UTIL.put_line(' ');
1637: FII_UTIL.put_line('-------------------------------------------------');
1638: FII_UTIL.put_line('The date range of collection is from ' || to_char(g_start_date, 'MM/DD/YYYY HH24:MI:SS') || '.');
1639: FII_UTIL.put_line('-------------------------------------------------');
1640: FII_UTIL.put_line(' ');
1641: end if;
1642:
1643: --------------------------------------------------------------------
1644: -- Checking to see if there's any record in the staging table.
1714: --g_timestamp4 - last Payables Expenses load.
1715: -------------------------------------------------------------
1716: g_state := 'Defining timestamps to maintain ap_dbi_log.';
1717: IF g_debug_flag = 'Y' then
1718: FII_UTIL.put_line('');
1719: FII_UTIL.put_line(g_state);
1720: fii_util.put_line('');
1721: END IF;
1722:
1715: -------------------------------------------------------------
1716: g_state := 'Defining timestamps to maintain ap_dbi_log.';
1717: IF g_debug_flag = 'Y' then
1718: FII_UTIL.put_line('');
1719: FII_UTIL.put_line(g_state);
1720: fii_util.put_line('');
1721: END IF;
1722:
1723: g_timestamp1 := BIS_COLLECTION_UTILITIES.G_Start_Date;
1716: g_state := 'Defining timestamps to maintain ap_dbi_log.';
1717: IF g_debug_flag = 'Y' then
1718: FII_UTIL.put_line('');
1719: FII_UTIL.put_line(g_state);
1720: fii_util.put_line('');
1721: END IF;
1722:
1723: g_timestamp1 := BIS_COLLECTION_UTILITIES.G_Start_Date;
1724:
1758: g_old_act_part2 := MOD(TO_NUMBER(TO_CHAR(TRUNC(g_timestamp2+1), 'J')), 32);
1759:
1760: if g_debug_flag = 'Y' then
1761:
1762: FII_UTIL.put_line('Current Load Timestamp is: ' || to_char(g_timestamp1, 'YYYY/MM/DD HH24:MI:SS'));
1763: FII_UTIL.put_line('Previous Payables Load Timestamp is: ' || to_char(g_timestamp2, 'YYYY/MM/DD HH24:MI:SS'));
1764: FII_UTIL.put_line('Previous Payables Operations Load Timestamp is: ' || to_char(g_timestamp3, 'YYYY/MM/DD HH24:MI:SS'));
1765: FII_UTIL.put_line('Previous Payables Expenses Load Timestamp is: ' || to_char(g_timestamp4, 'YYYY/MM/DD HH24:MI:SS'));
1766: end if;
1759:
1760: if g_debug_flag = 'Y' then
1761:
1762: FII_UTIL.put_line('Current Load Timestamp is: ' || to_char(g_timestamp1, 'YYYY/MM/DD HH24:MI:SS'));
1763: FII_UTIL.put_line('Previous Payables Load Timestamp is: ' || to_char(g_timestamp2, 'YYYY/MM/DD HH24:MI:SS'));
1764: FII_UTIL.put_line('Previous Payables Operations Load Timestamp is: ' || to_char(g_timestamp3, 'YYYY/MM/DD HH24:MI:SS'));
1765: FII_UTIL.put_line('Previous Payables Expenses Load Timestamp is: ' || to_char(g_timestamp4, 'YYYY/MM/DD HH24:MI:SS'));
1766: end if;
1767:
1760: if g_debug_flag = 'Y' then
1761:
1762: FII_UTIL.put_line('Current Load Timestamp is: ' || to_char(g_timestamp1, 'YYYY/MM/DD HH24:MI:SS'));
1763: FII_UTIL.put_line('Previous Payables Load Timestamp is: ' || to_char(g_timestamp2, 'YYYY/MM/DD HH24:MI:SS'));
1764: FII_UTIL.put_line('Previous Payables Operations Load Timestamp is: ' || to_char(g_timestamp3, 'YYYY/MM/DD HH24:MI:SS'));
1765: FII_UTIL.put_line('Previous Payables Expenses Load Timestamp is: ' || to_char(g_timestamp4, 'YYYY/MM/DD HH24:MI:SS'));
1766: end if;
1767:
1768:
1761:
1762: FII_UTIL.put_line('Current Load Timestamp is: ' || to_char(g_timestamp1, 'YYYY/MM/DD HH24:MI:SS'));
1763: FII_UTIL.put_line('Previous Payables Load Timestamp is: ' || to_char(g_timestamp2, 'YYYY/MM/DD HH24:MI:SS'));
1764: FII_UTIL.put_line('Previous Payables Operations Load Timestamp is: ' || to_char(g_timestamp3, 'YYYY/MM/DD HH24:MI:SS'));
1765: FII_UTIL.put_line('Previous Payables Expenses Load Timestamp is: ' || to_char(g_timestamp4, 'YYYY/MM/DD HH24:MI:SS'));
1766: end if;
1767:
1768:
1769: -------------------------------------------------
1777: RAISE G_RUN_INIT;
1778: END IF;
1779:
1780: if g_debug_flag = 'Y' then
1781: FII_UTIL.put_line('Populating Invoice ID table');
1782: FII_UTIL.start_timer;
1783: end if;
1784: l_new_inv_id_count := POPULATE_INV_ID_TEMP;
1785: if g_debug_flag = 'Y' then
1778: END IF;
1779:
1780: if g_debug_flag = 'Y' then
1781: FII_UTIL.put_line('Populating Invoice ID table');
1782: FII_UTIL.start_timer;
1783: end if;
1784: l_new_inv_id_count := POPULATE_INV_ID_TEMP;
1785: if g_debug_flag = 'Y' then
1786: FII_UTIL.stop_timer;
1782: FII_UTIL.start_timer;
1783: end if;
1784: l_new_inv_id_count := POPULATE_INV_ID_TEMP;
1785: if g_debug_flag = 'Y' then
1786: FII_UTIL.stop_timer;
1787: FII_UTIL.print_timer('Duration');
1788: end if;
1789:
1790: --------------------------------------------------------
1783: end if;
1784: l_new_inv_id_count := POPULATE_INV_ID_TEMP;
1785: if g_debug_flag = 'Y' then
1786: FII_UTIL.stop_timer;
1787: FII_UTIL.print_timer('Duration');
1788: end if;
1789:
1790: --------------------------------------------------------
1791: -- POPULATE_INV_ID_TEMP will identify the new invoices
1796: --------------------------------------------------------
1797: IF (l_new_inv_id_count = 0) THEN
1798:
1799: if g_debug_flag = 'Y' then
1800: FII_UTIL.put_line('No Invoice to Process, exit.');
1801: end if;
1802:
1803: ----------------------------------------------------------------
1804: -- Calling BIS API to record the range we collect. Only do this
1828: -- CCID dimension.
1829: ----------------------------------------------------------------
1830: g_phase := 'Verifying if CCID Dimension is up to date';
1831: if g_debug_flag = 'Y' then
1832: FII_UTIL.put_line(g_phase);
1833: end if;
1834:
1835: VERIFY_CCID_UP_TO_DATE;
1836:
1854: --------------------------------------------
1855: -- Register jobs
1856: --------------------------------------------
1857: if g_debug_flag = 'Y' then
1858: FII_UTIL.put_line(' ');
1859: FII_UTIL.put_line('Populating Jobs Table');
1860: FII_UTIL.put_timestamp;
1861: end if;
1862: REGISTER_JOBS;
1855: -- Register jobs
1856: --------------------------------------------
1857: if g_debug_flag = 'Y' then
1858: FII_UTIL.put_line(' ');
1859: FII_UTIL.put_line('Populating Jobs Table');
1860: FII_UTIL.put_timestamp;
1861: end if;
1862: REGISTER_JOBS;
1863: COMMIT;
1856: --------------------------------------------
1857: if g_debug_flag = 'Y' then
1858: FII_UTIL.put_line(' ');
1859: FII_UTIL.put_line('Populating Jobs Table');
1860: FII_UTIL.put_timestamp;
1861: end if;
1862: REGISTER_JOBS;
1863: COMMIT;
1864: --------------------------------------------------------
1864: --------------------------------------------------------
1865: -- Launch worker
1866: --------------------------------------------------------
1867: if g_debug_flag = 'Y' then
1868: FII_UTIL.put_line('Launching Workers');
1869: end if;
1870: FOR i IN 1..p_no_worker
1871: LOOP /* p_no_worker is the parameter user submitted
1872: to specify how many workers they want to
1872: to specify how many workers they want to
1873: submit */
1874: l_worker(i) := LAUNCH_WORKER(i);
1875: if g_debug_flag = 'Y' then
1876: FII_UTIL.put_line(' Worker '||i||' request id: '||l_worker(i));
1877: end if;
1878: END LOOP;
1879:
1880: COMMIT;
1907: l_tot_cnt
1908: FROM FII_AP_SUM_WORK_JOBS;
1909:
1910: if g_debug_flag = 'Y' then
1911: FII_UTIL.put_line('Job status - Unassigned:'||l_unassigned_cnt||
1912: ' In Process:'||l_wip_cnt||
1913: ' Completed:'||l_completed_cnt||
1914: ' Failed:'||l_failed_cnt);
1915: end if;
1927: -- have completed. Then we can exit the loop
1928: ----------------------------------------------
1929: IF (l_tot_cnt = l_completed_cnt) THEN
1930: if g_debug_flag = 'Y' then
1931: FII_UTIL.put_line('Job status - Total: '|| l_tot_cnt);
1932: end if;
1933: EXIT;
1934: END IF;
1935:
1970:
1971: END LOOP;
1972:
1973: if g_debug_flag = 'Y' then
1974: FII_UTIL.stop_timer;
1975: FII_UTIL.print_timer('Duration');
1976: end if;
1977: END;
1978:
1971: END LOOP;
1972:
1973: if g_debug_flag = 'Y' then
1974: FII_UTIL.stop_timer;
1975: FII_UTIL.print_timer('Duration');
1976: end if;
1977: END;
1978:
1979: END IF;
1992: g_truncate_staging := 'N';
1993:
1994: g_state := 'Updating records with missing primary rates in FII_AP_INV_DIST_T table';
1995: if g_debug_flag = 'Y' then
1996: FII_UTIL.put_line('');
1997: FII_UTIL.put_line('---------------------------------------------------------------------');
1998: FII_UTIL.put_line(g_state);
1999: FII_UTIL.start_timer;
2000: end if;
1993:
1994: g_state := 'Updating records with missing primary rates in FII_AP_INV_DIST_T table';
1995: if g_debug_flag = 'Y' then
1996: FII_UTIL.put_line('');
1997: FII_UTIL.put_line('---------------------------------------------------------------------');
1998: FII_UTIL.put_line(g_state);
1999: FII_UTIL.start_timer;
2000: end if;
2001:
1994: g_state := 'Updating records with missing primary rates in FII_AP_INV_DIST_T table';
1995: if g_debug_flag = 'Y' then
1996: FII_UTIL.put_line('');
1997: FII_UTIL.put_line('---------------------------------------------------------------------');
1998: FII_UTIL.put_line(g_state);
1999: FII_UTIL.start_timer;
2000: end if;
2001:
2002: --modified by ilavenil to handle future dated transaction. The change is usage of least(...,sysdate)
1995: if g_debug_flag = 'Y' then
1996: FII_UTIL.put_line('');
1997: FII_UTIL.put_line('---------------------------------------------------------------------');
1998: FII_UTIL.put_line(g_state);
1999: FII_UTIL.start_timer;
2000: end if;
2001:
2002: --modified by ilavenil to handle future dated transaction. The change is usage of least(...,sysdate)
2003: UPDATE FII_AP_INV_DIST_T stg
2007: WHERE stg.PRIM_CONVERSION_RATE < 0;
2008:
2009: l_rowcount := SQL%ROWCOUNT;
2010: if g_debug_flag = 'Y' then
2011: FII_UTIL.put_line('');
2012: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for primary conversion rate');
2013: FII_UTIL.stop_timer;
2014: FII_UTIL.print_timer('Duration');
2015:
2008:
2009: l_rowcount := SQL%ROWCOUNT;
2010: if g_debug_flag = 'Y' then
2011: FII_UTIL.put_line('');
2012: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for primary conversion rate');
2013: FII_UTIL.stop_timer;
2014: FII_UTIL.print_timer('Duration');
2015:
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2009: l_rowcount := SQL%ROWCOUNT;
2010: if g_debug_flag = 'Y' then
2011: FII_UTIL.put_line('');
2012: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for primary conversion rate');
2013: FII_UTIL.stop_timer;
2014: FII_UTIL.print_timer('Duration');
2015:
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2017: FII_UTIL.put_line('');
2010: if g_debug_flag = 'Y' then
2011: FII_UTIL.put_line('');
2012: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for primary conversion rate');
2013: FII_UTIL.stop_timer;
2014: FII_UTIL.print_timer('Duration');
2015:
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2017: FII_UTIL.put_line('');
2018: FII_UTIL.put_line('---------------------------------------------------------------------');
2013: FII_UTIL.stop_timer;
2014: FII_UTIL.print_timer('Duration');
2015:
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2017: FII_UTIL.put_line('');
2018: FII_UTIL.put_line('---------------------------------------------------------------------');
2019: FII_UTIL.put_line(g_state);
2020: FII_UTIL.start_timer;
2021: end if;
2014: FII_UTIL.print_timer('Duration');
2015:
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2017: FII_UTIL.put_line('');
2018: FII_UTIL.put_line('---------------------------------------------------------------------');
2019: FII_UTIL.put_line(g_state);
2020: FII_UTIL.start_timer;
2021: end if;
2022:
2015:
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2017: FII_UTIL.put_line('');
2018: FII_UTIL.put_line('---------------------------------------------------------------------');
2019: FII_UTIL.put_line(g_state);
2020: FII_UTIL.start_timer;
2021: end if;
2022:
2023: --modified by ilavenil to handle future dated transaction. The change is usage of least(...,sysdate)
2016: g_state := 'Updating records with missing secondary rates in FII_AP_INV_DIST_T table';
2017: FII_UTIL.put_line('');
2018: FII_UTIL.put_line('---------------------------------------------------------------------');
2019: FII_UTIL.put_line(g_state);
2020: FII_UTIL.start_timer;
2021: end if;
2022:
2023: --modified by ilavenil to handle future dated transaction. The change is usage of least(...,sysdate)
2024: UPDATE FII_AP_INV_DIST_T stg
2028: WHERE stg.SEC_CONVERSION_RATE < 0;
2029:
2030: l_rowcount := SQL%ROWCOUNT;
2031: if g_debug_flag = 'Y' then
2032: FII_UTIL.put_line('');
2033: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for secondary conversion rate');
2034: FII_UTIL.stop_timer;
2035: FII_UTIL.print_timer('Duration');
2036: end if;
2029:
2030: l_rowcount := SQL%ROWCOUNT;
2031: if g_debug_flag = 'Y' then
2032: FII_UTIL.put_line('');
2033: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for secondary conversion rate');
2034: FII_UTIL.stop_timer;
2035: FII_UTIL.print_timer('Duration');
2036: end if;
2037:
2030: l_rowcount := SQL%ROWCOUNT;
2031: if g_debug_flag = 'Y' then
2032: FII_UTIL.put_line('');
2033: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for secondary conversion rate');
2034: FII_UTIL.stop_timer;
2035: FII_UTIL.print_timer('Duration');
2036: end if;
2037:
2038: COMMIT;
2031: if g_debug_flag = 'Y' then
2032: FII_UTIL.put_line('');
2033: FII_UTIL.put_line('Updated ' || l_rowcount || ' records for secondary conversion rate');
2034: FII_UTIL.stop_timer;
2035: FII_UTIL.print_timer('Duration');
2036: end if;
2037:
2038: COMMIT;
2039:
2072: -- records from the staging table into the summary table
2073: -----------------------------------------------------------------------
2074: ELSE
2075: if g_debug_flag = 'Y' then
2076: FII_UTIL.start_timer;
2077: end if;
2078:
2079: IF p_program_type = 'L' THEN
2080: ------------------------------------------------------------
2088: POPULATE_AP_BASE_SUM;
2089: END IF;
2090:
2091: if g_debug_flag = 'Y' then
2092: FII_UTIL.stop_timer;
2093: end if;
2094:
2095: -------------------------------------------------------------------
2096: -- After we have merged the records from the staging table into the
2115:
2116: END IF; /* IF (VERIFY_MISSING_RATES = -1) */
2117:
2118: if g_debug_flag = 'Y' then
2119: FII_UTIL.put_line('return code is ' || retcode);
2120: end if;
2121: Retcode := g_retcode;
2122:
2123:
2124: EXCEPTION
2125: WHEN G_IMP_NOT_SET THEN
2126: retcode:=g_retcode;
2127: g_exception_msg := g_retcode || ':' || g_errbuf;
2128: FII_UTIL.put_line('Error occured while ' || g_state);
2129: FII_UTIL.put_line(g_exception_msg);
2130:
2131: WHEN G_MISSING_RATES THEN
2132: retcode := g_retcode;
2125: WHEN G_IMP_NOT_SET THEN
2126: retcode:=g_retcode;
2127: g_exception_msg := g_retcode || ':' || g_errbuf;
2128: FII_UTIL.put_line('Error occured while ' || g_state);
2129: FII_UTIL.put_line(g_exception_msg);
2130:
2131: WHEN G_MISSING_RATES THEN
2132: retcode := g_retcode;
2133: g_exception_msg := g_retcode || ':' || g_errbuf;
2130:
2131: WHEN G_MISSING_RATES THEN
2132: retcode := g_retcode;
2133: g_exception_msg := g_retcode || ':' || g_errbuf;
2134: FII_UTIL.put_line('Error occured while ' || g_state);
2135: FII_UTIL.put_line(g_exception_msg);
2136:
2137: WHEN OTHERS THEN
2138: g_errbuf:=g_errbuf;
2131: WHEN G_MISSING_RATES THEN
2132: retcode := g_retcode;
2133: g_exception_msg := g_retcode || ':' || g_errbuf;
2134: FII_UTIL.put_line('Error occured while ' || g_state);
2135: FII_UTIL.put_line(g_exception_msg);
2136:
2137: WHEN OTHERS THEN
2138: g_errbuf:=g_errbuf;
2139: g_retcode:= -1;
2138: g_errbuf:=g_errbuf;
2139: g_retcode:= -1;
2140: retcode:=g_retcode;
2141: g_exception_msg := g_retcode || ':' || g_errbuf;
2142: FII_UTIL.put_line('Error occured while ' || g_state);
2143: FII_UTIL.put_line(g_exception_msg);
2144:
2145: ---------------------------------------------------------------
2146: -- Truncating the staging table so the next time the program
2139: g_retcode:= -1;
2140: retcode:=g_retcode;
2141: g_exception_msg := g_retcode || ':' || g_errbuf;
2142: FII_UTIL.put_line('Error occured while ' || g_state);
2143: FII_UTIL.put_line(g_exception_msg);
2144:
2145: ---------------------------------------------------------------
2146: -- Truncating the staging table so the next time the program
2147: -- is ran, the program will start from beginning. If we leave
2198: g_start_date := nvl(l_last_period_from, bis_common_parameters.get_global_start_date);
2199:
2200:
2201: if g_debug_flag = 'Y' then
2202: FII_UTIL.put_line(' ');
2203: FII_UTIL.put_timestamp;
2204: FII_UTIL.put_line('Worker '||p_worker_no||' Starting');
2205: end if;
2206:
2199:
2200:
2201: if g_debug_flag = 'Y' then
2202: FII_UTIL.put_line(' ');
2203: FII_UTIL.put_timestamp;
2204: FII_UTIL.put_line('Worker '||p_worker_no||' Starting');
2205: end if;
2206:
2207: -- ------------------------------------------
2200:
2201: if g_debug_flag = 'Y' then
2202: FII_UTIL.put_line(' ');
2203: FII_UTIL.put_timestamp;
2204: FII_UTIL.put_line('Worker '||p_worker_no||' Starting');
2205: end if;
2206:
2207: -- ------------------------------------------
2208: -- Initalization
2208: -- Initalization
2209: -- ------------------------------------------
2210:
2211: if g_debug_flag = 'Y' then
2212: FII_UTIL.put_line(' ');
2213: FII_UTIL.put_line('Initialization');
2214: end if;
2215: INIT;
2216:
2209: -- ------------------------------------------
2210:
2211: if g_debug_flag = 'Y' then
2212: FII_UTIL.put_line(' ');
2213: FII_UTIL.put_line('Initialization');
2214: end if;
2215: INIT;
2216:
2217: --g_worker_num := p_worker_no;
2235: FROM FII_AP_SUM_WORK_JOBS;
2236:
2237: IF (l_failed_cnt > 0) THEN
2238: if g_debug_flag = 'Y' then
2239: FII_UTIL.put_line('');
2240: FII_UTIL.put_line('Another worker have errored out. Stop processing.');
2241: end if;
2242: EXIT;
2243: ELSIF (l_unassigned_cnt = 0) THEN
2236:
2237: IF (l_failed_cnt > 0) THEN
2238: if g_debug_flag = 'Y' then
2239: FII_UTIL.put_line('');
2240: FII_UTIL.put_line('Another worker have errored out. Stop processing.');
2241: end if;
2242: EXIT;
2243: ELSIF (l_unassigned_cnt = 0) THEN
2244: if g_debug_flag = 'Y' then
2241: end if;
2242: EXIT;
2243: ELSIF (l_unassigned_cnt = 0) THEN
2244: if g_debug_flag = 'Y' then
2245: FII_UTIL.put_line('');
2246: FII_UTIL.put_line('No more jobs left. Terminating.');
2247: end if;
2248: EXIT;
2249: ELSIF (l_curr_comp_cnt = l_curr_tot_cnt) THEN
2242: EXIT;
2243: ELSIF (l_unassigned_cnt = 0) THEN
2244: if g_debug_flag = 'Y' then
2245: FII_UTIL.put_line('');
2246: FII_UTIL.put_line('No more jobs left. Terminating.');
2247: end if;
2248: EXIT;
2249: ELSIF (l_curr_comp_cnt = l_curr_tot_cnt) THEN
2250: if g_debug_flag = 'Y' then
2247: end if;
2248: EXIT;
2249: ELSIF (l_curr_comp_cnt = l_curr_tot_cnt) THEN
2250: if g_debug_flag = 'Y' then
2251: FII_UTIL.put_line('');
2252: FII_UTIL.put_line('All jobs completed, no more job. Terminating');
2253: end if;
2254: EXIT;
2255: ELSIF (l_curr_unasgn_cnt > 0) THEN
2248: EXIT;
2249: ELSIF (l_curr_comp_cnt = l_curr_tot_cnt) THEN
2250: if g_debug_flag = 'Y' then
2251: FII_UTIL.put_line('');
2252: FII_UTIL.put_line('All jobs completed, no more job. Terminating');
2253: end if;
2254: EXIT;
2255: ELSIF (l_curr_unasgn_cnt > 0) THEN
2256: UPDATE FII_AP_SUM_WORK_JOBS
2283: ---------------------------------------------------------
2284: --Do summarization using the start_range and end_range
2285: ---------------------------------------------------------
2286: if g_debug_flag = 'Y' then
2287: FII_UTIL.start_timer;
2288: end if;
2289: POPULATE_AP_SUM_STG (l_start_range, l_end_range);
2290: if g_debug_flag = 'Y' then
2291: FII_UTIL.stop_timer;
2287: FII_UTIL.start_timer;
2288: end if;
2289: POPULATE_AP_SUM_STG (l_start_range, l_end_range);
2290: if g_debug_flag = 'Y' then
2291: FII_UTIL.stop_timer;
2292: FII_UTIL.print_timer('Duration');
2293: end if;
2294:
2295: UPDATE FII_AP_SUM_WORK_JOBS jobs
2288: end if;
2289: POPULATE_AP_SUM_STG (l_start_range, l_end_range);
2290: if g_debug_flag = 'Y' then
2291: FII_UTIL.stop_timer;
2292: FII_UTIL.print_timer('Duration');
2293: end if;
2294:
2295: UPDATE FII_AP_SUM_WORK_JOBS jobs
2296: SET jobs.status = 'COMPLETED'
2320: Errbuf := '
2321: ---------------------------------
2322: Error in Procedure: WORKER
2323: Message: '||sqlerrm;
2324: FII_UTIL.put_line(Errbuf);
2325:
2326: -------------------------------------------
2327: -- Update the WORKER_JOBS table to indicate
2328: -- this job has failed