Sei sulla pagina 1di 20

CREATE OR REPLACE PROCEDURE xxbog_sup_validating_p ( retcode errbuf AS CURSOR cur_sup_stg_header IS SELECT DISTINCT vendor_name FROM xxbog_sup_interface; CURSOR cur_sup_stg_sites

(p_vendor_name VARCHAR2) IS SELECT vendor_site_code FROM xxbog_sup_interface WHERE vendor_name = p_vendor_name; CURSOR cur_sup_stg_contacts (p_vendor_site_code VARCHAR2) IS SELECT vendor_site_code FROM xxbog_sup_interface WHERE vendor_site_code = p_vendor_site_code; CURSOR cur_sup_hdr IS (SELECT * FROM xxbog_sup_interface_hdr WHERE process_flag IS NULL AND NVL (error_flag, 'N') = 'N' AND ROWNUM <= 6000); CURSOR cur_sup_sites IS (SELECT * FROM xxbog_sup_interface_sites WHERE process_flag IS NULL AND NVL (error_flag, 'N') = 'N' AND ROWNUM <= 6000); CURSOR cur_sup_contacts IS (SELECT * FROM xxbog_sup_interface_contacts WHERE process_flag IS NULL AND NVL (error_flag, 'N') = 'N' AND ROWNUM <= 6000); CURSOR cur_hdr_record_number_upd IS SELECT * FROM xxbog_sup_interface_hdr WHERE vendor_name IS NOT NULL FOR UPDATE OF record_number; CURSOR cur_sites_record_number_upd IS SELECT * FROM xxbog_sup_interface_sites WHERE vendor_site_code IS NOT NULL FOR UPDATE OF record_number; l_hdr_succ_cnt NUMBER; l_hdr_err_cnt NUMBER; l_sites_succ_cnt NUMBER; l_sites_err_cnt NUMBER; l_contacts_succ_cnt NUMBER; l_contacts_err_cnt NUMBER; lv_rec_num NUMBER := 0; --Declaring Variable for employee_id lv_vendor_type_lookup_code VARCHAR2(20); OUT OUT VARCHAR2, VARCHAR2)

lv_employee_id VARCHAR2(15); --Declaring variables for cost_centre and location lv_ccid VARCHAR2(30); lv_cost_centre VARCHAR2(10); lv_location VARCHAR2(10); ln_vendor_site_id NUMBER; BEGIN DELETE FROM xxbog.xxbog_sup_interface_hdr; DELETE FROM xxbog.xxbog_sup_interface_sites; DELETE FROM xxbog.xxbog_sup_interface_contacts; DELETE FROM xxbog.xxbog_sup_interface_contacts1; COMMIT; FOR i IN cur_sup_stg_header LOOP /* FOR UPLOADING EMPLOYEEE */ BEGIN SELECT vendor_type_lookup_code INTO lv_vendor_type_lookup_code FROM xxbog_sup_interface WHERE vendor_name = i.vendor_name; IF lv_vendor_type_lookup_code = 'EMPLOYEE' THEN SELECT person_id INTO lv_employee_id FROM per_all_people_f WHERE full_name = i.vendor_name AND current_employee_flag = 'Y'; ELSE lv_employee_id := NULL; END IF; EXCEPTION WHEN OTHERS THEN lv_employee_id := NULL; END; INSERT INTO xxbog_sup_interface_hdr (vendor_interface_id, vendor_id, vendor_name, vendor_name_alt, vat_registration_num, customer_num, vendor_type_lookup_code, one_time_flag, minority_group_lookup_code, small_business_flag, women_owned_flag, invoice_amount_limit, hold_all_payments_flag, hold_unmatched_invoices_flag, hold_reason, terms_name, invoice_currency_code, pay_group_lookup_code, payment_currency_code, payment_priority, terms_date_basis, pay_date_basis_lookup_code, exclude_freight_from_discount, payment_method_lookup_code, ship_to_location_code,

SELECT

FROM WHERE AND --- END LOOP; FOR j IN cur_sup_stg_sites (i.vendor_name) LOOP /* Code changed to insert cost center and location information in prepay a ccount of EMPLOYEE look-up type */ BEGIN

bill_to_location_code, ship_via_lookup_code, fob_lookup_code, freight_terms_lookup_code, create_debit_memo_flag, enforce_ship_to_location_code, qty_rcv_tolerance, qty_rcv_exception_code, days_early_receipt_allowed, days_late_receipt_allowed, receipt_days_exception_code, employee_id) vendor_interface_id_s.NEXTVAL, (SELECT vendor_id FROM po_vendors pv WHERE pv.vendor_name = i.vendor_name), vendor_name, vendor_name_alt, vat_registration_num, customer_num, vendor_type_lookup_code, one_time_flag, minority_group_lookup_code, small_business_flag, women_owned_flag, invoice_amount_limit, hold_all_payments_flag, hold_unmatched_invoices_flag, hold_reason, terms_name, invoice_currency_code, pay_group_lookup_code, payment_currency_code, payment_priority, terms_date_basis, pay_date_basis_lookup_code, exclude_freight_from_discount, payment_method_lookup_code, ship_to_location_code, bill_to_location_code, ship_via_lookup_code, fob_lookup_code, freight_terms_lookup_code, create_debit_memo_flag, enforce_ship_to_location_code, qty_rcv_tolerance, qty_rcv_exception_code, days_early_receipt_allowed, days_late_receipt_allowed, receipt_days_exception_code, lv_employee_id xxbog_sup_interface xsi vendor_name = i.vendor_name ROWNUM = 1;

SELECT vendor_type_lookup_code INTO lv_vendor_type_lookup_code FROM xxbog_sup_interface WHERE vendor_name = i.vendor_name; SELECT cost_centre, LOCATION INTO lv_cost_centre, lv_location FROM xxbog_sup_interface WHERE vendor_name = i.vendor_name AND vendor_type_lookup_code = 'EMPLOYEE'; IF lv_vendor_type_lookup_code = 'EMPLOYEE' THEN SELECT code_combination_id INTO lv_ccid FROM gl_code_combinations WHERE chart_of_accounts_id = (SELECT chart_of_accounts_id FROM gl_sets_of_books WHERE short_name = 'GH_SOB') AND segment1 || '.' || segment2 || '.' || segment3 || '.' || segment4 || '.' || segment5 || '.' || segment6 || '.' || segment7 = '10' || '.' || '01' || '.' || lv_cost_centre || '.' || lv_location || '.' || '00000' || '.' || '5506001' || '.' || '000000'; ELSE lv_ccid := NULL; END IF; EXCEPTION WHEN OTHERS THEN lv_ccid := NULL; END; INSERT INTO xxbog_sup_interface_sites (vendor_interface_id, vendor_id, vendor_site_code, vendor_site_code_alt, country, address_line1, address_line2, address_line3, address_line4,

address_lines_alt, city, state, zip, province, county, LANGUAGE, pay_site_flag, primary_pay_site_flag, purchasing_site_flag, rfq_only_site_flag, supplier_notif_method, telex, fax_area_code, fax, email_address, prepay_code_combination_id) SELECT vendor_interface_id_s.CURRVAL, (SELECT vendor_id FROM po_vendors pv WHERE pv.vendor_name = i.vendor_name), vendor_site_code, vendor_site_code_alt, country, address_line1, address_line2, address_line3, address_line4, address_lines_alt, city, state, zip, province, county, LANGUAGE, pay_site_flag, primary_pay_site_flag, purchasing_site_flag, rfq_only_site_flag, supplier_notif_method, telex, fax_area_code, fax, email_address, lv_ccid FROM xxbog_sup_interface WHERE vendor_name = i.vendor_name; COMMIT ; --WHERE ROWNUM=1; FOR k IN cur_sup_stg_contacts (j.vendor_site_code) LOOP INSERT INTO xxbog_sup_interface_contacts1 (record_number, vendor_site_code, first_name, middle_name, last_name, prefix, title, area_code,

SELECT

FROM WHERE AND COMMIT ; END LOOP; END LOOP; END LOOP; INSERT INTO xxbog_sup_interface_contacts(record_number, vendor_site_code, first_name, middle_name, last_name, prefix, title, area_code, phone, department, con_email_address, alt_area_code, alt_phone, vendor_id) SELECT DISTINCT record_number, vendor_site_code, first_name, middle_name, SUBSTR(last_name, 1,20), prefix, title, area_code, phone, department, con_email_address, alt_area_code, alt_phone, vendor_id FROM xxbog_sup_interface_contacts1; COMMIT; /************************/

phone, department, con_email_address, alt_area_code, alt_phone, vendor_id) record_number, vendor_site_code, first_name, middle_name, SUBSTR(last_name,1,20), prefix, title, area_code, phone, department, con_email_address, alt_area_code, alt_phone, (SELECT vendor_id FROM po_vendors pv WHERE pv.vendor_name = i.vendor_name) xxbog_sup_interface vendor_name = i.vendor_name vendor_site_code = j.vendor_site_code;

FOR cur_hdr IN cur_hdr_record_number_upd LOOP lv_rec_num := lv_rec_num + 1; BEGIN UPDATE xxbog_sup_interface_hdr SET record_number = lv_rec_num WHERE CURRENT OF cur_hdr_record_number_upd; END; COMMIT; EXIT WHEN cur_hdr_record_number_upd%NOTFOUND; END LOOP; FOR cur_sites IN cur_sites_record_number_upd LOOP lv_rec_num := lv_rec_num + 1; BEGIN UPDATE xxbog_sup_interface_sites SET record_number = lv_rec_num WHERE CURRENT OF cur_sites_record_number_upd; END; COMMIT; EXIT WHEN cur_sites_record_number_upd%NOTFOUND; END LOOP; /********************/ /*Updating vendor_id with sequence*/ fnd_file.put_line (fnd_file.LOG, 'updating vendor id with sequence'); /*UPDATE xxbog_sup_interface_hdr SET vendor_id= XXBOG_SUP_INT_VID_S.NEXTVAL;*/ FOR c_sup_hdr_rec IN cur_sup_hdr LOOP EXIT WHEN cur_sup_hdr%NOTFOUND; /*Checking for mandatory fields in header table */ fnd_file.put_line (fnd_file.LOG, 'Checking for mandatory fields in header table' ); IF c_sup_hdr_rec.vendor_name IS NULL THEN fnd_file.put_line (fnd_file.LOG, 'vendor name is null'); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr || ', ' || 'vendor name IS NULL', error_flag = 'Y' WHERE record_number = c_sup_hdr_rec.record_number; END IF; /*Checking for duplicate vendor name*/ fnd_file.put_line (fnd_file.LOG, 'Checking for duplicate vendor name'); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr || ', ' || 'Duplicate vendor name ', error_flag = 'Y' WHERE EXISTS (SELECT 1 FROM po_vendors pv WHERE pv.vendor_name = c_sup_hdr_rec.vendor_name) AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid vendor type lookup code*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid vendor lookup type code' ); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr || ', '|| 'vendor type lookup code IS N OT VALID', error_flag = 'Y' WHERE NOT EXISTS (

SELECT 1 FROM fnd_lookup_values_vl flv WHERE flv.lookup_code = c_sup_hdr_rec.vendor_type_looku p_code AND flv.lookup_type = 'VENDOR TYPE') AND vendor_type_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for ship to location code is valid or not*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid ship location code'); UPDATE xxbog_sup_interface_hdr xsih SET error_mesg_hdr =error_mesg_hdr || ', ' || 'ship_to_location_code is no t valid', error_flag = 'Y' WHERE ship_to_location_code NOT IN ( SELECT hla.location_code FROM hr_locations_all hla WHERE NVL (hla.ship_to_site_flag, 'N' ) = 'Y' AND NVL (hla.inactive_date, SYSDATE + 1) > SYSDATE) AND ship_to_location_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*updating ship_to_location_id*/ UPDATE xxbog_sup_interface_hdr xsih SET ship_to_location_id = (SELECT location_id FROM hr_locations_all WHERE location_code = xsih.ship_to_location_code ) WHERE record_number = c_sup_hdr_rec.record_number; /*Checking for bill to location code is valid or not*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid ship location code'); UPDATE xxbog_sup_interface_hdr xsih SET error_mesg_hdr =error_mesg_hdr || ', ' || 'bill_to_location_code is no t valid', error_flag = 'Y' WHERE bill_to_location_code NOT IN ( SELECT hla.location_code FROM hr_locations_all hla WHERE NVL (hla.ship_to_site_flag, 'N' ) = 'Y' AND NVL (hla.inactive_date, SYSDATE + 1) > SYSDATE) AND bill_to_location_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*updating bill to location id*/ fnd_file.put_line (fnd_file.LOG, 'updating bill to location id'); UPDATE xxbog_sup_interface_hdr xsih SET bill_to_location_id = (SELECT location_id FROM hr_locations_all WHERE location_code = xsih.bill_to_location_code) WHERE record_number = c_sup_hdr_rec.record_number; /*Checking for valid Terms name*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid Terms name'); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr || ', ' || 'Terms name is not valid', error_flag = 'Y'

WHERE NOT EXISTS (SELECT 1 FROM ap_terms AT WHERE AT.NAME = c_sup_hdr_rec.terms_name) AND terms_name IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid payment method lookup code*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid payment method lookup code' ); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr|| ', ' || 'payment method lookup code is not valid', error_flag = 'Y' WHERE UPPER (payment_method_lookup_code) NOT IN ( SELECT UPPER (flv.lookup_ code) FROM fnd_lookup_values_vl flv WHERE flv.lookup_type='PA YMENT TYPE') AND payment_method_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid FOB lookup code*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid fob lookup code'); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr || ', ' || 'fob lookup code is not vali d', error_flag = 'Y' WHERE NOT EXISTS ( SELECT 1 FROM fnd_lookup_values_vl flv WHERE flv.lookup_code = c_sup_hdr_rec.fob_lookup_code AND flv.lookup_type = 'FOB') AND fob_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid freight terms lookup code*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid freight terms lookup code' ); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr|| ', '|| 'freight terms lookup code is not valid', error_flag = 'Y' WHERE freight_terms_lookup_code NOT IN ( SELECT flv.lookup_code FROM fnd_lookup_values_vl flv WHERE flv.lookup_type = 'FREIGHT TERMS') AND freight_terms_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid ship via lookup code*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid ship via lookup code' ); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr = error_mesg_hdr || ', ' || 'ship via lookup code is not valid', error_flag = 'Y' WHERE NOT EXISTS ( SELECT 1

FROM fnd_lookup_values_vl flv WHERE flv.lookup_code = c_sup_hdr_rec.ship_via_lookup_code AND flv.lookup_type = 'SHIP_VIA') AND ship_via_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid pay date basislookup code*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid pay date basis lookup code' ); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr|| ', '|| 'pay date basis lookup code is not valid', error_flag = 'Y' WHERE NOT EXISTS ( SELECT 1 FROM fnd_lookup_values_vl flv WHERE TRIM (flv.lookup_code) = TRIM(UPPER (c_sup_hdr_rec.pay_date_basis_lookup_code) ) AND flv.lookup_type = 'PAY DATE BASIS') AND pay_date_basis_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number; /*Checking for valid minority group lookup code*/ /*fnd_file.put_line (fnd_file.LOG, 'Checking for valid minority group look up code'); UPDATE xxbog_sup_interface_hdr SET error_mesg_hdr =error_mesg_hdr || ', ' || 'Minority group lookup code is not valid', error_flag = 'Y' WHERE NOT EXISTS ( SELECT 1 FROM fnd_lookup_values_vl flv WHERE flv.lookup_code = c_sup_hdr_rec.Minority group_loo kup_code AND flv.lookup_type = 'MINORITY_OWNED_TYPE') AND Minority_group_lookup_code IS NOT NULL AND record_number = c_sup_hdr_rec.record_number;*/ END LOOP; /************************************/ FOR c_sup_sites_rec IN cur_sup_sites LOOP EXIT WHEN cur_sup_sites%NOTFOUND; /*Checking for mandatory fields in supplier sites table */ fnd_file.put_line (fnd_file.LOG, 'Checking for mandatory fields in supplier sites table' ); IF c_sup_sites_rec.vendor_site_code IS NULL THEN fnd_file.put_line (fnd_file.LOG, 'vendor site code is null'); UPDATE xxbog_sup_interface_sites SET error_mesg_sites = error_mesg_sites || ', ' || 'vendor site code is null', error_flag = 'Y' WHERE record_number = c_sup_sites_rec.record_number; END IF; /*checking for valid country*/ fnd_file.put_line (fnd_file.LOG, 'Checking for valid country'); UPDATE xxbog_sup_interface_sites xsis SET error_mesg_sites =

error_mesg_sites || ', ' || 'country is not valid', error_flag = 'Y' WHERE NOT EXISTS (SELECT 1 FROM fnd_territories_tl ft WHERE xsis.country = ft.territory_code) AND record_number = c_sup_sites_rec.record_number; /*Checking adresslines,city,state,zip,province,country,area_code,phone,county,ad dress_style are valid are not*/ /*FND_FILE.PUT_line(FND_FILE.LOG,'Checking adresslines,city,state,zip,provinc e,country,county,address_style are valid are not'); UPDATE xxbog_sup_interface_sites SET error_mesg_sites=error_mesg_sites||', '||'address is not valid', error_flag='Y' WHERE EXISTS (SELECT 1 FROM po_vendors pv,po_vendor_sites pvs WHERE pv.vendor_id=pvs.vendor_id AND pvs.address_line1=c_sup_sites_rec.address_line1 AND pvs.address_line2=c_sup_sites_rec.address_line2 AND pvs.address_line3=c_sup_sites_rec.address_line3 AND pvs.address_lines_alt=c_sup_sites_rec.address_line4 AND pvs.city=c_sup_sites_rec.city AND pvs.state=c_sup_sites_rec.state AND pvs.zip=c_sup_sites_rec.zip AND pvs.province=c_sup_sites_rec.province AND pvs.country=c_sup_sites_rec.country AND pvs.county=c_sup_sites_rec.county ) AND record_number=c_sup_sites_rec.record_number;*/ /*updating the organization id*/ fnd_file.put_line (fnd_file.LOG, 'Updating Organization ID'); UPDATE xxbog_sup_interface_sites SET org_id = 101 WHERE org_id IS NULL AND record_number = c_sup_sites_rec.record_number; /*checking for valid vendor_id */ fnd_file.put_line (fnd_file.LOG, 'checking for valid vendor_id '); UPDATE xxbog_sup_interface_sites xsis SET vendor_id = (SELECT vendor_id FROM xxbog_sup_interface_hdr xsih WHERE xsis.vendor_interface_id = xsih.vendor_interface_id) WHERE record_number = c_sup_sites_rec.record_number; END LOOP; /*************************************/ UPDATE xxbog_sup_interface_contacts SET vendor_site_id = xxbog_sup_int_vsiteid_s.NEXTVAL; FOR c_sup_con_rec IN cur_sup_contacts LOOP EXIT WHEN cur_sup_contacts%NOTFOUND; /*Checking for mandatory fields in supplier contacts table */ fnd_file.put_line (fnd_file.LOG, 'Checking for mandatory fields in supplier contacts table' ); IF c_sup_con_rec.vendor_site_code IS NULL THEN UPDATE xxbog_sup_interface_contacts SET error_mesg_con = error_mesg_con || ', ' || 'vendor site code is null' || c_sup_con_rec.vendor_site_code,

error_flag = 'Y' WHERE record_number = c_sup_con_rec.record_number; --CODE MODIFED AS LAST NAME CAN BE NULL /* ELSIF c_sup_con_rec.last_name IS NULL THEN UPDATE xxbog_sup_interface_contacts SET error_mesg_con = error_mesg_con || ', ' || 'last name is null' || c_sup_con_rec.last_name, error_flag = 'Y' WHERE record_number = c_sup_con_rec.record_number; */ END IF; /*checking for valid vendor*/ UPDATE xxbog_sup_interface_contacts xsic SET error_mesg_con = error_mesg_con || ', ' || 'invalid vendor site code' || c_sup_con_rec.vendor_site_code, error_flag = 'Y' WHERE EXISTS ( SELECT 1 FROM xxbog_sup_interface_sites xsis WHERE xsis.vendor_site_code = xsic.vendor_site_code AND NVL (error_flag, 'N') = 'Y') AND xsic.vendor_site_code IS NOT NULL AND record_number = c_sup_con_rec.record_number; /*checking for valid address*/ UPDATE xxbog_sup_interface_contacts xsic SET error_mesg_con = error_mesg_con || ', ' || 'invalid address', error_flag = 'Y' WHERE EXISTS ( SELECT 1 FROM po_vendor_sites_all pvs, po_vendor_contacts pvc WHERE pvs.vendor_site_id = pvc.vendor_site_id AND pvc.first_name = c_sup_con_rec.first_name AND pvc.middle_name = c_sup_con_rec.middle_name AND pvc.last_name = c_sup_con_rec.last_name AND pvc.prefix = c_sup_con_rec.prefix AND pvc.title = c_sup_con_rec.title AND pvc.area_code = c_sup_con_rec.area_code AND pvc.phone = c_sup_con_rec.phone AND pvc.email_address = c_sup_con_rec.con_email_address) AND record_number = c_sup_con_rec.record_number; /*updating the organization id*/ fnd_file.put_line (fnd_file.LOG, 'Updating Organization ID'); UPDATE xxbog_sup_interface_contacts SET org_id = 101 WHERE org_id IS NULL AND record_number = c_sup_con_rec.record_number; COMMIT; END LOOP; /******************************************/ fnd_file.put_line (fnd_file.LOG, ' INSERTING ALL THE STATGING TABLE DATA INTO INTERFACE TABLES' ); /* INSERTING ALL THE STAGING TABLE DATA INTO ap_suppliers_int*/ INSERT INTO ap_suppliers_int

(vendor_interface_id, --- VENDOR_ID, vendor_name, vendor_name_alt, vendor_type_lookup_code, vat_registration_num, customer_num, one_time_flag, minority_group_lookup_code, small_business_flag, women_owned_flag, invoice_amount_limit, ship_to_location_id, ship_to_location_code, bill_to_location_id, bill_to_location_code, ship_via_lookup_code, freight_terms_lookup_code, fob_lookup_code, terms_name, hold_all_payments_flag, hold_reason, payment_method_lookup_code, hold_unmatched_invoices_flag, invoice_currency_code, pay_group_lookup_code, payment_currency_code, payment_priority, terms_date_basis, pay_date_basis_lookup_code, exclude_freight_from_discount, create_debit_memo_flag, enforce_ship_to_location_code, qty_rcv_tolerance, qty_rcv_exception_code, days_early_receipt_allowed, days_late_receipt_allowed, receipt_days_exception_code, created_by, creation_date, last_updated_by, last_update_login, last_update_date, EMPLOYEE_ID, ALLOW_AWT_FLAG, AWT_GROUP_NAME) SELECT vendor_interface_id, ---VENDOR_ID, vendor_name, vendor_name_alt, vendor_type_lookup_code, vat_registration_num, customer_num, one_time_flag, minority_group_lookup_code, small_business_flag, women_owned_flag, invoice_amount_limit, ship_to_location_id, ship_to_location_code, bill_to_location_id,

bill_to_location_code, ship_via_lookup_code, freight_terms_lookup_code, fob_lookup_code, terms_name, hold_all_payments_flag, hold_reason, payment_method_lookup_code, hold_unmatched_invoices_flag, invoice_currency_code, pay_group_lookup_code, payment_currency_code, payment_priority, terms_date_basis, pay_date_basis_lookup_code, exclude_freight_from_discount, create_debit_memo_flag, enforce_ship_to_location_code, qty_rcv_tolerance, qty_rcv_exception_code, days_early_receipt_allowed, days_late_receipt_allowed, receipt_days_exception_code, fnd_profile.VALUE ('USER_ID'), SYSDATE, fnd_profile.VALUE ('USER_ID'), fnd_profile.VALUE ('LOGIN_ID'), SYSDATE, EMPLOYEE_ID, 'Y', 7 '5% WHT' 7 */

--- Hard Coded on 01-Jul-200 --- Hard Coded on 01-Jul-200

/* ----- Added in this code to insert for vendor_type_lookup_code 'EMPLOYEE' FROM xxbog_sup_interface_hdr WHERE NVL (error_flag, 'N') <> 'Y'; COMMIT; /* INSERTING ALL THE STATGING TABLE DATA INTO ap_supplier_sites_int*/ INSERT INTO ap_supplier_sites_int (vendor_interface_id, vendor_id, vendor_site_code, vendor_site_code_alt, purchasing_site_flag, pay_site_flag, rfq_only_site_flag, address_line1, address_lines_alt, address_line2, address_line3, address_line4, city, state, zip, province, country, county, customer_num, ship_to_location_id,

SELECT

ship_to_location_code, bill_to_location_id, bill_to_location_code, ship_via_lookup_code, freight_terms_lookup_code, fob_lookup_code, fax, fax_area_code, telex, payment_method_lookup_code, payment_priority, terms_date_basis, terms_name, pay_group_lookup_code, invoice_amount_limit, pay_date_basis_lookup_code, invoice_currency_code, payment_currency_code, hold_all_payments_flag, hold_reason, hold_unmatched_invoices_flag, exclude_freight_from_discount, LANGUAGE, vat_registration_num, create_debit_memo_flag, supplier_notif_method, email_address, primary_pay_site_flag, created_by, creation_date, last_updated_by, last_update_login, last_update_date, org_id, operating_unit_name, prepay_code_combination_id, ALLOW_AWT_FLAG, AWT_GROUP_NAME) DECODE (xsis.vendor_id,NULL, xsis.vendor_interface_id,NULL), xsis.vendor_id, vendor_site_code, vendor_site_code_alt, purchasing_site_flag, pay_site_flag, rfq_only_site_flag, address_line1, address_lines_alt, address_line2, address_line3, address_line4, city, state, zip, province, country, county, xsih.customer_num, xsih.ship_to_location_id, xsih.ship_to_location_code, xsih.bill_to_location_id,

xsih.bill_to_location_code, xsih.ship_via_lookup_code, xsih.freight_terms_lookup_code, xsih.fob_lookup_code, fax, fax_area_code, telex, xsih.payment_method_lookup_code, xsih.payment_priority, xsih.terms_date_basis, xsih.terms_name, xsih.pay_group_lookup_code, xsih.invoice_amount_limit, xsih.pay_date_basis_lookup_code, xsih.invoice_currency_code, xsih.payment_currency_code, xsih.hold_all_payments_flag, xsih.hold_reason, xsih.hold_unmatched_invoices_flag, xsih.exclude_freight_from_discount, LANGUAGE, xsih.vat_registration_num, xsih.create_debit_memo_flag, supplier_notif_method, email_address, primary_pay_site_flag, fnd_profile.VALUE ('USER_ID'), SYSDATE, fnd_profile.VALUE ('USER_ID'), fnd_profile.VALUE ('LOGIN_ID'), SYSDATE, org_id, 'Bank of Ghana', xsis.prepay_code_combination_id, 'Y', --- Hard Coded on 01-Jul-200 7 '5% WHT' 7 xxbog_sup_interface_sites xsis, xxbog_sup_interface_hdr xsih WHERE NVL (xsis.error_flag, 'N') <> 'Y' AND xsis.vendor_interface_id = xsih.vendor_interface_id AND xsis.org_id = 101; COMMIT; /* INSERTING ALL THE STAGING TABLE DATA INTO ap_sup_site_contact_int*/ FOR m1 IN (SELECT a.vendor_id,b.VENDOR_SITE_CODE FROM xxbog_sup_interface_hdr a, xxbog_sup_interface_sites b WHERE a.vendor_id = b.vendor_id ) LOOP BEGIN BEGIN SELECT a.vendor_site_id INTO ln_vendor_site_id FROM po_VENDOR_SITES_all a,po_vendor_contacts b WHERE a.VENDOR_SITE_ID = b.VENDOR_SITE_ID AND a.VENDOR_ID = m1.VENDOR_ID AND a.VENDOR_SITE_CODE = m1.VENDOR_SITE_CODE; EXCEPTION WHEN NO_DATA_FOUND THEN ln_vendor_site_id:=0; FROM --- Hard Coded on 01-Jul-200

END; IF ln_vendor_site_id=0 THEN INSERT INTO ap_sup_site_contact_int (vendor_site_id, vendor_site_code, first_name, middle_name, last_name, prefix, title, department, area_code, phone, email_address, alt_area_code, alt_phone, org_id, operating_unit_name, created_by, creation_date, last_updated_by, last_update_login, last_update_date) SELECT (SELECT vendor_site_id FROM po_vendor_sites_all pvsa WHERE UPPER (pvsa.vendor_site_code) =UPPER (xsic.vendor_site_co de) AND pvsa.vendor_id = m1.vendor_id AND ROWNUM = 1 AND org_id = fnd_profile.VALUE ('ORG_ID') AND NOT EXISTS ( SELECT 1 FROM po_vendor_contacts pvc WHERE pvc.vendor_site_id =pvsa.vendor_site_id)), -- xsic.vendor_site_id, DECODE((SELECT vendor_site_id FROM po_vendor_sites_all pvsa WHERE UPPER (pvsa.vendor_site_code) =UPPER (xsic.vendor_site_co de) AND ROWNUM = 1 AND org_id = fnd_profile.VALUE ('ORG_ID') AND NOT EXISTS ( SELECT 1 FROM po_vendor_contacts pvc WHERE pvc.vendor_site_id =pvsa.vendor_site_id)), NULL, xsic.vendor_site_code,NULL) vendor_site_code, first_name, middle_name, last_name, prefix, title, department, area_code, phone, con_email_address, alt_area_code, alt_phone, fnd_profile.VALUE ('ORG_ID'), ---xsic.org_id, 'Bank of Ghana', fnd_profile.VALUE ('USER_ID'),

FROM WHERE AND END IF; END; END LOOP; COMMIT; /*********************************/ UPDATE xxbog_sup_interface_hdr SET process_flag = 7 WHERE NVL (error_flag, 'N') <> 'Y'; UPDATE xxbog_sup_interface_sites SET process_flag = 7 WHERE NVL (error_flag, 'N') <> 'Y'; UPDATE xxbog_sup_interface_contacts SET process_flag = 7 WHERE NVL (error_flag, 'N') <> 'Y'; SELECT COUNT (1) INTO l_hdr_succ_cnt FROM xxbog_sup_interface_hdr WHERE NVL (process_flag, 1) = 7; SELECT COUNT (1) INTO l_hdr_err_cnt FROM xxbog_sup_interface_hdr WHERE NVL (process_flag, 1) <> 7; SELECT COUNT (1) INTO l_sites_succ_cnt FROM xxbog_sup_interface_sites WHERE NVL (process_flag, 1) = 7; SELECT COUNT (1) INTO l_sites_err_cnt FROM xxbog_sup_interface_sites WHERE NVL (process_flag, 1) <> 7; SELECT COUNT (1) INTO l_contacts_succ_cnt FROM xxbog_sup_interface_contacts WHERE NVL (process_flag, 1) = 7; SELECT COUNT (1) INTO l_contacts_err_cnt FROM xxbog_sup_interface_contacts WHERE NVL (process_flag, 1) <> 7; fnd_file.put_line (fnd_file.output, ' '); fnd_file.put_line (fnd_file.output, 'Total Number of Successful Header Records : ' || l_hdr_succ_cnt ); fnd_file.put_line (fnd_file.output, 'Total Number of Errored Header Records : ' || l_hdr_err_cnt ); fnd_file.put_line (fnd_file.output, 'Total Number of Successful supplier site Records : ' || l_sites_succ_cnt );

SYSDATE, fnd_profile.VALUE ('USER_ID'), fnd_profile.VALUE ('LOGIN_ID'), SYSDATE xxbog_sup_interface_contacts xsic NVL (xsic.error_flag, 'N') <> 'Y' xsic.vendor_id = m1.vendor_id;

fnd_file.put_line (fnd_file.output, 'Total Number of Errored supplier site Records : ' || l_sites_err_cnt ); fnd_file.put_line (fnd_file.output, 'Total Number of Successful supplier contact Records : ' || l_contacts_succ_cnt ); fnd_file.put_line (fnd_file.output, 'Total Number of Errored supplier contact Records : ' || l_contacts_err_cnt ); fnd_file.put_line (fnd_file.output, ' '); fnd_file.put_line (fnd_file.output, '------------------------------ERROR LOG--------------------------------------' ); fnd_file.put_line (fnd_file.output, ' '); fnd_file.put_line (fnd_file.output, '------------------------------HEADER ERRORS--------------------------------------' ); fnd_file.put_line (fnd_file.output, 'Record Number Error Message'); fnd_file.put_line (fnd_file.output, '-------------------------------------------------------------------------' ); FOR err_rec IN (SELECT * FROM xxbog_sup_interface_hdr WHERE NVL (error_flag, 'N') = 'Y' OR error_mesg_hdr IS NOT NULL) LOOP fnd_file.put_line (fnd_file.output, err_rec.record_number || ' ' || err_rec.error_mesg_hdr ); END LOOP; fnd_file.put_line (fnd_file.output, ' '); fnd_file.put_line (fnd_file.output, '------------------------------suppliers sites ERRORS--------------------------------------' ); fnd_file.put_line (fnd_file.output, 'Record Number Error Message'); fnd_file.put_line (fnd_file.output, '-------------------------------------------------------------------------' ); FOR err_rec IN (SELECT * FROM xxbog_sup_interface_sites WHERE error_flag = 'Y' OR error_mesg_sites IS NOT NULL) LOOP

fnd_file.put_line (fnd_file.output, err_rec.record_number || ' ' || err_rec.error_mesg_sites ); END LOOP; fnd_file.put_line (fnd_file.output, ' '); fnd_file.put_line (fnd_file.output, '------------------------------suppliers contacts ERRORS---------------------------------------' ); fnd_file.put_line (fnd_file.output, 'Record Number Error Message'); fnd_file.put_line (fnd_file.output, '--------------------------------------------------------------------------' ); FOR err_rec IN (SELECT * FROM xxbog_sup_interface_contacts WHERE error_flag = 'Y' OR error_mesg_con IS NOT NULL) LOOP fnd_file.put_line (fnd_file.output, err_rec.record_number || ' ' || err_rec.error_mesg_con ); END LOOP; EXCEPTION WHEN OTHERS THEN fnd_file.put_line (fnd_file.LOG, 'Error in supplier Upload Process : ' || SQLERRM ); END xxbog_sup_validating_p; /

Potrebbero piacerti anche