Technical Brief On Supplier and Bank Account API in R12
Technical Brief On Supplier and Bank Account API in R12
To help API users:
• Understand the API structure
• Design anonymous block
• Create/update records in Applications through API Debug the common
errors in API execution.
Contents
Overview .........................................................................................................................................................2
Objective .........................................................................................................................................................2
Scope ..............................................................................................................................................................2
Agenda ............................................................................................................................................................3
Designing Anonymous Block...........................................................................................................................3
Sample Anonymous Block ..............................................................................................................................3
Suppliers/Vendors Creation (Primary Data) ...................................................................................................4
Supplier Site ................................................................................................................................................7
Supplier Contact........................................................................................................................................11
Supplier Bank Account ..............................................................................................................................12
Updating existing records using API .............................................................................................................18
Debugging the API issues ..............................................................................................................................21
Enabling Debug at User Level ...................................................................................................................23
References: ...................................................................................................................................................24
Overview
• API stands for Application Programming Interface.
• While APIs themselves are not new, we are now entering a chapter, which opens a whole new
spectrum of possibilities. It helps and acts as a primary data upload in scant of interface import
program When talking about API management, the first thing that comes to mind is a public API,
one that is open for anybody to consume, provided a certain level of registration exists.
• Public APIs : These are designed for customers and Oracle consultants to integrate non-Oracle
systems into Oracle e-Business Suite or to extend the functionality of the base products. Oracle
does not support public APIs unless they are published in a reference manual.
• Private APIs : Private API's are one which Oracle normally using internal, development purpose
only. Details are not provided to anyone outside of the immediate development environment,
nor are they intended for use by anyone outside of the e-Business Suite development
environment.
Objective
• Oracle Applications use APIs to insert and update data in Oracle Applications. APIs are stored
procedures that enable you to insert and update data in Oracle Applications.
• For example, by using APIs, you can insert a Supplier record in Oracle Applications
• Objective: To help understanding technical insight with various Payables Public APIs usage and
debugging techniques. This paper is written with the intention of helping implementers and
those supporting the applications to understand how API works.
Scope
• This document covers the overview of Payables Specific Public APIs with technical structure and
usage.
• It covers Suppliers, Sites, Contact, Bank, Branch and External Bank Account APIs.
• Does not cover Employee type Supplier, automation, customization and legacy data migration.
declare
<Declaration Part>;
begin
<variable assignments>;
<Calling API>;
End;
• For example, for a single supplier, you can buy from several different addresses and send
payments to several different addresses. Most supplier information automatically defaults to all
supplier sites to facilitate supplier site entry. However, you can override these defaults and have
unique information for each site.
• Note : Suppliers can have multiple addresses and each address can be used by an operating unit
through a supplier site record.
• The Oracle eBusiness Suite has a single repository called the Trading Community Architecture
(TCA) to store information about your trading partners.
Parameters: --
Required
BEGIN
--
-- Required
--
--
-- Optional
--
l_vendor_rec.vendor_name_alt := '&Alternate_Name';
l_vendor_rec.start_date_active := sysdate - 1;
-- etc.. --
pos_vendor_pub_pkg.create_vendor(
p_vendor_rec => l_vendor_rec,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
x_vendor_id => l_vendor_id,
x_party_id => l_party_id);
COMMIT;
dbms_output.put_line('return_status: '||l_return_status);
dbms_output.put_line('msg_data: '||l_msg_data); dbms_output.put_line('vendor_id:
'||l_vendor_id); dbms_output.put_line('party_id: '||l_party_id);
END;
/
• For example, city name or branch name. This name is for your reference when selecting sites
from a list of values during purchase order or invoice entry, and will not appear on any
correspondence with the supplier.
• Address: Depending on the address parameter values, an existing address is used or a new
address will be created. Can verify it with the party_site_id.
SQL>@Create_Vendor_Site_API
Parameters:
Create_Vendor_Site_API Script:
set serveroutput on; DECLARE
l_vendor_site_rec ap_vendor_pub_pkg.r_vendor_site_rec_type;
l_return_status VARCHAR2(10); l_msg_count NUMBER;
l_msg_data VARCHAR2(1000); l_vendor_site_id NUMBER;
l_party_site_id NUMBER; l_location_id NUMBER;
BEGIN
--
-- Required
--
SELECT vendor_id
INTO l_vendor_site_rec.vendor_id
FROM ap_suppliers
WHERE vendor_name = '&Supplier_Name';
l_vendor_site_rec.vendor_site_code := '&Supp_Site_Code';
l_vendor_site_rec.address_line1 := '&Address';
l_vendor_site_rec.city := '&City'; l_vendor_site_rec.state
:= '&State'; l_vendor_site_rec.country := '&Country';
select organization_id
INTO l_vendor_site_rec.org_id
from hr_operating_units
where upper(name) = upper('&operating_unit');
-- etc... --
pos_vendor_pub_pkg.create_vendor_site(
p_vendor_site_rec => l_vendor_site_rec,
x_return_status => l_return_status,
x_msg_count => l_msg_count, x_msg_data
=> l_msg_data, x_vendor_site_id =>
l_vendor_site_id, x_party_site_id =>
l_party_site_id, x_location_id =>
l_location_id);
DBMS_OUTPUT.put_line(l_vendor_site_id);
DBMS_OUTPUT.put_line('message count: '||l_msg_count);
DBMS_OUTPUT.put_line('return status: '||l_return_status);
DBMS_OUTPUT.put_line(l_msg_data);
Update Address
SQL>@Create_Vendor_Contact-API.sql Parameters:
vendor_name := 'Supplier API';
org_id := '204';
person_first_name := 'A';
person_last_name := 'XYZ';
BEGIN
--
-- Required
--
SELECT vendor_id
INTO l_vendor_contact_rec.vendor_id
FROM ap_suppliers
WHERE vendor_name = '&Supplier_name';
select organization_id
INTO l_vendor_contact_rec.org_id
from hr_operating_units
where upper(name) = upper('&operating_unit') ;
l_vendor_contact_rec.person_first_name := '&First_Name';
l_vendor_contact_rec.person_last_name := '&Last_Name';
--
-- Optional
--
--l_vendor_contact_rec.phone := '12343210';
--l_vendor_contact_rec.email_address := 'axyz@oracle.com';
-- etc... --
pos_vendor_pub_pkg.create_vendor_contact(
p_vendor_contact_rec => l_vendor_contact_rec,
x_return_status => l_return_status,
x_msg_count => l_msg_count, x_msg_data =>
l_msg_data,
x_vendor_contact_id => l_vendor_contact_id,
x_per_party_id => l_per_party_id,
x_rel_party_id => l_rel_party_id, x_rel_id
=> l_rel_id,
x_org_contact_id => l_org_contact_id,
x_party_site_id => l_party_site_id);
dbms_output.put_line('return_status: '||l_return_status);
dbms_output.put_line('msg_data: '||l_msg_data);
dbms_output.put_line('vendor_contact_id: '||l_vendor_contact_id);
dbms_output.put_line('party_site_id: '||l_party_site_id);
dbms_output.put_line('per_party_id: '||l_per_party_id);
dbms_output.put_line('rel_party_id: '||l_rel_party_id); dbms_output.put_line('rel_id:
'||l_rel_id);
dbms_output.put_line('org_contact_id: '||l_org_contact_id);
• Access the Suppliers: Banking Details page to record the supplier bank accounts that your
suppliers and supplier sites use for payment transactions
• In order to create bank account, a Bank and Branch are required. Either these can be created as
new or use existing ones.
• Using API, if new Bank and Branch are to be created, then need to create the same first before
creating Bank Account.
Parameters:
begin
--Intializing the Message Pub API.
FND_MSG_PUB.initialize;
ce_bank_pub.create_bank
( p_init_msg_list => l_init_msg_list ,
p_country_code => '&Country_Code',
p_bank_name => '&Bank_Name',
p_bank_number => NULL,
p_alternate_bank_name => NULL,
p_short_bank_name => NULL,
p_description => NULL,
p_tax_payer_id => NULL,
p_tax_registration_number => NULL,
p_attribute_category => NULL, p_attribute1
=> NULL, p_attribute2 => NULL,
p_attribute3 => NULL, p_attribute4
=> NULL, p_attribute5 => NULL,
p_attribute6 => NULL, p_attribute7
=> NULL, p_attribute8 => NULL,
p_attribute9 => NULL,
p_attribute10 => NULL,
p_attribute11 => NULL,
p_attribute12 => NULL,
p_attribute13 => NULL,
p_attribute14 => NULL,
p_attribute15 => NULL,
p_attribute16 => NULL,
p_attribute17 => NULL,
p_attribute18 => NULL,
Supplier Bank UI
Parameters:
--Note: Below SQL has been used in API to retrieve Bank id.
--select bank_party_id
--from ce_banks_v
--where upper(bank_name) = upper('&Bank_Name')
begin
--Intializing the Message Pub API.
FND_MSG_PUB.initialize;
select
bank_party_id INTO
l_bank_id
from ce_banks_v
where upper(bank_name) = upper('&Bank_Name');
ce_bank_pub.create_bank_branch
( p_init_msg_list => l_init_msg_list ,
p_bank_id => l_bank_id ,
p_branch_name => '&Branch_Name',
p_branch_number => NULL, p_branch_type
=> NULL, p_alternate_branch_name=> NULL,
p_description => NULL, p_bic
=> NULL,
p_eft_number => NULL,
p_rfc_identifier => NULL,
p_attribute_category=>NULL,
p_attribute1 => NULL,
p_attribute2 => NULL,
p_attribute3 => NULL,
p_attribute4 => NULL,
p_attribute5 => NULL,
p_attribute6 => NULL,
p_attribute7 => NULL,
p_attribute8 => NULL,
p_attribute9 => NULL,
p_attribute10 => NULL,
p_attribute11 => NULL,
p_attribute12 => NULL,
p_attribute13 => NULL,
p_attribute14 => NULL,
p_attribute15 => NULL,
p_attribute16 => NULL,
p_attribute17 => NULL,
p_attribute18 => NULL,
p_attribute19 => NULL,
p_attribute20 => NULL,
p_attribute21 => NULL,
p_attribute22 => NULL,
p_attribute23 => NULL,
p_attribute24 => NULL,
x_branch_id => l_branch_id,
x_return_status => l_return_status
,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data); DBMS_OUTPUT.put_line(l_branch_id);
DBMS_OUTPUT.put_line(l_return_status);
DBMS_OUTPUT.put_line(l_msg_data);
Parameters:
bank_account_num := 609792;
branch_id := 628799; bank_id :=
628797; acct_owner_party_id :=
609792;
country_code := 'US';
bank_account_name := 'ACCOUNT_API';
--Note : Below SQL has been used in API to retrieve Bank, Branch and party id.
--select bank_party_id, branch_party_id
--from ce_bank_branches_v
--where upper(bank_name) = upper('&Bank_name')
--and upper(bank_branch_name) = upper('&Branch_name');
--select party_id
--from ap_suppliers
--where upper(Vendor_name)= upper('&Vendor_Name');--
begin
--Intializing the Message Pub API.
FND_MSG_PUB.initialize;
l_rec.bank_account_num := '&Bank_Account_number';
select bank_party_id,
branch_party_id INTO
l_rec.bank_id,l_rec.branch_id from
ce_bank_branches_v
where upper(bank_name) = upper('&Bank_name') and
upper(bank_branch_name) = upper('&Branch_name');
select party_id
INTO l_rec.acct_owner_party_id from
ap_suppliers
where upper(Vendor_name)= upper('&Vendor_Name');-- party_id = 609792
l_rec.country_code := '&Country_code'; l_rec.bank_account_name :=
'&Bank_account_name';
iby_ext_bankacct_pub.create_ext_bank_acct (
p_api_version => l_api_version,
p_init_msg_list => l_init_msg_list,
p_ext_bank_acct_rec => l_rec,
p_association_level => 'S',
p_supplier_site_id => NULL, p_party_site_id
=> NULL, p_org_id => NULL,
p_org_type => NULL, x_acct_id
=> l_bank_account_id , x_return_status =>
l_return_status, x_msg_count => l_msg_count,
x_msg_data => l_msg_data, x_response
=> l_resp
);
DBMS_OUTPUT.put_line(l_bank_account_id);
DBMS_OUTPUT.put_line(l_return_status);
IF l_msg_count >1 THEN FOR I IN
1..l_msg_count LOOP
dbms_output.put_line(I||'. '||SubStr(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255));
END LOOP;
END IF;
if (l_return_status = 'S') then
commit; end if;
end;
• In this document, updating Supplier and Site using API are described.
Parameters:
Supplier update – UI
• STEP 1:
Enable FND Logging using system administrator responsibility by setting the following profiles at user level.
• STEP 2:
Execute API script in issue
• STEP 3:
Use below SQL from the API script session to get AUDSID:
• STEP 4:
Use the below SQL to collect the debug log messages
set serveroutput on
declare l_resp_id
number; l_user_id
number;
l_vendor_site_rec ap_vendor_pub_pkg.r_vendor_site_rec_type; l_api_version number :=
1; l_init_msg_list VARCHAR2 (30) DEFAULT fnd_api.g_false;
l_validation_level NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL; l_msg_data VARCHAR2
(1000); l_msg_count NUMBER; l_return_status VARCHAR2 (100); l_vendor_site_id NUMBER;
l_party_site_id NUMBER; l_location_id NUMBER; l_user_id NUMBER; l_responsibility_id
NUMBER;
begin
/*Initialize to collect the debug log output starts select
user_id INTO l_user_id
from fnd_user where upper(user_name) = upper('&user_name');
fnd_global.APPS_INITIALIZE (l_user_id,l_responsibility_id,200);
FND_MSG_PUB.initialize;
Initialize to collect the debug log output ends*/
SELECT vendor_id
l_vendor_site_rec.vendor_site_code := '&Supp_Site_Code';
l_vendor_site_rec.address_line1 := '&Address';
l_vendor_site_rec.city := '&City'; l_vendor_site_rec.state
:= '&State'; l_vendor_site_rec.country := '&Country';
select organization_id
INTO l_vendor_site_rec.org_id
from hr_operating_units
where upper(name) = upper('&operating_unit');
AP_VENDOR_PUB_PKG.Create_Vendor_Site
( p_api_version => l_api_version,
p_init_msg_list => l_init_msg_list, p_commit
=> l_init_msg_list,
p_validation_level => l_validation_level, 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,
x_vendor_site_id => l_vendor_site_id, x_party_site_id
=> l_party_site_id,
x_location_id => l_location_id);
DBMS_OUTPUT.put_line(l_vendor_site_id);
DBMS_OUTPUT.put_line(l_msg_count);
DBMS_OUTPUT.put_line(l_return_status);
DBMS_OUTPUT.put_line(l_msg_data);
IF l_msg_count >1 THEN FOR I IN 1..l_msg_count LOOP
dbms_output.put_line(I||'. '||SubStr(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255));
END LOOP; END IF; if (l_return_status = 'S') then commit; end if; end;//*
*********************************************
To get the AUDSID need to run in the session
of the API script:
*********************************************
select sid,audsid from v$session
where audsid = sys_context('USERENV', 'SESSIONID')
*********************************************
Output:
144,31542700
19 31543786
*********************************************
select *
from fnd_log_messages A
where A.user_id='1318' and
A.audsid = '31542700' and
timestamp > sysdate-1 order
by log_sequence desc;
****************** API
Script Output:
******************
5
U
Re-enter.
2. Supplier Site Info is duplicate
3. VENDOR_SITE_CODE is invalid
4. Address/PartySite name already exists for the Supplier. Please re-enter a unique one.
5. Invalid Payee context values. Org parameters exist only with party site and supplier site.
*/