[Home] [Help]
590: -- lose the beginning onhand quantities.
591: BEGIN
592: SELECT trunc (min (trx_date)) -- must drop time stamp timestamp.
593: INTO l_edw_start_date_org
594: FROM opi_ids_push_log
595: WHERE organization_id = org_id;
596: EXCEPTION
597: WHEN NO_DATA_FOUND THEN
598: NULL; -- l_edw_start_date_org would be NULL if no date found
657: EDW_LOG.PUT_LINE('to_date: ' || to_char(to_date,'DD-MON-YYYY hh24:mi:ss'));
658:
659:
660: /*-------------------------------------------------------------------
661: Purge old data in opi_ids_push_log table.
662: For a specified org, all rows with transaction date in a closed period
663: will be purged, EXCEPT rows with txn dates falling into a period
664: start date or a period end date. In addition, data in a closed period
665: which include the lastest pushed transaction date will not be purged.
664: start date or a period end date. In addition, data in a closed period
665: which include the lastest pushed transaction date will not be purged.
666: --------------------------------------------------------------------*/
667: l_statement := 40;
668: EDW_LOG.PUT_LINE('Calling purge_opi_ids_push_log ...');
669: select sysdate into l_print_date from dual;
670: EDW_LOG.PUT_LINE('Start time: ' ||
671: to_char (sysdate, 'DD-MON-YY HH24:MI:SS'));
672:
682: FETCH l_extraction_periods_csr INTO l_extraction_periods_rec;
683: FETCH l_extraction_periods_csr INTO l_extraction_periods_rec;
684: IF l_extraction_periods_csr%FOUND THEN
685: -- must have more than 1 period
686: DELETE FROM opi_ids_push_log
687: WHERE trx_date BETWEEN inv_from_date AND to_date
688: AND trx_date <> l_edw_start_date_org
689: AND organization_id = org_id;
690: END IF;
690: END IF;
691: CLOSE l_extraction_periods_csr;
692: END IF;
693:
694: purge_opi_ids_push_log(org_id,
695: l_errnum,
696: l_retcode,
697: l_errbuf);
698:
1309: -- lose the beginning onhand quantities.
1310: BEGIN
1311: SELECT trunc (min (trx_date)) -- must drop time stamp timestamp.
1312: INTO l_edw_start_date_org
1313: FROM opi_ids_push_log
1314: WHERE organization_id = org_id;
1315: EXCEPTION -- don't expect to be here, because we should
1316: -- are not doing a first push and at least the
1317: -- EDW inception entries should be present. Just
1526: l_status Number:=1;
1527:
1528: CURSOR last_trx is
1529: SELECT trunc(MAX(trx_date))
1530: FROM OPI_IDS_PUSH_LOG
1531: WHERE ORGANIZATION_ID = p_organization_id
1532: AND INVENTORY_ITEM_ID = p_item_id
1533: AND nvl(COST_GROUP_ID,-999) = nvl(p_cost_group_id,-999)
1534: AND nvl(REVISION,-999) = nvl(p_revision,-999)
1560:
1561:
1562:
1563: /*---------------------------------------------------------------------------------------
1564: The above cursor will find if the record is already existing in opi_ids_push_log for a
1565: particular item,org,costgroup,rev,lot,sub and locator. It not then the start qty and start
1566: value are 0, otherwise get the start value and qty for the last transacted record for that
1567: combination (last record) from opi_ids_push_log
1568: ------------------------------------------------------------------------------------------*/
1563: /*---------------------------------------------------------------------------------------
1564: The above cursor will find if the record is already existing in opi_ids_push_log for a
1565: particular item,org,costgroup,rev,lot,sub and locator. It not then the start qty and start
1566: value are 0, otherwise get the start value and qty for the last transacted record for that
1567: combination (last record) from opi_ids_push_log
1568: ------------------------------------------------------------------------------------------*/
1569:
1570: l_ids_key := l_max_trx_date||'-'||p_item_id||'-'||p_organization_id||'-'||p_cost_group_id||'-'||p_revision||'-'||p_lot_number||'-'||p_subinventory||'-'||p_locator;
1571:
1602: -- if nothing is found, then there
1603: -- must never have been an
1604: -- inception qty
1605: INTO l_last_end_qty, l_last_end_val
1606: FROM opi_ids_push_log
1607: WHERE IDS_KEY = l_ids_key;
1608: Exception
1609: when others then
1610: edw_log.put_line('ids key - ' || l_ids_key );
1615: ELSE
1616: Begin -- Suhasini Added exception handling, Forward port 11.5.9.3
1617: SELECT Nvl(end_onh_val_b,0), Nvl(end_onh_qty,0)
1618: INTO l_last_end_val, l_last_end_qty
1619: FROM OPI_IDS_PUSH_LOG
1620: WHERE IDS_KEY = l_ids_key;
1621: Exception
1622: when others then
1623: edw_log.put_line('ids key - ' || l_ids_key );
1767: status := 1;
1768:
1769: END Calculate_Balance;
1770:
1771: PROCEDURE purge_opi_ids_push_log(
1772: i_org_id IN NUMBER,
1773: o_errnum OUT NOCOPY NUMBER, -- bug 3589921 added nocopy
1774: o_retcode OUT NOCOPY VARCHAR2, -- bug 3589921 added nocopy
1775: o_errbuf OUT NOCOPY VARCHAR2 -- bug 3589921 added nocopy
1800: l_last_push_date := null;
1801: l_latest_push_date := null;
1802:
1803:
1804: -- Get the min date of opi_ids_push_log rows which are not period start
1805: -- or period end dates. Rows with that date would be the first ones to
1806: -- be purged if they belong to an 'eligible' closed period, i.e. a
1807: -- period that does not include the last push transaction date.
1808:
1808:
1809: l_statement := 10;
1810: select min(trx_date)
1811: into l_purge_from_date
1812: from opi_ids_push_log ipl
1813: where push_flag = 0 -- already pushed
1814: and period_flag is null -- not start or end period rows
1815: and organization_id = i_org_id;
1816:
1861: if l_purge_from_date > l_purge_to_date then
1862: raise no_purge;
1863: else
1864: l_statement := 50;
1865: delete from opi_ids_push_log ipl
1866: where ipl.organization_id = i_org_id
1867: and ipl.trx_date between l_purge_from_date
1868: and l_purge_to_date
1869: and ipl.push_flag = 0
1886: EXCEPTION
1887: WHEN no_purge then
1888: o_errnum := l_errnum;
1889: o_errbuf := l_errbuf;
1890: EDW_LOG.PUT_LINE('OPIMXWI.purge_opi_ids_push_log - no purge; ');
1891: EDW_LOG.PUT_LINE('Data can only be purged thru '
1892: || to_char(l_purge_to_date));
1893: WHEN others then
1894: o_errnum := SQLCODE;
1891: EDW_LOG.PUT_LINE('Data can only be purged thru '
1892: || to_char(l_purge_to_date));
1893: WHEN others then
1894: o_errnum := SQLCODE;
1895: o_errbuf := 'OPIMXWI.purge_opi_ids_push_log ('
1896: || to_char(l_statement)
1897: || '): '
1898: || substr(SQLERRM, 1,200);
1899:
1896: || to_char(l_statement)
1897: || '): '
1898: || substr(SQLERRM, 1,200);
1899:
1900: END purge_opi_ids_push_log;
1901:
1902: PROCEDURE process_error(
1903: i_stmt_num IN NUMBER,
1904: i_errnum IN NUMBER,
2394: ORDER BY trunc(mmt.TRANSACTION_DATE),mmt.inventory_item_id;
2395:
2396: CURSOR row_exists IS
2397: SELECT 1
2398: FROM opi_ids_push_log
2399: WHERE IDS_KEY=l_pk;
2400:
2401: CURSOR last_trx is
2402: SELECT trunc(MAX(trx_date))
2399: WHERE IDS_KEY=l_pk;
2400:
2401: CURSOR last_trx is
2402: SELECT trunc(MAX(trx_date))
2403: FROM OPI_IDS_PUSH_LOG
2404: WHERE ORGANIZATION_ID = l_organization_id
2405: AND INVENTORY_ITEM_ID = l_item_id
2406: AND nvl(COST_GROUP_ID,-999) = nvl(l_cost_group_id,-999)
2407: AND REVISION is null
2524: INTO l_row_exists;
2525:
2526: if(row_exists%rowcount > 0) then
2527: l_statement:=4;
2528: UPDATE opi_ids_push_log
2529: SET end_int_qty = (end_int_qty + total_qty)
2530: WHERE IDS_KEY = l_pk;
2531:
2532: else
2539:
2540:
2541: /*---------------------------------------------------------------
2542: The above cursor will find if the record is already existing
2543: in opi_ids_push_log for a particular item,org,costgroup.
2544: If not then the start int qty and start value are 0,
2545: otherwise get the start value and qty for the last
2546: transacted record for that combination (last record)
2547: from opi_ids_push_log
2543: in opi_ids_push_log for a particular item,org,costgroup.
2544: If not then the start int qty and start value are 0,
2545: otherwise get the start value and qty for the last
2546: transacted record for that combination (last record)
2547: from opi_ids_push_log
2548: -----------------------------------------------------------------*/
2549:
2550: IF(l_max_trx_date is null) THEN
2551: l_last_end_qty := 0;
2552: l_last_end_val := 0;
2553: ELSE
2554: SELECT Nvl(end_int_val_b,0), Nvl(end_int_qty,0)
2555: INTO l_last_end_val, l_last_end_qty
2556: FROM OPI_IDS_PUSH_LOG
2557: WHERE IDS_KEY = l_max_trx_date||'-'||l_item_id||'-'||l_organization_id||'-'||l_cost_group_id||'-'||'-'||'-'||'-';
2558:
2559: END IF;
2560:
2571: select process_enabled_flag into l_process_org
2572: from mtl_parameters where organization_id = l_organization_id;
2573:
2574: if l_process_org <> 'Y' then
2575: INSERT INTO opi_ids_push_log
2576: (ids_key,
2577: cost_group_id,
2578: organization_id,
2579: inventory_item_id,