1: PACKAGE BODY rcv_core_s AS
2: /* $Header: RCVCOCOB.pls 120.2 2006/05/18 05:21:59 amony noship $*/
3:
4: -- Read the profile option that enables/disables the debug log
5: g_asn_debug VARCHAR2(1) := NVL(fnd_profile.VALUE('RCV_DEBUG_MODE'), 'N');
6: g_log_head CONSTANT VARCHAR2(30) := 'po.plsql.RCV_CORE_S.'; --
7: e_validation_error EXCEPTION;
8:
9: /*===========================================================================
1293: x_header_record IN OUT NOCOPY rcv_shipment_header_sv.headerrectype
1294: ) IS
1295: BEGIN
1296: IF x_header_record.header_record.receipt_header_id IS NOT NULL THEN
1297: IF (g_asn_debug = 'Y') THEN
1298: asn_debug.put_line('Need to put a cursor to retrieve other values');
1299: asn_debug.put_line('Shipment header Id has been provided');
1300: END IF;
1301:
1294: ) IS
1295: BEGIN
1296: IF x_header_record.header_record.receipt_header_id IS NOT NULL THEN
1297: IF (g_asn_debug = 'Y') THEN
1298: asn_debug.put_line('Need to put a cursor to retrieve other values');
1299: asn_debug.put_line('Shipment header Id has been provided');
1300: END IF;
1301:
1302: RETURN;
1295: BEGIN
1296: IF x_header_record.header_record.receipt_header_id IS NOT NULL THEN
1297: IF (g_asn_debug = 'Y') THEN
1298: asn_debug.put_line('Need to put a cursor to retrieve other values');
1299: asn_debug.put_line('Shipment header Id has been provided');
1300: END IF;
1301:
1302: RETURN;
1303: END IF;
1309: OR REPLACE(x_header_record.header_record.shipment_num,
1310: ' ',
1311: ''
1312: ) IS NULL) THEN
1313: IF (g_asn_debug = 'Y') THEN
1314: asn_debug.put_line('Cannot derive the shipment_header_id at this point');
1315: END IF;
1316:
1317: RETURN;
1310: ' ',
1311: ''
1312: ) IS NULL) THEN
1313: IF (g_asn_debug = 'Y') THEN
1314: asn_debug.put_line('Cannot derive the shipment_header_id at this point');
1315: END IF;
1316:
1317: RETURN;
1318: END IF;
1339: AND shipment_num = x_header_record.header_record.shipment_num
1340: AND shipped_date >= ADD_MONTHS(x_header_record.header_record.shipped_date, -12);
1341: EXCEPTION
1342: WHEN OTHERS THEN
1343: IF (g_asn_debug = 'Y') THEN
1344: asn_debug.put_line(SQLERRM);
1345: END IF;
1346: END;
1347:
1340: AND shipped_date >= ADD_MONTHS(x_header_record.header_record.shipped_date, -12);
1341: EXCEPTION
1342: WHEN OTHERS THEN
1343: IF (g_asn_debug = 'Y') THEN
1344: asn_debug.put_line(SQLERRM);
1345: END IF;
1346: END;
1347:
1348: RETURN;
1366: BEGIN
1367: -- no need to derive shipment_header_id if it is already provided
1368:
1369: IF x_header_record.header_record.receipt_header_id IS NOT NULL THEN
1370: IF (g_asn_debug = 'Y') THEN
1371: asn_debug.put_line('Shipment header Id has been provided');
1372: END IF;
1373:
1374: RETURN;
1367: -- no need to derive shipment_header_id if it is already provided
1368:
1369: IF x_header_record.header_record.receipt_header_id IS NOT NULL THEN
1370: IF (g_asn_debug = 'Y') THEN
1371: asn_debug.put_line('Shipment header Id has been provided');
1372: END IF;
1373:
1374: RETURN;
1375: END IF;
1382: OR REPLACE(x_header_record.header_record.shipment_num,
1383: ' ',
1384: ''
1385: ) IS NULL) THEN
1386: IF (g_asn_debug = 'Y') THEN
1387: asn_debug.put_line('Shipment num is still null');
1388: END IF;
1389:
1390: RETURN;
1383: ' ',
1384: ''
1385: ) IS NULL) THEN
1386: IF (g_asn_debug = 'Y') THEN
1387: asn_debug.put_line('Shipment num is still null');
1388: END IF;
1389:
1390: RETURN;
1391: END IF;
1412: AND shipment_num = x_header_record.header_record.shipment_num
1413: AND shipped_date >= ADD_MONTHS(x_header_record.header_record.shipped_date, -12);
1414: EXCEPTION
1415: WHEN OTHERS THEN
1416: IF (g_asn_debug = 'Y') THEN
1417: asn_debug.put_line(SQLERRM);
1418: END IF;
1419: END;
1420:
1413: AND shipped_date >= ADD_MONTHS(x_header_record.header_record.shipped_date, -12);
1414: EXCEPTION
1415: WHEN OTHERS THEN
1416: IF (g_asn_debug = 'Y') THEN
1417: asn_debug.put_line(SQLERRM);
1418: END IF;
1419: END;
1420:
1421: RETURN;
1439: x_shipment_header_id NUMBER; -- added for cancel process
1440: x_sysdate DATE := SYSDATE;
1441: BEGIN
1442: -- Check for shipment number which is null, blank , zero
1443: IF (g_asn_debug = 'Y') THEN
1444: asn_debug.put_line('Check for shipment number which is null, blank , zero ');
1445: END IF;
1446:
1447: /*dbms_output.put_line(nvl(X_header_record.header_record.shipment_num,'@@@'));*/
1440: x_sysdate DATE := SYSDATE;
1441: BEGIN
1442: -- Check for shipment number which is null, blank , zero
1443: IF (g_asn_debug = 'Y') THEN
1444: asn_debug.put_line('Check for shipment number which is null, blank , zero ');
1445: END IF;
1446:
1447: /*dbms_output.put_line(nvl(X_header_record.header_record.shipment_num,'@@@'));*/
1448: IF x_header_record.header_record.asn_type IN('ASN', 'ASBN')
1459: END IF;
1460:
1461: -- Check for Receipts before ASN
1462:
1463: IF (g_asn_debug = 'Y') THEN
1464: asn_debug.put_line('Check for Receipts before ASN ');
1465: END IF;
1466:
1467: /*
1460:
1461: -- Check for Receipts before ASN
1462:
1463: IF (g_asn_debug = 'Y') THEN
1464: asn_debug.put_line('Check for Receipts before ASN ');
1465: END IF;
1466:
1467: /*
1468: * BUGNO: 1708017
1580: END IF;
1581: END IF;
1582:
1583: -- Check for matching ASN if ADD, CANCEL
1584: IF (g_asn_debug = 'Y') THEN
1585: asn_debug.put_line('Check for matching ASN if ADD, CANCEL');
1586: END IF;
1587:
1588: /*
1581: END IF;
1582:
1583: -- Check for matching ASN if ADD, CANCEL
1584: IF (g_asn_debug = 'Y') THEN
1585: asn_debug.put_line('Check for matching ASN if ADD, CANCEL');
1586: END IF;
1587:
1588: /*
1589: * BUGNO: 1708017
1612: END IF;
1613: END IF;
1614:
1615: -- Check that there are no receipts against the ASN for ADD, CANCEL
1616: IF (g_asn_debug = 'Y') THEN
1617: asn_debug.put_line('Check that there are no receipts against the ASN for ADD, CANCEL');
1618: END IF;
1619:
1620: IF x_header_record.header_record.transaction_type IN('ADD', 'CANCEL')
1613: END IF;
1614:
1615: -- Check that there are no receipts against the ASN for ADD, CANCEL
1616: IF (g_asn_debug = 'Y') THEN
1617: asn_debug.put_line('Check that there are no receipts against the ASN for ADD, CANCEL');
1618: END IF;
1619:
1620: IF x_header_record.header_record.transaction_type IN('ADD', 'CANCEL')
1621: AND x_header_record.header_record.asn_type IN('ASN', 'ASBN') THEN
1647: AND shipped_date >= ADD_MONTHS(x_sysdate, -12));
1648: END IF;
1649:
1650: IF NVL(x_count, 0) > 0 THEN -- Some quantity has been received
1651: IF (g_asn_debug = 'Y') THEN
1652: asn_debug.put_line('There are receipts against the ASN ' || x_header_record.header_record.shipment_num);
1653: END IF;
1654:
1655: rcv_error_pkg.set_error_message('RCV_ASN_QTY_RECEIVED');
1648: END IF;
1649:
1650: IF NVL(x_count, 0) > 0 THEN -- Some quantity has been received
1651: IF (g_asn_debug = 'Y') THEN
1652: asn_debug.put_line('There are receipts against the ASN ' || x_header_record.header_record.shipment_num);
1653: END IF;
1654:
1655: rcv_error_pkg.set_error_message('RCV_ASN_QTY_RECEIVED');
1656: rcv_error_pkg.set_token('SHIPMENT', x_header_record.header_record.shipment_num);
1660:
1661: -- If we have reached this place that means the shipment exists
1662: -- Make sure we have a shipment header id
1663:
1664: IF (g_asn_debug = 'Y') THEN
1665: asn_debug.put_line('Make sure we have a shipment_header_id');
1666: END IF;
1667:
1668: /*
1661: -- If we have reached this place that means the shipment exists
1662: -- Make sure we have a shipment header id
1663:
1664: IF (g_asn_debug = 'Y') THEN
1665: asn_debug.put_line('Make sure we have a shipment_header_id');
1666: END IF;
1667:
1668: /*
1669: * BUGNO: 1708017
1687: END IF;
1688:
1689: -- Verify that the shipment_header_id matches the derived/defaulted shipment_header_id
1690:
1691: IF (g_asn_debug = 'Y') THEN
1692: asn_debug.put_line('Verify that the shipment_header_id matches the derived/defaulted shipment_header_id');
1693: END IF;
1694:
1695: /*
1688:
1689: -- Verify that the shipment_header_id matches the derived/defaulted shipment_header_id
1690:
1691: IF (g_asn_debug = 'Y') THEN
1692: asn_debug.put_line('Verify that the shipment_header_id matches the derived/defaulted shipment_header_id');
1693: END IF;
1694:
1695: /*
1696: * BUGNO: 1708017
1712: AND TRUNC(shipped_date) = TRUNC(x_header_record.header_record.shipped_date)
1713: AND shipped_date >= ADD_MONTHS(x_sysdate, -12);
1714:
1715: IF x_shipment_header_id <> x_header_record.header_record.receipt_header_id THEN
1716: IF (g_asn_debug = 'Y') THEN
1717: asn_debug.put_line('The shipment_header_id do not match ');
1718: END IF;
1719:
1720: rcv_error_pkg.set_error_message('RCV_ASN_MISMATCH_SHIP_ID');
1713: AND shipped_date >= ADD_MONTHS(x_sysdate, -12);
1714:
1715: IF x_shipment_header_id <> x_header_record.header_record.receipt_header_id THEN
1716: IF (g_asn_debug = 'Y') THEN
1717: asn_debug.put_line('The shipment_header_id do not match ');
1718: END IF;
1719:
1720: rcv_error_pkg.set_error_message('RCV_ASN_MISMATCH_SHIP_ID');
1721: rcv_error_pkg.set_token('SHIPMENT', x_header_record.header_record.shipment_num);