Wednesday, February 17, 2016

Update Supplier Site Information using API


CREATE OR REPLACE PROCEDURE xx_update_supplier_site AS
  lr_vendor_site_rec apps.ap_vendor_pub_pkg.r_vendor_site_rec_type;
  p_vendor_site_id   NUMBER;
  x_msg_data         VARCHAR2(1000);
  x_msg_count        NUMBER;
  p_count            NUMBER;
  x_return_status    VARCHAR2(10);
  lc_msg_data        VARCHAR2(4000);

-- Modify cursor as per your requirement to select Vendor and site
  CURSOR lcu_head IS
    SELECT aps.vendor_id,
           apss.vendor_site_id,
           apss.org_id           
      FROM ap_suppliers aps, ap_supplier_sites_all apss
     WHERE 1 = 1      
       AND aps.vendor_id = apss.vendor_id     
       --AND aps.vendor_id = 10284 
       ;

BEGIN
  fnd_global.apps_initialize(1110, 50747, 200);
  mo_global.init('SQLAP');
  fnd_client_info.set_org_context(83);

  FOR i IN lcu_head LOOP
   
      p_vendor_site_id := NULL;
      x_msg_data       := NULL;
      x_msg_count      := NULL;
      p_count          := NULL;
      x_return_status  := NULL;
      lc_msg_data      := NULL;
      -- Assign Vendor Site Details      
      lr_vendor_site_rec.last_update_date := SYSDATE;
      lr_vendor_site_rec.last_updated_by  := 1110;
      lr_vendor_site_rec.vendor_id        := i.vendor_id;
      lr_vendor_site_rec.org_id           := i.org_id;   
      
      --lr_vendor_site_rec.pay_group_lookup_code := 'PAY GROUP';
     
   
      ap_vendor_pub_pkg.update_vendor_site(p_api_version      => 1.0
                                           x_return_status    => x_return_status,
                                           x_msg_count        => x_msg_count,
                                           x_msg_data         => x_msg_data,
                                           p_vendor_site_rec  => lr_vendor_site_rec,
                                           p_vendor_site_id   => i.vendor_site_id
                                           );
   
      Commit;
      IF x_return_status = 'S' THEN
        dbms_output.put_line('Success ' || x_return_status);
      ELSE
        dbms_output.put_line('Failed ' || x_return_status);
        IF (x_msg_count = 1) THEN
          dbms_output.put_line('x_msg_data ' || x_msg_data);
          lc_msg_data := x_msg_data;
        ELSIF (x_msg_count > 1) THEN
          LOOP
            p_count    := p_count + 1;
            x_msg_data := fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false);
            IF (x_msg_data IS NULL) THEN
              EXIT;
            END IF;
            dbms_output.put_line('Message' || p_count || ' ---' || x_msg_data);
            lc_msg_data := lc_msg_data || ' ' || x_msg_data;
          END LOOP;
        END IF;
     
      END IF;
    
 
  END LOOP;
END;


No comments: