Thursday, May 28, 2015

API to create External Bank Account in Oracle Apps R12 (iby_ext_bankacct_pub.create_ext_bank_acct Sample Script)













Script:
DECLARE
  p_api_version             NUMBER;
  p_init_msg_list           VARCHAR2(200);
  p_ext_bank_acct_rec       apps.iby_ext_bankacct_pub.extbankacct_rec_type;
  x_acct_id                 NUMBER;
  x_return_status           VARCHAR2(200);
  x_msg_count               NUMBER;
  x_msg_data                VARCHAR2(200);
  x_response                apps.iby_fndcpt_common_pub.result_rec_type;
  lv_bank_name              VARCHAR2(100);
  lv_bank_branch            VARCHAR2(100);
  lv_bank_acct_num          VARCHAR2(100);
  lv_bank_acct_name         VARCHAR2(100);
  lv_vendor_name            VARCHAR2(100);
  ln_bank_id                NUMBER;
  ln_branch_id              NUMBER;
  lv_bank_home_country_code VARCHAR2(100);
  ln_acct_owner_party_id    NUMBER;
  l_msg                     VARCHAR2(200);
BEGIN
  -- Initialize apps session
  fnd_global.apps_initialize(1119, 50833, 200);
  mo_global.init('SQLAP');
  fnd_client_info.set_org_context(101);
  lv_bank_name      := 'TEST SUPPLIER BANK';
  lv_bank_branch    := 'TEST BRANCH';
  lv_bank_acct_num  := '123456789';
  lv_bank_acct_name := 'TEST SUPP BANK ACCT';
  lv_vendor_name    := 'TEST SUPPLIER';
  -- Nullify temp variables
  ln_bank_id                := NULL;
  ln_branch_id              := NULL;
  lv_bank_home_country_code := NULL;
  ln_acct_owner_party_id    := NULL;

  -- Get bank details
  BEGIN
    SELECT bank_home_country, bank_party_id, pk_id
      INTO lv_bank_home_country_code, ln_bank_id, ln_branch_id
      FROM ce_bank_branches_v
     WHERE bank_name = lv_bank_name
       AND bank_branch_name = lv_bank_branch;
  EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.put_line('Unable to derive Bank and Branch details' ||
                           SQLERRM);
  END;

  -- Get account owner id
  BEGIN
    SELECT party_id
      INTO ln_acct_owner_party_id
      FROM hz_parties
     WHERE party_name = lv_vendor_name;
  EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.put_line('Unable to derive Account Owner Infor' ||
                           SQLERRM);
  END;

  -- Assign API parameters
  p_api_version                                := 1.0;
  p_init_msg_list                              := fnd_api.g_true;
  p_ext_bank_acct_rec.country_code             := lv_bank_home_country_code;
  p_ext_bank_acct_rec.bank_id                  := ln_bank_id; -- bank_id
  p_ext_bank_acct_rec.branch_id                := ln_branch_id; -- branch_id
  p_ext_bank_acct_rec.acct_owner_party_id      := ln_acct_owner_party_id;
  p_ext_bank_acct_rec.bank_account_name        := lv_bank_acct_name;
  p_ext_bank_acct_rec.bank_account_num         := lv_bank_acct_num;
  p_ext_bank_acct_rec.currency                 := 'USD'; -- bank_acct_currency
  p_ext_bank_acct_rec.start_date               := SYSDATE;
  p_ext_bank_acct_rec.foreign_payment_use_flag := 'Y';

  iby_ext_bankacct_pub.create_ext_bank_acct(p_api_version       => p_api_version,
                                            p_init_msg_list     => p_init_msg_list,
                                            p_ext_bank_acct_rec => p_ext_bank_acct_rec,
                                            x_acct_id           => x_acct_id,
                                            x_return_status     => x_return_status,
                                            x_msg_count         => x_msg_count,
                                            x_msg_data          => x_msg_data,
                                            x_response          => x_response);
  DBMS_OUTPUT.put_line('X_ACCT_ID = ' || x_acct_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);
  DBMS_OUTPUT.put_line('X_RESPONSE.Result_Code = ' ||
                       x_response.result_code);
  DBMS_OUTPUT.put_line('X_RESPONSE.Result_Category = ' ||
                       x_response.result_category);
  DBMS_OUTPUT.put_line('X_RESPONSE.Result_Message = ' ||
                       x_response.result_message);

  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;


TestResults:


0 Responses to “API to create External Bank Account in Oracle Apps R12 (iby_ext_bankacct_pub.create_ext_bank_acct Sample Script)”

Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.