53: WHERE SEQ_ID is NULL));
54:
55: BEGIN
56: /* Print Header */
57: edw_log.put_line(' ');
58: edw_log.put_line ('Identified Missing Rows Date:'||SYSDATE);
59:
60: edw_log.put_line (' ');
61: edw_log.put_line (' ');
54:
55: BEGIN
56: /* Print Header */
57: edw_log.put_line(' ');
58: edw_log.put_line ('Identified Missing Rows Date:'||SYSDATE);
59:
60: edw_log.put_line (' ');
61: edw_log.put_line (' ');
62:
56: /* Print Header */
57: edw_log.put_line(' ');
58: edw_log.put_line ('Identified Missing Rows Date:'||SYSDATE);
59:
60: edw_log.put_line (' ');
61: edw_log.put_line (' ');
62:
63: edw_log.put_line ('Primary Key is PM_BTCH_HDR.Plant_code - PM_BTCH_HDR.Batch_id - PM_MATL_DTL.Item_id - instance_code - OPM');
64: edw_log.put_line ('-----------------------------------------');
57: edw_log.put_line(' ');
58: edw_log.put_line ('Identified Missing Rows Date:'||SYSDATE);
59:
60: edw_log.put_line (' ');
61: edw_log.put_line (' ');
62:
63: edw_log.put_line ('Primary Key is PM_BTCH_HDR.Plant_code - PM_BTCH_HDR.Batch_id - PM_MATL_DTL.Item_id - instance_code - OPM');
64: edw_log.put_line ('-----------------------------------------');
65: edw_log.put_line ('Primary Key / Currency / Transaction Date');
59:
60: edw_log.put_line (' ');
61: edw_log.put_line (' ');
62:
63: edw_log.put_line ('Primary Key is PM_BTCH_HDR.Plant_code - PM_BTCH_HDR.Batch_id - PM_MATL_DTL.Item_id - instance_code - OPM');
64: edw_log.put_line ('-----------------------------------------');
65: edw_log.put_line ('Primary Key / Currency / Transaction Date');
66: edw_log.put_line ('-----------------------------------------');
67: /* Print Rows */
60: edw_log.put_line (' ');
61: edw_log.put_line (' ');
62:
63: edw_log.put_line ('Primary Key is PM_BTCH_HDR.Plant_code - PM_BTCH_HDR.Batch_id - PM_MATL_DTL.Item_id - instance_code - OPM');
64: edw_log.put_line ('-----------------------------------------');
65: edw_log.put_line ('Primary Key / Currency / Transaction Date');
66: edw_log.put_line ('-----------------------------------------');
67: /* Print Rows */
68:
61: edw_log.put_line (' ');
62:
63: edw_log.put_line ('Primary Key is PM_BTCH_HDR.Plant_code - PM_BTCH_HDR.Batch_id - PM_MATL_DTL.Item_id - instance_code - OPM');
64: edw_log.put_line ('-----------------------------------------');
65: edw_log.put_line ('Primary Key / Currency / Transaction Date');
66: edw_log.put_line ('-----------------------------------------');
67: /* Print Rows */
68:
69: For l_rows in missing_rate loop
62:
63: edw_log.put_line ('Primary Key is PM_BTCH_HDR.Plant_code - PM_BTCH_HDR.Batch_id - PM_MATL_DTL.Item_id - instance_code - OPM');
64: edw_log.put_line ('-----------------------------------------');
65: edw_log.put_line ('Primary Key / Currency / Transaction Date');
66: edw_log.put_line ('-----------------------------------------');
67: /* Print Rows */
68:
69: For l_rows in missing_rate loop
70: edw_log.put_line (l_rows.JOB_DETAIL_PK||' / '||l_rows.SOB_CURRENCY_FK||' / '||l_rows.TRX_DATE_FK);
66: edw_log.put_line ('-----------------------------------------');
67: /* Print Rows */
68:
69: For l_rows in missing_rate loop
70: edw_log.put_line (l_rows.JOB_DETAIL_PK||' / '||l_rows.SOB_CURRENCY_FK||' / '||l_rows.TRX_DATE_FK);
71: end loop;
72: edw_log.put_line(' ');
73: edw_log.put_line(' ');
74: EXCEPTION
68:
69: For l_rows in missing_rate loop
70: edw_log.put_line (l_rows.JOB_DETAIL_PK||' / '||l_rows.SOB_CURRENCY_FK||' / '||l_rows.TRX_DATE_FK);
71: end loop;
72: edw_log.put_line(' ');
73: edw_log.put_line(' ');
74: EXCEPTION
75: WHEN OTHERS THEN
76: g_errbuf:=sqlerrm;
69: For l_rows in missing_rate loop
70: edw_log.put_line (l_rows.JOB_DETAIL_PK||' / '||l_rows.SOB_CURRENCY_FK||' / '||l_rows.TRX_DATE_FK);
71: end loop;
72: edw_log.put_line(' ');
73: edw_log.put_line(' ');
74: EXCEPTION
75: WHEN OTHERS THEN
76: g_errbuf:=sqlerrm;
77: g_retcode:=sqlcode;
74: EXCEPTION
75: WHEN OTHERS THEN
76: g_errbuf:=sqlerrm;
77: g_retcode:=sqlcode;
78: edw_log.put_line('Raised Exception from PRINT_MISSING_RATE '||sqlerrm);
79: END;
80:
81: /* Procedure to Push missing rows */
82: PROCEDURE PUSH_MISSING_ROWS
84: l_count number;
85: BEGIN
86: /* Delete the incremental table before inserting new data */
87: DELETE OPI_EDW_OPM_JOB_DETAIL_INC;
88: edw_log.put_line(' ');
89: edw_log.Put_line('Identifying Missing Rate Rows ');
90: edw_log.put_line(' ');
91: SELECT count(*) into l_count from OPI_EDW_JOB_DETAIL_FSTG where
92: COLLECTION_STATUS in ('RATE NOT AVAILABLE','INVALID CURRENCY')
85: BEGIN
86: /* Delete the incremental table before inserting new data */
87: DELETE OPI_EDW_OPM_JOB_DETAIL_INC;
88: edw_log.put_line(' ');
89: edw_log.Put_line('Identifying Missing Rate Rows ');
90: edw_log.put_line(' ');
91: SELECT count(*) into l_count from OPI_EDW_JOB_DETAIL_FSTG where
92: COLLECTION_STATUS in ('RATE NOT AVAILABLE','INVALID CURRENCY')
93: AND JOB_DETAIL_PK like '%OPM';
86: /* Delete the incremental table before inserting new data */
87: DELETE OPI_EDW_OPM_JOB_DETAIL_INC;
88: edw_log.put_line(' ');
89: edw_log.Put_line('Identifying Missing Rate Rows ');
90: edw_log.put_line(' ');
91: SELECT count(*) into l_count from OPI_EDW_JOB_DETAIL_FSTG where
92: COLLECTION_STATUS in ('RATE NOT AVAILABLE','INVALID CURRENCY')
93: AND JOB_DETAIL_PK like '%OPM';
94: IF l_count > 0 THEN
110: instrB(JOB_DETAIL_PK,'-',1,2)-1-instrB(JOB_DETAIL_PK,'-',1,1))
111: FROM OPI_EDW_JOB_DETAIL_FSTG
112: WHERE COLLECTION_STATUS in ('RATE NOT AVAILABLE','INVALID CURRENCY')
113: AND JOB_DETAIL_PK like '%OPM');
114: edw_log.Put_line(to_char(sql%rowcount) ||' rows missing Currency Rate Conversion');
115: edw_log.put_line(' ');
116: Commit;
117: edw_log.put_line ('Printing Missing Rate Rows Output');
118: edw_log.put_line(' ');
111: FROM OPI_EDW_JOB_DETAIL_FSTG
112: WHERE COLLECTION_STATUS in ('RATE NOT AVAILABLE','INVALID CURRENCY')
113: AND JOB_DETAIL_PK like '%OPM');
114: edw_log.Put_line(to_char(sql%rowcount) ||' rows missing Currency Rate Conversion');
115: edw_log.put_line(' ');
116: Commit;
117: edw_log.put_line ('Printing Missing Rate Rows Output');
118: edw_log.put_line(' ');
119: PRINT_MISSING_ROWS;
113: AND JOB_DETAIL_PK like '%OPM');
114: edw_log.Put_line(to_char(sql%rowcount) ||' rows missing Currency Rate Conversion');
115: edw_log.put_line(' ');
116: Commit;
117: edw_log.put_line ('Printing Missing Rate Rows Output');
118: edw_log.put_line(' ');
119: PRINT_MISSING_ROWS;
120: edw_log.put_line ('Output Printed. You can view the output using ''View output'' option from Request page');
121: edw_log.put_line(' ');
114: edw_log.Put_line(to_char(sql%rowcount) ||' rows missing Currency Rate Conversion');
115: edw_log.put_line(' ');
116: Commit;
117: edw_log.put_line ('Printing Missing Rate Rows Output');
118: edw_log.put_line(' ');
119: PRINT_MISSING_ROWS;
120: edw_log.put_line ('Output Printed. You can view the output using ''View output'' option from Request page');
121: edw_log.put_line(' ');
122:
116: Commit;
117: edw_log.put_line ('Printing Missing Rate Rows Output');
118: edw_log.put_line(' ');
119: PRINT_MISSING_ROWS;
120: edw_log.put_line ('Output Printed. You can view the output using ''View output'' option from Request page');
121: edw_log.put_line(' ');
122:
123: /*Delete all missing rows from FSTG table if source and target are on same instance*/
124: IF (LOCAL_SAME_AS_REMOTE) THEN
117: edw_log.put_line ('Printing Missing Rate Rows Output');
118: edw_log.put_line(' ');
119: PRINT_MISSING_ROWS;
120: edw_log.put_line ('Output Printed. You can view the output using ''View output'' option from Request page');
121: edw_log.put_line(' ');
122:
123: /*Delete all missing rows from FSTG table if source and target are on same instance*/
124: IF (LOCAL_SAME_AS_REMOTE) THEN
125: DELETE OPI_EDW_JOB_DETAIL_FSTG
124: IF (LOCAL_SAME_AS_REMOTE) THEN
125: DELETE OPI_EDW_JOB_DETAIL_FSTG
126: WHERE COLLECTION_STATUS in ('RATE NOT AVAILABLE','INVALID CURRENCY')
127: AND JOB_DETAIL_PK like '%OPM';
128: edw_log.Put_line(to_char(sql%rowcount) ||' missing Currency Rate Conversion rows deleted from Staging table');
129: END IF;
130: /* Deletion completed */
131: ELSE
132: edw_log.Put_line('0 rows missing Currency Rate Conversion');
128: edw_log.Put_line(to_char(sql%rowcount) ||' missing Currency Rate Conversion rows deleted from Staging table');
129: END IF;
130: /* Deletion completed */
131: ELSE
132: edw_log.Put_line('0 rows missing Currency Rate Conversion');
133: END IF;
134: EXCEPTION
135: WHEN OTHERS THEN
136: g_errbuf:=sqlerrm;
134: EXCEPTION
135: WHEN OTHERS THEN
136: g_errbuf:=sqlerrm;
137: g_retcode:=sqlcode;
138: edw_log.put_line('Raised Exception from PUSH_MISSING_ROWS '||sqlerrm);
139: END;
140:
141: -----------------------------------------------------------
142: --PROCEDURE PUSH_TO_LOCAL
340: WHERE view_id = p_view_id
341: AND seq_id = p_seq_id;
342: commit;
343: l_no_rows := sql%rowcount;
344: edw_log.put_line('Sequence is '||to_char(p_seq_id));
345: edw_log.put_line('View ID is '||to_char(p_view_id));
346: /* Push Currency Conversion Missing Rows */
347: PUSH_MISSING_ROWS;
348: RETURN l_no_rows;
341: AND seq_id = p_seq_id;
342: commit;
343: l_no_rows := sql%rowcount;
344: edw_log.put_line('Sequence is '||to_char(p_seq_id));
345: edw_log.put_line('View ID is '||to_char(p_view_id));
346: /* Push Currency Conversion Missing Rows */
347: PUSH_MISSING_ROWS;
348: RETURN l_no_rows;
349: EXCEPTION
399: FND_STATS.GATHER_TABLE_STATS(OWNNAME => l_OPI_schema,
400: TABNAME => 'OPI_EDW_OPM_JOB_DETAIL_INC');
401: END IF;
402:
403: edw_log.put_line('Sequence is '||to_char(l_seq_id));
404: RETURN(l_seq_id);
405: EXCEPTION
406: WHEN OTHERS THEN
407: g_errbuf:=sqlerrm;
405: EXCEPTION
406: WHEN OTHERS THEN
407: g_errbuf:=sqlerrm;
408: g_retcode:=sqlcode;
409: edw_log.put_line('Rasied Exception '||sqlerrm);
410:
411: RETURN(-1);
412: END;
413:
455: EDW_COLLECTION_UTIL.G_local_last_push_start_date -
456: EDW_COLLECTION_UTIL.g_offset);
457: g_push_to_date := nvl(l_to_date,
458: EDW_COLLECTION_UTIL.G_local_curr_push_start_date);
459: edw_log.put_line( 'The collection range is from '||
460: to_char(g_push_from_date,'MM/DD/YYYY HH24:MI:SS')||' to '||
461: to_char(g_push_to_date,'MM/DD/YYYY HH24:MI:SS'));
462: edw_log.put_line(' ');
463: -- --------------------------------------------
458: EDW_COLLECTION_UTIL.G_local_curr_push_start_date);
459: edw_log.put_line( 'The collection range is from '||
460: to_char(g_push_from_date,'MM/DD/YYYY HH24:MI:SS')||' to '||
461: to_char(g_push_to_date,'MM/DD/YYYY HH24:MI:SS'));
462: edw_log.put_line(' ');
463: -- --------------------------------------------
464: -- Identify OPM Net Changes
465: -- --------------------------------------------
466: edw_log.put_line(' ');
462: edw_log.put_line(' ');
463: -- --------------------------------------------
464: -- Identify OPM Net Changes
465: -- --------------------------------------------
466: edw_log.put_line(' ');
467: edw_log.put_line('Identifying changes in view type 1');
468: l_seq_id1 := IDENTIFY_OPM_CHANGE(1,l_row_count);
469: edw_log.put_line('Sequence is '||to_char(l_seq_id1));
470:
463: -- --------------------------------------------
464: -- Identify OPM Net Changes
465: -- --------------------------------------------
466: edw_log.put_line(' ');
467: edw_log.put_line('Identifying changes in view type 1');
468: l_seq_id1 := IDENTIFY_OPM_CHANGE(1,l_row_count);
469: edw_log.put_line('Sequence is '||to_char(l_seq_id1));
470:
471: if (l_seq_id1 = -1) THEN
465: -- --------------------------------------------
466: edw_log.put_line(' ');
467: edw_log.put_line('Identifying changes in view type 1');
468: l_seq_id1 := IDENTIFY_OPM_CHANGE(1,l_row_count);
469: edw_log.put_line('Sequence is '||to_char(l_seq_id1));
470:
471: if (l_seq_id1 = -1) THEN
472: RAISE l_iden_change_failure;
473: end if;
470:
471: if (l_seq_id1 = -1) THEN
472: RAISE l_iden_change_failure;
473: end if;
474: edw_log.put_line ('Identified '||l_row_count||' changed records in view type 1');
475: -- --------------------------------------------
476: -- Push to local staging table
477: -- --------------------------------------------
478: edw_log.put_line(' ');
474: edw_log.put_line ('Identified '||l_row_count||' changed records in view type 1');
475: -- --------------------------------------------
476: -- Push to local staging table
477: -- --------------------------------------------
478: edw_log.put_line(' ');
479: edw_log.put_line('Inserting into local staging table ');
480: l_row_count1 := PUSH_TO_LOCAL(1,l_seq_id1);
481: IF (l_row_count1 = -1) THEN RAISE L_push_local_failure; END IF;
482: edw_log.put_line('Inserted '||nvl(l_row_count1,0)||
475: -- --------------------------------------------
476: -- Push to local staging table
477: -- --------------------------------------------
478: edw_log.put_line(' ');
479: edw_log.put_line('Inserting into local staging table ');
480: l_row_count1 := PUSH_TO_LOCAL(1,l_seq_id1);
481: IF (l_row_count1 = -1) THEN RAISE L_push_local_failure; END IF;
482: edw_log.put_line('Inserted '||nvl(l_row_count1,0)||
483: ' rows into the local staging table ');
478: edw_log.put_line(' ');
479: edw_log.put_line('Inserting into local staging table ');
480: l_row_count1 := PUSH_TO_LOCAL(1,l_seq_id1);
481: IF (l_row_count1 = -1) THEN RAISE L_push_local_failure; END IF;
482: edw_log.put_line('Inserted '||nvl(l_row_count1,0)||
483: ' rows into the local staging table ');
484: edw_log.put_line(' ');
485: g_row_count:= l_row_count1;
486: edw_log.put_line(' ');
480: l_row_count1 := PUSH_TO_LOCAL(1,l_seq_id1);
481: IF (l_row_count1 = -1) THEN RAISE L_push_local_failure; END IF;
482: edw_log.put_line('Inserted '||nvl(l_row_count1,0)||
483: ' rows into the local staging table ');
484: edw_log.put_line(' ');
485: g_row_count:= l_row_count1;
486: edw_log.put_line(' ');
487: edw_log.put_line('For all views types, inserted '||nvl(g_row_count,0)||
488: ' rows into local staging table ');
482: edw_log.put_line('Inserted '||nvl(l_row_count1,0)||
483: ' rows into the local staging table ');
484: edw_log.put_line(' ');
485: g_row_count:= l_row_count1;
486: edw_log.put_line(' ');
487: edw_log.put_line('For all views types, inserted '||nvl(g_row_count,0)||
488: ' rows into local staging table ');
489: -- --------------------------------------------
490: -- No exception raised so far. Call wrapup to transport
483: ' rows into the local staging table ');
484: edw_log.put_line(' ');
485: g_row_count:= l_row_count1;
486: edw_log.put_line(' ');
487: edw_log.put_line('For all views types, inserted '||nvl(g_row_count,0)||
488: ' rows into local staging table ');
489: -- --------------------------------------------
490: -- No exception raised so far. Call wrapup to transport
491: -- data to target database, and insert messages into logs
489: -- --------------------------------------------
490: -- No exception raised so far. Call wrapup to transport
491: -- data to target database, and insert messages into logs
492: -- -----------------------------------------------
493: edw_log.put_line(' ');
494: edw_log.put_line('Inserted '||nvl(g_row_count,0)||
495: ' rows into the staging table');
496: edw_log.put_line(' ');
497: commit;
490: -- No exception raised so far. Call wrapup to transport
491: -- data to target database, and insert messages into logs
492: -- -----------------------------------------------
493: edw_log.put_line(' ');
494: edw_log.put_line('Inserted '||nvl(g_row_count,0)||
495: ' rows into the staging table');
496: edw_log.put_line(' ');
497: commit;
498:
492: -- -----------------------------------------------
493: edw_log.put_line(' ');
494: edw_log.put_line('Inserted '||nvl(g_row_count,0)||
495: ' rows into the staging table');
496: edw_log.put_line(' ');
497: commit;
498:
499: EDW_COLLECTION_UTIL.wrapup(TRUE, g_row_count, l_exception_msg,
500: g_push_from_date, g_push_to_date);
506: Errbuf:=g_errbuf;
507: Retcode:=g_retcode;
508: l_exception_msg := Retcode || ':' || Errbuf;
509: rollback; -- Rollback insert into local staging
510: edw_log.put_line('Inserting into local staging have failed');
511: EDW_COLLECTION_UTIL.wrapup(FALSE, 0, l_exception_msg,g_push_from_date,g_push_to_date);
512: raise;
513: WHEN L_IDEN_CHANGE_FAILURE THEN
514: Errbuf:=g_errbuf;
513: WHEN L_IDEN_CHANGE_FAILURE THEN
514: Errbuf:=g_errbuf;
515: Retcode:=g_retcode;
516: l_exception_msg := Retcode || ':' || Errbuf;
517: edw_log.put_line('Identifying changed records have Failed');
518: EDW_COLLECTION_UTIL.wrapup(FALSE, 0, l_exception_msg,g_push_from_date,g_push_to_date);
519: raise;
520: WHEN OTHERS THEN
521: Errbuf:=g_errbuf;
521: Errbuf:=g_errbuf;
522: Retcode:=g_retcode;
523: l_exception_msg := Retcode || ':' || Errbuf;
524: rollback;
525: edw_log.put_line('Other errors');
526: EDW_COLLECTION_UTIL.wrapup(FALSE, 0, l_exception_msg,
527: g_push_from_date, g_push_to_date);
528: raise;
529: END;