Tuesday, October 17, 2017

How to update Vendor Taxpayer ID (NUM_1099) with API

DECLARE
  lc_return_status            VARCHAR2(2000);
  ln_msg_count                NUMBER;
  ll_msg_data                   LONG;
  Ln_Vendor_Id              NUMBER;
  Ln_Vendor_site_Id      NUMBER;
  ln_message_int             NUMBER;
  Ln_Party_Id                 NUMBER;

  lrec_vendor_rec ap_vendor_pub_pkg.r_vendor_rec_type;
  cursor c_vendors is
  select s.taxpayer_id, s.vendor_id_ora from temporary_suppliers s where s.taxpayer_id is not null and segment1='0'
and s.acc_end_date is null;


BEGIN





  for i in c_vendors
    loop
  Ln_Vendor_Id    := i.vendor_id_ora;

  Lrec_Vendor_Rec.JGZZ_FISCAL_CODE       := i.taxpayer_id;


  ap_vendor_pub_pkg.update_vendor_public( p_api_version => 1,--
  x_return_status => lc_return_status,                 --
  x_msg_count => ln_msg_count,                         --
  x_msg_data => ll_msg_data,                           --
  p_vendor_rec => Lrec_Vendor_Rec,                     --
  p_Vendor_Id => Ln_Vendor_Id);

  IF (lc_return_status <> 'S') THEN
    IF ln_msg_count    >= 1 THEN
      FOR v_index IN 1..ln_msg_count
      LOOP
       fnd_msg_pub.get (p_msg_index => v_index, p_encoded => 'F', p_data => ll_msg_data, p_msg_index_out => ln_message_int );
        Ll_Msg_Data := 'UPDATE_VENDOR '||SUBSTR(Ll_Msg_Data,1,3900);
        dbms_output.put_line('Ll_Msg_Data - '||Ll_Msg_Data );
      END LOOP;

    End If;
  END IF;
  end loop;

EXCEPTION

WHEN OTHERS THEN
  dbms_output.put_line('SQLERRM - '||SQLERRM );
END;

No comments:

Post a Comment