原文地址 使用API失效供应商地址Demo
DECLARE lv_return_status VARCHAR2(1) := NULL; ln_msg_count NUMBER; lv_errmsg VARCHAR2(5000); lt_vendor_site_rec ap_vendor_pub_pkg.r_vendor_site_rec_type; l_party_site_rec hz_party_site_v2pub.party_site_rec_type; lt_location_rec hz_location_v2pub.location_rec_type; ln_object_version_number NUMBER; ln_object_version_number2 NUMBER; ln_vendor_site_id NUMBER := NULL; ln_party_site_id NUMBER := NULL; lv_party_site_name VARCHAR2(240); lv_party_site_number VARCHAR2(30); ln_location_id NUMBER; -- WHO columns l_user_id NUMBER := -1; l_resp_id NUMBER := -1; l_application_id NUMBER := -1; l_row_cnt NUMBER := 1; l_user_name VARCHAR2(30) := &user_name; l_resp_name VARCHAR2(30) := &resp_name; lv_vendor_site_code VARCHAR2(15) := &vendor_site_code; ln_org_id NUMBER := &org_id; /*CURSOR sup_site IS SELECT vendor_site_code_de FROM xxwe_mg_supplier_sites_xross WHERE batch_id = 234 AND segment1_so NOT LIKE ‘NON%‘;*/ BEGIN -- Get the user_id SELECT user_id INTO l_user_id FROM fnd_user WHERE upper(user_name) = upper(l_user_name); -- Get the application_id and responsibility_id SELECT application_id, responsibility_id INTO l_application_id, l_resp_id FROM fnd_responsibility_vl WHERE upper(responsibility_name) = upper(l_resp_name); -- Initialize applications information fnd_global.apps_initialize(l_user_id, l_resp_id, l_application_id); -- Mfg / Mfg & Dist Mgr / INV dbms_output.put_line(‘Initialized applications context: ‘ || l_user_id || ‘ ‘ || l_resp_id || ‘ ‘ || l_application_id); -- dbms_output.put_line(‘------------------Start Update-------------------‘); --FOR rec IN sup_site LOOP --dbms_output.put_line(‘Supplier site code:‘ || rec.vendor_site_code_de); --dbms_output.put_line(‘Supplier org id:‘ || ln_org_id); --SELECT NECESSARY INFORMATION BEGIN SELECT pvs.vendor_site_id, pvs.party_site_id, hps.party_site_name, hps.object_version_number, hps.party_site_number, pvs.location_id, hl.object_version_number INTO ln_vendor_site_id, ln_party_site_id, lv_party_site_name, ln_object_version_number, lv_party_site_number, ln_location_id, ln_object_version_number2 FROM ap_supplier_sites_all pvs, hz_party_sites hps, hz_locations hl WHERE pvs.vendor_site_code = lv_vendor_site_code--rec.vendor_site_code_de AND pvs.org_id = ln_org_id AND pvs.party_site_id = hps.party_site_id AND pvs.location_id = hl.location_id; EXCEPTION WHEN no_data_found THEN lv_errmsg := ‘Can not find the vendor site need to update!The site code is:‘ || lv_vendor_site_code/*rec.vendor_site_code_de*/; dbms_output.put_line(lv_errmsg); END; -- lt_vendor_site_rec.vendor_site_id := ln_vendor_site_id; lt_vendor_site_rec.vendor_site_code := substr(lv_vendor_site_code, length(lv_vendor_site_code) - 7, 8) || ‘disable‘; lt_vendor_site_rec.inactive_date := SYSDATE; --UPDATE vendor_site_code ap_vendor_pub_pkg.update_vendor_site(p_api_version => 1.0, p_init_msg_list => fnd_api.g_true, p_commit => fnd_api.g_false, p_validation_level => fnd_api.g_valid_level_full, x_return_status => lv_return_status, x_msg_count => ln_msg_count, x_msg_data => lv_errmsg, p_vendor_site_rec => lt_vendor_site_rec, p_vendor_site_id => ln_vendor_site_id); IF (nvl(lv_return_status, fnd_api.g_ret_sts_error) <> fnd_api.g_ret_sts_success) THEN ln_msg_count := fnd_msg_pub.count_msg; IF ln_msg_count > 0 THEN lv_errmsg := substr(fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false), 1, 512); FOR i IN 1 .. (ln_msg_count - 1) LOOP lv_errmsg := lv_errmsg || chr(10) || substr(fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false), 1, 512); END LOOP; fnd_msg_pub.delete_msg(); END IF; dbms_output.put_line(‘------------------Update Error-------------------‘); dbms_output.put_line(‘Error1 :‘ || lv_errmsg); END IF; --UPDATE party_site_name l_party_site_rec.party_site_id := ln_party_site_id; l_party_site_rec.party_site_name := lv_party_site_name || ‘disable‘; l_party_site_rec.status := ‘I‘; -- hz_party_site_v2pub.update_party_site(p_init_msg_list => fnd_api.g_false, p_party_site_rec => l_party_site_rec, p_object_version_number => ln_object_version_number, x_return_status => lv_return_status, x_msg_count => ln_msg_count, x_msg_data => lv_errmsg); IF (nvl(lv_return_status, fnd_api.g_ret_sts_error) <> fnd_api.g_ret_sts_success) THEN ln_msg_count := fnd_msg_pub.count_msg; IF ln_msg_count > 0 THEN lv_errmsg := substr(fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false), 1, 512); FOR i IN 1 .. (ln_msg_count - 1) LOOP lv_errmsg := lv_errmsg || chr(10) || substr(fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false), 1, 512); END LOOP; fnd_msg_pub.delete_msg(); END IF; dbms_output.put_line(‘------------------Update Error-------------------‘); dbms_output.put_line(‘Error2 :‘ || lv_errmsg); END IF; --update location lt_location_rec.address_style := ‘POSTAL_ADDR_DEF‘; lt_location_rec.location_id := ln_location_id; hz_location_v2pub.update_location(p_init_msg_list => fnd_api.g_true, p_location_rec => lt_location_rec, p_object_version_number => ln_object_version_number2, x_return_status => lv_return_status, x_msg_count => ln_msg_count, x_msg_data => lv_errmsg); IF (nvl(lv_return_status, fnd_api.g_ret_sts_error) <> fnd_api.g_ret_sts_success) THEN ln_msg_count := fnd_msg_pub.count_msg; IF ln_msg_count > 0 THEN lv_errmsg := substr(fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false), 1, 512); FOR i IN 1 .. (ln_msg_count - 1) LOOP lv_errmsg := lv_errmsg || chr(10) || substr(fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false), 1, 512); END LOOP; fnd_msg_pub.delete_msg(); END IF; dbms_output.put_line(‘------------------Update Error-------------------‘); dbms_output.put_line(‘Error3 :‘ || lv_errmsg); END IF; -- IF lv_return_status = fnd_api.g_ret_sts_success THEN dbms_output.put_line(‘------------------Update Success-------------------‘); DELETE xxwe_mg_supplier_sites_xross x WHERE x.party_site_number_de = lv_party_site_number AND x.org_id_de = ln_org_id; END IF; --END LOOP; dbms_output.put_line(‘------------------Update End-------------------‘); END;
时间: 2024-12-08 03:53:44