You are on page 1of 3

CREATE OR REPLACE PACKAGE xxtr_vendor180_pkg

AS
PROCEDURE xxtr_vendor180_proc(errbuf OUT VARCHAR2, retcode OUT NUMBER);
END xxtr_vendor180_pkg;
/

CREATE OR REPLACE PACKAGE BODY xxtr_vendor180_pkg


AS
PROCEDURE xxtr_vendor180_proc(errbuf OUT VARCHAR2, retcode OUT NUMBER)
AS
lv_organization_id hr_operating_units.organization_id%TYPE;
lv_vendor_id NUMBER;
lv_status VARCHAR2 (2000);
lv_exception_msg VARCHAR2 (2000);
lv_vendor_site_id NUMBER;
lv_vendor_contact_id NUMBER;
CURSOR cur_sup_info
IS
SELECT *
FROM xxtr_v180_int;
CURSOR cur_sup_sites_info (p_vendor_site_code NUMBER)
IS
SELECT *
FROM xxtr_v180_sites
WHERE vendor_site_code = p_vendor_site_code;
CURSOR cur_sup_cont_int (p_vendor_site_code NUMBER)
IS
SELECT *
FROM xxtr_v180_contact
WHERE vendor_site_code = p_vendor_site_code;
BEGIN
SELECT organization_id
INTO lv_organization_id
FROM hr_operating_units
WHERE NAME = 'Vision Operations';
fnd_client_info.set_org_context (lv_organization_id);
fnd_file.put_line (1, 'Organization Id set');
FOR supp IN cur_sup_info
LOOP
ap_po_vendors_apis_pkg.insert_new_vendor
(p_vendor_name =>
supp.vendor_name,
p_vendor_type_lookup_code =>
'VENDOR',
p_taxpayer_id => NULL,
p_tax_registration_id => NULL,
p_women_owned_flag => NULL,
p_small_business_flag => NULL,
p_minority_group_lookup_code => NULL,
p_supplier_number => NULL,
x_vendor_id =>
lv_vendor_id,
x_status =>
lv_status,
x_exception_msg =>
lv_exception_msg
);
fnd_file.put_line (1, 'Vendor inserted');
fnd_file.put_line (1, 'vendor Id: ' || lv_vendor_id);
FOR supp_site IN cur_sup_sites_info (supp.vendor_site_code)
LOOP
ap_po_vendors_apis_pkg.insert_new_vendor_site
(p_vendor_site_code =>
supp_site.vendor_site_code,
p_vendor_id => lv_vendor_id,
p_org_id => lv_organization_id,
p_address_line1 =>
supp_site.address_line1,
p_address_line2 =>
supp_site.address_line2,
p_address_line3 =>
supp_site.address_line3,
p_address_line4 => NULL,
p_city => supp_site.city,
p_state => supp_site.state,
p_zip => supp_site.zip,
p_province => NULL,
p_county => NULL,
p_country => supp_site.country,
p_area_code => NULL,
p_phone => NULL,
p_fax_area_code => NULL,
p_fax => NULL,
p_email_address => NULL,
p_purchasing_site_flag => 'Y',
p_pay_site_flag => 'Y',
p_rfq_only_site_flag => NULL,
x_vendor_site_id => lv_vendor_site_id,
x_status => lv_status,
x_exception_msg => lv_exception_msg
);
fnd_file.put_line (1, 'Vendor site id inserted');
fnd_file.put_line (1, 'vendor site Id :' || lv_vendor_site_id);
FOR supp_con IN cur_sup_cont_int(supp.vendor_site_code)
LOOP
ap_po_vendors_apis_pkg.insert_new_vendor_contact
(p_vendor_site_id => lv_vendor_site_id,
p_first_name =>supp_con.first_name,
p_last_name =>supp_con.last_name,
p_middle_name =>supp_con.middle_name,
p_prefix => NULL,
p_title => NULL,
p_mail_stop => NULL,
p_area_code => NULL,
p_phone => supp_con.phone,
p_alt_area_code => NULL,
p_alt_phone => NULL,
p_fax_area_code => NULL,
p_fax => supp_con.fax,
p_email_address =>
supp_con.email_address,
p_url => NULL,
x_vendor_contact_id => lv_vendor_contact_id,
x_status => lv_status,
x_exception_msg => lv_exception_msg
);
fnd_file.put_line (1, 'Vendor contact inserted');
fnd_file.put_line (1,
'vendor contact Id :' || lv_vendor_contact_id
);
END LOOP;
END LOOP;
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (1, 'Error in Inserting');
END xxtr_vendor180_proc;
END xxtr_vendor180_pkg;
/

You might also like