供应商地点信息更新

例:更新供应商地点可采购flag
DECLARE
   l_api_version CONSTANT NUMBER := 1;
   l_msg_data        VARCHAR2(2000);
   l_msg             VARCHAR2(4000);
   l_msg_count       NUMBER;
   l_return_status   VARCHAR2(1);
   l_method_code     VARCHAR2(50);
   l_vendor_site_rec ap_vendor_pub_pkg.r_vendor_site_rec_type;
   CURSOR cur_vendor IS
      SELECT vendor.vendor_id,
             vendor_site.vendor_site_id,
             vendor_site.org_id
        FROM ap_suppliers vendor, ap_supplier_sites_all vendor_site
       WHERE vendor.vendor_id = vendor_site.vendor_id
         AND vendor.vendor_type_lookup_code = 'EMPLOYEE';

BEGIN
   fnd_global.apps_initialize(user_id      => 1170,
                              resp_id      => 50717,
                              resp_appl_id => 20005);
   --mo_global.set_policy_context(p_access_mode => 'S', p_org_id => 83);
   --fnd_profile.PUT(NAME =>'MFG_ORGANIZATION_ID' ,VAL => 83);
   FOR rec_vendor IN cur_vendor LOOP
      mo_global.set_policy_context(p_access_mode => 'S',
                                   p_org_id      => rec_vendor.org_id);
      l_vendor_site_rec.purchasing_site_flag := 'N';
      l_vendor_site_rec.vendor_id            := rec_vendor.vendor_id;
      l_vendor_site_rec.vendor_site_id       := rec_vendor.vendor_site_id;
      BEGIN
         ap_vendor_pub_pkg.update_vendor_site(p_api_version      => l_api_version,
                                              p_init_msg_list    => fnd_api.g_false,
                                              p_commit           => fnd_api.g_false,
                                              p_validation_level => fnd_api.g_valid_level_full,
                                              x_return_status    => l_return_status,
                                              x_msg_count        => l_msg_count,
                                              x_msg_data         => l_msg_data,
                                              p_vendor_site_rec  => l_vendor_site_rec,
                                              p_vendor_site_id   => rec_vendor.vendor_site_id,
                                              p_calling_prog     => 'NOT ISETUP');
      
      EXCEPTION
         WHEN OTHERS THEN
            dbms_output.put_line('ERROR:' || SQLERRM);
      END;
      --COMMIT;
      --dbms_output.put_line('o_return_status:'||o_return_status);
      IF l_return_status <> fnd_api.g_ret_sts_success THEN
      
         FOR i IN 1 .. l_msg_count LOOP
            l_msg_data := fnd_msg_pub.get(p_msg_index => i,
                                          p_encoded   => 'F');
            dbms_output.put_line('l_msg_data:' || l_msg_data);
         END LOOP; --FOR i IN 1 .. x_msg_count LOOP    
         dbms_output.put_line('x_return_status:' || l_return_status);
      
         dbms_output.put_line('l_msg_data:' || l_msg_data);
         RAISE fnd_api.g_exc_unexpected_error;
         -- o_msg_data := l_msg_data;
      
      ELSE
         NULL;
         --dbms_output.put_line('S');
      END IF;
   
   END LOOP; -- FOR REC_VENDOR IN cur_vendor LOOP
END;

你可能感兴趣的:(详解EBS接口开发系列)