Tuesday 17 September 2019

Api to update the vendor info



DECLARE

  p_api_version          NUMBER;
 
  p_init_msg_list        VARCHAR2(200);

  p_commit               VARCHAR2(200);

  p_validation_level     NUMBER;

  x_return_status        VARCHAR2(200);

  x_msg_count            NUMBER;

  x_msg_data             VARCHAR2(200);

  lr_vendor_rec          apps.ap_vendor_pub_pkg.r_vendor_rec_type;

  lr_existing_vendor_rec ap_suppliers%ROWTYPE;

  l_msg                  VARCHAR2(200);

  p_vendor_id            NUMBER;

BEGIN



  -- Initialize apps session

  fnd_global.apps_initialize(26365, 54488, 200);

  mo_global.init('SQLAP');

  fnd_client_info.set_org_context(XXX);



  -- Assign Basic Values

  p_api_version      := 1.0;

  p_init_msg_list    := fnd_api.g_true;

  p_commit           := fnd_api.g_true;

  p_validation_level := fnd_api.g_valid_level_full;

  p_vendor_id        := XXXX;



  -- gather vendor details

  BEGIN

    SELECT *

      INTO lr_existing_vendor_rec

      FROM ap_suppliers asa

     WHERE asa.vendor_id = p_vendor_id;

  EXCEPTION

    WHEN OTHERS THEN

      DBMS_OUTPUT.put_line('Unable to derive the supplier  information for vendor id:' ||

                           p_vendor_id);

  END;



  --Deactivate Vendor

  lr_vendor_rec.vendor_id       := lr_existing_vendor_rec.vendor_id;

  lr_vendor_rec.vendor_type_lookup_code := 'VENDOR';

  --lr_vendor_rec.enabled_flag    := 'N';



  ap_vendor_pub_pkg.update_vendor(p_api_version      => p_api_version,

                                  p_init_msg_list    => p_init_msg_list,

                                  p_commit           => p_commit,

                                  p_validation_level => p_validation_level,

                                  x_return_status    => x_return_status,

                                  x_msg_count        => x_msg_count,

                                  x_msg_data         => x_msg_data,

                                  p_vendor_rec       => lr_vendor_rec,

                                  p_vendor_id        => p_vendor_id);

                               

  DBMS_OUTPUT.put_line('X_RETURN_STATUS = ' || x_return_status);

  DBMS_OUTPUT.put_line('X_MSG_COUNT = ' || x_msg_count);

  DBMS_OUTPUT.put_line('X_MSG_DATA = ' || x_msg_data);



  IF (x_return_status <> fnd_api.g_ret_sts_success) THEN

    FOR i IN 1 .. fnd_msg_pub.count_msg LOOP

      l_msg := fnd_msg_pub.get(p_msg_index => i,

                               p_encoded   => fnd_api.g_false);

      DBMS_OUTPUT.put_line('The API call failed with error ' || l_msg);

    END LOOP;

  ELSE

    DBMS_OUTPUT.put_line('The API call ended with SUCESSS status');

  END IF;

END;

/

3 comments:

  1. Very interesting blog Thank you for sharing such a nice and interesting blog and really very helpful article

    Oracle Fusion HCM Online Training

    ReplyDelete
  2. I see here we can enter just one vendor_id,what if we have over a 1000 vendor id to update??
    p_vendor_id := XXXX;

    ReplyDelete