[Home] [Help]
900:
901:
902:
903: --L7: Check for existing ASN with same Shipment Number
904: l_previous_sn pos_exasn_headers.shipment_number%type;
905: l_new_sn varchar2(1);
906: cursor l_checkExistAsn_csr
907: is
908: select line_number, shipment_number
910: (
911: select pht.line_number, pht.shipment_number
912: from pos_exasn_lines plnt,
913: rcv_headers_interface rhi,
914: pos_exasn_headers pht
915: where pht.header_id = plnt.header_id
916: and pht.shipment_number = rhi.shipment_num
917: and plnt.vendor_id = rhi.vendor_id
918: and nvl(plnt.vendor_site_id, -9999) = nvl(rhi.vendor_site_id, -9999)
919: union
920: select plnt.line_number, pht.shipment_number
921: from pos_exasn_lines plnt,
922: rcv_shipment_headers rsh,
923: pos_exasn_headers pht
924: where pht.header_id = plnt.header_id
925: and pht.shipment_number = rsh.shipment_num
926: and plnt.vendor_id = rsh.vendor_id
927: and nvl(plnt.vendor_site_id, -9999) = nvl(rsh.vendor_site_id, -9999))
933: l_header_id number;
934:
935: --L8: Check for Expected Receipt Date Tolerance per PO Shipment
936: l_receipt_days_exception_code po_line_locations_all.receipt_days_exception_code%type;
937: l_exp_rec_date pos_exasn_headers.expected_receipt_date%type;
938:
939: l_days_early po_line_locations_all.DAYS_EARLY_RECEIPT_ALLOWED%type;
940: l_days_late po_line_locations_all.DAYS_LATE_RECEIPT_ALLOWED%type;
941: l_due_date date;
1357: line_number
1358: into
1359: l_exp_rec_date,
1360: l_header_line_number
1361: from pos_exasn_headers
1362: where header_id = l_header_id;
1363:
1364: if(l_exp_rec_date > l_due_date+l_days_late OR l_exp_rec_date < l_due_date-l_days_early) then
1365: fnd_message.set_name('POS','POS_EXASN_ERDATE_TOL');
1434: --H2: GROSS WEIGHT UOM
1435: cursor l_checkGrossWtUOM_csr
1436: is
1437: select pht.line_number, pht.gross_weight_uom
1438: from pos_exasn_headers pht
1439: where pht.gross_weight_uom is not null
1440: and not exists
1441: (select 1 from por_unit_of_measure_lov_v puomv
1442: where puomv.unit_of_measure = pht.gross_weight_uom);
1445: --H3: NET WEIGHT UOM
1446: cursor l_checkNetWtUOM_csr
1447: is
1448: select pht.line_number, pht.net_weight_uom
1449: from pos_exasn_headers pht
1450: where pht.net_weight_uom is not null
1451: and not exists
1452: (select 1 from por_unit_of_measure_lov_v puomv
1453: where puomv.unit_of_measure = pht.net_weight_uom);
1455: --H4: TAR WEIGHT UOM
1456: cursor l_checkTarWtUOM_csr
1457: is
1458: select pht.line_number, pht.tar_weight_uom
1459: from pos_exasn_headers pht
1460: where pht.tar_weight_uom is not null
1461: and not exists
1462: (select 1 from por_unit_of_measure_lov_v puomv
1463: where puomv.unit_of_measure = pht.tar_weight_uom);
1465: --H5: FREIGHT TERMS
1466: cursor l_checkFreightTerms_csr
1467: is
1468: select pht.line_number, pht.freight_terms
1469: from pos_exasn_headers pht
1470: where pht.freight_terms is not null
1471: and not exists
1472: (select 1 from po_lookup_codes plc
1473: where plc.lookup_type = 'FREIGHT TERMS'and sysdate < nvl(plc.inactive_date, sysdate + 1)
1476: --H7: SHIPMENT DATE has to be < SYSDATE
1477: cursor l_checkShipDate_csr
1478: is
1479: select pht.line_number, shipment_date
1480: from pos_exasn_headers pht
1481: where shipment_date > sysdate;
1482:
1483: --H8: INVOICE PAYMENT TERMS
1484: cursor l_checkInvPT_csr
1483: --H8: INVOICE PAYMENT TERMS
1484: cursor l_checkInvPT_csr
1485: is
1486: select pht.line_number, pht.payment_terms
1487: from pos_exasn_headers pht
1488: where pht.payment_terms is not null
1489: and not exists
1490: (select 1 from ap_terms_val_v av
1491: where av.name = pht.payment_terms);
1493: --H9: Bad if expected receipt Date is BEFORE Shipment Date
1494: cursor l_checkER_Ship_csr
1495: is
1496: select pht.line_number
1497: from pos_exasn_headers pht
1498: where expected_receipt_date < shipment_date;
1499:
1500:
1501:
1516: end loop;
1517: close l_checkGrossWtUOM_csr;
1518:
1519: --Convert Gross Weight UOM to code
1520: update pos_exasn_headers
1521: set gross_weight_uom =
1522: (select puomv.uom_code
1523: from por_unit_of_measure_lov_v puomv
1524: where gross_weight_uom is not null
1539: end loop;
1540: close l_checkNetWtUOM_csr;
1541:
1542: --Convert Net Weight UOM to code
1543: update pos_exasn_headers
1544: set net_weight_uom =
1545: (select puomv.uom_code
1546: from por_unit_of_measure_lov_v puomv
1547: where net_weight_uom is not null
1562: end loop;
1563: close l_checkTarWtUOM_csr;
1564:
1565: --Convert Tar Weight UOM to code
1566: update pos_exasn_headers
1567: set tar_weight_uom =
1568: (select puomv.uom_code
1569: from por_unit_of_measure_lov_v puomv
1570: where tar_weight_uom is not null
1691:
1692:
1693: update pos_exasn_lines plnt
1694: set lpn_group_id = (select pht.lpn_group_id
1695: from pos_exasn_headers pht
1696: where pht.header_id = plnt.header_id)
1697: where
1698: (
1699: plnt.lls_code in ('LAS','LOT')
2852: select HEADER_ID from
2853: (
2854: select
2855: count(1), pht.header_id HEADER_ID, pht.shipment_number SHIPMENT_NUMBER, plnt.vendor_id VENDOR_ID, plnt.ship_to_org_id SHIP_TO_ORG_ID, nvl(plnt.vendor_site_id, -9999) VENDOR_SITE_ID, plnt.currency_code
2856: from pos_exasn_headers pht,
2857: pos_exasn_lines plnt
2858: where pht.header_id = plnt.header_id
2859: group by pht.header_id, pht.shipment_number, plnt.vendor_id, plnt.ship_to_org_id, nvl(plnt.vendor_site_id, -9999), plnt.currency_code
2860: )
2871: l_asbn_bad varchar2(1);
2872: l_error_ln number;
2873: cursor l_checkNotPaySite_csr is
2874: select peh.line_number
2875: from pos_exasn_headers peh,
2876: po_vendor_sites_all pvsa
2877: where pvsa.vendor_site_id = peh.vendor_site_id
2878: AND getvendorpaysiteid(peh.vendor_id,nvl(peh.vendor_site_id, -9999),peh.currency_code) IS null;
2879: --Refer the bug7338353 for more details
2878: AND getvendorpaysiteid(peh.vendor_id,nvl(peh.vendor_site_id, -9999),peh.currency_code) IS null;
2879: --Refer the bug7338353 for more details
2880:
2881: --H1: Freight Carrier Code
2882: l_fcc pos_exasn_headers.freight_carrier_code%type;
2883: cursor l_checkFreightCC_csr
2884: is
2885: select pht.line_number, pht.freight_carrier_code
2886: from pos_exasn_headers pht
2882: l_fcc pos_exasn_headers.freight_carrier_code%type;
2883: cursor l_checkFreightCC_csr
2884: is
2885: select pht.line_number, pht.freight_carrier_code
2886: from pos_exasn_headers pht
2887: where pht.freight_carrier_code is not null
2888: and 0=
2889: (select count(*) from org_freight oft
2890: where nvl(oft.disable_date, sysdate) >= sysdate
2892: and organization_id = pht.ship_to_org_id
2893: );
2894:
2895: --H10: Bad Ship From Location
2896: l_ship_from_loc pos_exasn_headers.ship_from_location_code%type;
2897: cursor l_shipFrom_Loc_csr is
2898: select pht.line_number,pht.ship_from_location_code
2899: from pos_exasn_headers pht
2900: where pht.ship_from_location_code is not null
2895: --H10: Bad Ship From Location
2896: l_ship_from_loc pos_exasn_headers.ship_from_location_code%type;
2897: cursor l_shipFrom_Loc_csr is
2898: select pht.line_number,pht.ship_from_location_code
2899: from pos_exasn_headers pht
2900: where pht.ship_from_location_code is not null
2901: and not exists (
2902: select 1 from hz_party_sites ps,hz_party_site_uses psu,po_vendors pov
2903: where ps.party_site_id = psu.party_site_id
2910: begin
2911:
2912: l_asbn_bad := 'F';
2913:
2914: select max(header_id) into l_asn_header_id from pos_exasn_headers;
2915:
2916: select decode(count(1),0,'ASN','ASBN')
2917: into l_asn_asbn
2918: from pos_exasn_headers
2914: select max(header_id) into l_asn_header_id from pos_exasn_headers;
2915:
2916: select decode(count(1),0,'ASN','ASBN')
2917: into l_asn_asbn
2918: from pos_exasn_headers
2919: where invoice_number is not null;
2920:
2921:
2922:
2944: if(l_asn_asbn = 'ASBN') then
2945: l_asbn_bad := 'T';
2946: select line_number
2947: into l_error_ln
2948: from pos_exasn_headers
2949: where header_id = l_ex_header_id;
2950:
2951: fnd_message.set_name('POS','POS_EXASN_ASBN_XHDR');
2952: fnd_message.set_token('LINE_NUM',l_error_ln);
2973: if(l_asbn_bad = 'T') then
2974: raise l_early_exit;
2975: end if;
2976:
2977: update pos_exasn_headers pht
2978: set (
2979: pht.vendor_id,
2980: pht.ship_to_org_id,
2981: pht.vendor_site_id,
3050:
3051:
3052:
3053: -- Update Payment Term ID, if any
3054: update pos_exasn_headers pht
3055: set payment_term_id =
3056: (select atv.term_id
3057: from ap_terms_val_v atv
3058: where atv.name = pht.payment_terms)
3063:
3064:
3065: update pos_exasn_lines plnt
3066: set (header_interface_id, group_id, expected_receipt_date) = (select pht.header_interface_id, pht.group_id, pht.expected_receipt_date
3067: from pos_exasn_headers pht
3068: where pht.header_id = plnt.header_id);
3069: exception when l_early_exit then
3070: null;
3071: end FixHeadersAndLines;
3286: BEGIN
3287: select rcv_interface_groups_s.nextval into l_lpn_group_id from dual;
3288: select rcv_headers_interface_s.nextval into l_header_interface_id from dual;
3289:
3290: insert into pos_exasn_headers(
3291: header_id,
3292: lpn_group_id,
3293: vendor_id,
3294: ship_to_org_id,
3302: p_ex_ship_to_org_id,
3303: p_ex_vendor_site_id,
3304: l_header_interface_id);
3305:
3306: update pos_exasn_headers
3307: set (
3308: PAYMENT_TERM_ID,
3309: CURRENCY_CODE,
3310: RATE,
3409: ATTRIBUTE12,
3410: ATTRIBUTE13,
3411: ATTRIBUTE14,
3412: ATTRIBUTE15
3413: from pos_exasn_headers
3414: where header_id = p_ex_header_id)
3415: where header_id = p_asn_header_id;
3416:
3417:
3836: net_weight_uom,
3837: net_weight,
3838: decode(invoice_number,null,null,getvendorpaysiteid(vendor_id,nvl(vendor_site_id,-9999),currency_code)),
3839: ship_from_location_code
3840: from pos_exasn_headers;
3841:
3842:
3843:
3844: end InsertIntoRHI;
4110:
4111: cursor l_checkDocAsn_csr
4112: is
4113: select SHIPMENT_NUMBER
4114: from pos_Exasn_headers
4115: group by SHIPMENT_NUMBER, nvl(VENDOR_ID,-9999), nvl(VENDOR_SITE_ID,-9999)
4116: having count(1) > 1;
4117:
4118:
4118:
4119: cursor l_buyerNotif_csr
4120: is
4121: select SHIPMENT_NUMBER, VENDOR_ID, VENDOR_SITE_ID
4122: from pos_exasn_headers;
4123:
4124: l_shipment_number pos_exasn_headers.shipment_number%type;
4125: l_vendor_id pos_exasn_headers.vendor_id%type;
4126: l_vendor_site_id pos_exasn_headers.vendor_site_id%type;
4120: is
4121: select SHIPMENT_NUMBER, VENDOR_ID, VENDOR_SITE_ID
4122: from pos_exasn_headers;
4123:
4124: l_shipment_number pos_exasn_headers.shipment_number%type;
4125: l_vendor_id pos_exasn_headers.vendor_id%type;
4126: l_vendor_site_id pos_exasn_headers.vendor_site_id%type;
4127: l_user_vendor_id_tbl vendor_id_tbl_type;
4128:
4121: select SHIPMENT_NUMBER, VENDOR_ID, VENDOR_SITE_ID
4122: from pos_exasn_headers;
4123:
4124: l_shipment_number pos_exasn_headers.shipment_number%type;
4125: l_vendor_id pos_exasn_headers.vendor_id%type;
4126: l_vendor_site_id pos_exasn_headers.vendor_site_id%type;
4127: l_user_vendor_id_tbl vendor_id_tbl_type;
4128:
4129: /* Inbound Logistics : Validate Ship From Location Code */
4122: from pos_exasn_headers;
4123:
4124: l_shipment_number pos_exasn_headers.shipment_number%type;
4125: l_vendor_id pos_exasn_headers.vendor_id%type;
4126: l_vendor_site_id pos_exasn_headers.vendor_site_id%type;
4127: l_user_vendor_id_tbl vendor_id_tbl_type;
4128:
4129: /* Inbound Logistics : Validate Ship From Location Code */
4130: Cursor l_shipFrom is
4133: plt.po_line_id,
4134: plt.po_line_location_id,
4135: pht.ship_from_location_code,
4136: ps.location_id as ship_from_location_id
4137: from pos_exasn_headers pht,
4138: pos_exasn_lines plt,
4139: hz_party_sites ps
4140: where pht.header_id = plt.header_id
4141: and pht.ship_from_location_code is not null
4145: l_lineIdTbl po_tbl_number := po_tbl_number();
4146: l_lineLocIdTbl po_tbl_number := po_tbl_number();
4147: l_count NUMBER := 0;
4148: l_return_status VARCHAR2(2000);
4149: l_prev_header_id pos_exasn_headers.header_id%type := -1;
4150: l_prev_ship_from VARCHAR2(30) := '';
4151: l_header_id pos_exasn_headers.header_id%type;
4152: l_line_id pos_exasn_lines.po_line_id%type;
4153: l_line_location_id pos_exasn_lines.po_line_location_id%type;
4147: l_count NUMBER := 0;
4148: l_return_status VARCHAR2(2000);
4149: l_prev_header_id pos_exasn_headers.header_id%type := -1;
4150: l_prev_ship_from VARCHAR2(30) := '';
4151: l_header_id pos_exasn_headers.header_id%type;
4152: l_line_id pos_exasn_lines.po_line_id%type;
4153: l_line_location_id pos_exasn_lines.po_line_location_id%type;
4154: l_ship_from_location_code pos_exasn_headers.ship_from_location_code%type;
4155: --l_ship_from_location_id hz_party_sites.location_id%type;
4150: l_prev_ship_from VARCHAR2(30) := '';
4151: l_header_id pos_exasn_headers.header_id%type;
4152: l_line_id pos_exasn_lines.po_line_id%type;
4153: l_line_location_id pos_exasn_lines.po_line_location_id%type;
4154: l_ship_from_location_code pos_exasn_headers.ship_from_location_code%type;
4155: --l_ship_from_location_id hz_party_sites.location_id%type;
4156: l_ship_from_location_id number;
4157: l_err_tbl po_tbl_varchar2000 ;
4158: