Sie sind auf Seite 1von 222

Goal: How to create customer in TCA via API

------------------------------------- 1. Setup the Org_id


-----------------------------------exec dbms_application_info.set_client_info('&Your_Org_Id');
------------------------------------- 2. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 3. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'Acc_test1';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'Fenner Test';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);

dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
------------------------------------- 4. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Test';
p_location_rec.city := 'san Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
------------------------------------- 5. Create a party site
-party_id (from step 3)
-location_id (from step 4)
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);

x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 15184;
p_party_site_rec.location_id := 3270;
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
------------------------------------- 6. Create an account site
-- cust_account_id (from step 2)
-- party_site_id (from step 5).
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 12722;
p_cust_acct_site_rec.party_site_id := 12164;
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');

dbms_output.put_line('Output information ....');


dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
-------------------------------------------- 7. Create an account site use 'BILL_TO'
-- cust_acct_site_id (from step 6)
------------------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 9369;
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
commit;\
***************************************************************************
************************************************
***************************************************************************
************************************************

Goal: How to create a PERSON customer via TCA API ?


Fact: Oracle Trading Community 11.5.7
Fix: Example to create a PERSON customer via API in TCA.
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'TPERSON01';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_person_rec.person_first_name := 'FennerT1';
p_person_rec.person_last_name := 'GiraldoT1';
p_person_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_person_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 7645
x_account_number: 3951
x_party_id: 7989
x_party_number: 6333
x_profile_id: 4742
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address1';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 5126
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 7989; --<<value for party_id from step 2>
p_party_site_rec.location_id := 5126; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');

END;
***************************
Output information ....
x_party_site_id: 6670
x_party_site_number: 5303
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7645; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 6670; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 6583
x_return_status: S
x_msg_count: 0
x_msg_data:

***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 6583; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 6637
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address
commit;

*/

***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: How to create a cust_account via TCA API to an existing PARTY (PERSON
Customer)?
Fact: Oracle Trading Community 11.5.4
Fix: Example of how to create a cust_account via TCA API to an existing
PARTY (PERSON Customer)?
How to create a cust_account via TCA API to an existing PARTY (PERSON
Customer)?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'TPERSONFENNER02';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_person_rec.party_rec.party_id := 7989; --<< party_id that already exist
p_person_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_person_rec,

p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 7649
x_account_number: 3954
x_party_id: 7989
x_party_number:
x_profile_id:
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address2';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';

p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 5128
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 7989; --<<value for party_id from step 2>
p_party_site_rec.location_id := 5128; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 6672
x_party_site_number: 5305
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7649; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 6672; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');

END;
***************************
Output information ....
x_cust_acct_site_id: 6585
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 6585; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 6639

x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to create two BILL_TO sites for the same customer via TCA API
-----------------------------------------------------------------Example:
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'ACC01_01_02';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory
p_organization_rec.organization_name := 'CUSTAPI2';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';

-- is not

hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address2a';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,

x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := XX; --<<value for party_id from step 2>
p_party_site_rec.location_id := XX; --<<value for location_id from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
------------------------------------

DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := XX; --<<value for cust_account_id
you get from step 2>
p_cust_acct_site_rec.party_site_id := XX; --<<value for party_site_id from
step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO' (first BILL_TO)
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',

'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/* END address

*/

commit;
------------------------------------- 7. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address2b';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');

END;
------------------------------------- 8. Create a party site using party_id from step 2 and location_id from
step 7
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := XX; --<<value for party_id from step 2>
p_party_site_rec.location_id := XX; --<<value for location_id from step 7>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
------------------------------------- 9. Create an account site using cust_account_id from step 2 and
party_site_id from step 8.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := XX; --<<value for cust_account_id
you get from step 2>
p_cust_acct_site_rec.party_site_id := XX; --<<value for party_site_id from

step 8>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
------------------------------------- 10. Create an account site use using cust_acct_site_id from step 9 and
site_use_code='BILL_TO' (Second BILL_TO)
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 9>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to create BILL_TO and SHIP_TO sites via TCA API
--------------------------------------------------Example:
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'ACC01_01_03';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory
p_organization_rec.organization_name := 'CUSTAPI3';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';

-- is not

hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address3a';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := XX; --<<value for party_id from step 2>
p_party_site_rec.location_id := XX; --<<value for location_id from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;

x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := XX; --<<value for cust_account_id
you get from step 2>
p_cust_acct_site_rec.party_site_id := XX; --<<value for party_site_id from
step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,

x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/* END address

*/

commit;
------------------------------------- 7. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address3b';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;

------------------------------------- 8. Create a party site using party_idfrom step 2 and location_id from
step 7
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := XX; --<<value for party_id from step 2>
p_party_site_rec.location_id := XX; --<<value for location_id from step 7>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
------------------------------------- 9. Create an account site using cust_account_id from step 2 and
party_site_id from step 8.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := XX; --<<value for cust_account_id
you get from step 2>
p_cust_acct_site_rec.party_site_id := XX; --<<value for party_site_id from
step 8>
p_cust_acct_site_rec.language := 'US';

p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
------------------------------------- 10. Create an account site use using cust_acct_site_id from step 9 and
site_use_code='SHIP_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 9>
p_cust_site_use_rec.site_use_code := 'SHIP_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);

dbms_output.put_line('***************************');
END;
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to create a customer (ORGANIZATION) via TCA API with account_number off
and party_number on?
Suppose:
-. Automatic customer numbering is not checked on System Options.
-. HZ: Generate Party Number in Yes on Profile Options Form.
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'FennerAccN';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_cust_account_rec.account_number := 'FennerAccN';
p_organization_rec.organization_name := 'FennerAccN';

p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 12189
x_account_number: FennerAccN
x_party_id: 17602
x_party_number: 16047
x_profile_id: 8081
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);

x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address1';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 1000002012555
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 17602; --<<value for party_id from step 2>
p_party_site_rec.location_id := 1000002012555; --<<value for location_id
from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',

p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 12419
x_party_site_number: 10872
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 12189; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 12419; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 10061
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 10061; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');

END;
***************************
Output information ....
x_site_use_id: 10359
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How To Create A Contact At Customer Level Without Phone Via TCA API
---------------------------------------------------------------Example:
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'ACC01_01_04';

p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory

-- is not

p_organization_rec.organization_name := 'CUSTAPI4';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address4';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(

'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := XX; --<<value for party_id from step 2>
p_party_site_rec.location_id := XX; --<<value for location_id from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := XX; --<<value for cust_account_id
you get from step 2>
p_cust_acct_site_rec.party_site_id := XX; --<<value for party_site_id from
step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';

hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/* END address

*/

commit;
/* BEGIN contact to an organization */
------------------------------------- 7. Create a definition contact
-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'Fennerc4';
p_create_person_rec.person_last_name := 'Giraldoc4';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;

------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_org_contact_rec.department_code := 'ACCOUNTING';
p_org_contact_rec.job_title := 'ACCOUNTS OFFICER';
p_org_contact_rec.decision_maker_flag := 'Y';
p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := XX; --<<value for party_id
from step 7>
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := XX; --<<value for party_id
from step 2>
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,
x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');
END;

------------------------------------- 9. Create a contact using party_id you get 8 and cust_account_id from
step 2
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := XX; --<<value for party_id from step 8>
p_cr_cust_acc_role_rec.cust_account_id := XX; --<<value for cust_account_id
from step 2>
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(
'T',
p_cr_cust_acc_role_rec,
x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
END;
/* END contact */
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How To Create A Contact At Address Level Without Phone Via TCA API
Example:
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'ACC01_01_06';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory
p_organization_rec.organization_name := 'CUSTAPI6';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';

-- is not

hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address6';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := XX; --<<value for party_id from step 2>
p_party_site_rec.location_id := XX; --<<value for location_id from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE

p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := XX; --<<value for cust_account_id
you get from step 2>
p_cust_acct_site_rec.party_site_id := XX; --<<value for party_site_id from
step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',

x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/* END address

*/

commit;
/* BEGIN contact to an address */
------------------------------------- 7. Create a contact definition
-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'Fennerc6';
p_create_person_rec.person_last_name := 'Giraldoc6';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_org_contact_rec.department_code := 'ACCOUNTING';
p_org_contact_rec.job_title := 'ACCOUNTS OFFICER';
p_org_contact_rec.decision_maker_flag := 'Y';
p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := XX; --<<value for party_id
from step 7>
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := XX; --<<value for party_id
from step 2>
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,
x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);

dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');
END;
------------------------------------- 9. Create a contact using party_id you get 8, cust_account_id from step
2 and cust_acct_site_id from step 5
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := XX; --<<value for party_id from step 8>
p_cr_cust_acc_role_rec.cust_account_id := XX; --<<value for cust_account_id
from step 2>
p_cr_cust_acc_role_rec.cust_acct_site_id := XX; --<<value for
cust_acct_site_id from step 5>
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(
'T',
p_cr_cust_acc_role_rec,
x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
END;

/* END contact */
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How To Create A Contact At Address Level Without Phone Via TCA API using
conditions like:
HZ: Generate Contact Number
: No
Fix
How To Create A Contact At Address Level Without Phone Via TCA API using
conditions like:
Profiles Options:
HZ: Generate Contact Number
: No
HZ: Generate Party Number
: No
HZ: Generate Party Site Number : No
system Options Form has values:
Automatic Site Numbering
: NULL
Automatic Customer Numbering : NULL
Example:
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('290');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);

x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'CHEXAM001';
p_cust_account_rec.account_number := 'CHEXAM001';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory

-- is not

p_organization_rec.organization_name := 'CHEXAM001';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.party_rec.party_number := '0001122';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;

***************************
Output information ....
x_cust_account_id: 2571
x_account_number: CHEXAM001
x_party_id: 27093
x_party_number: 0001122
x_profile_id: 2123
x_return_status: S

x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address0001aa';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 2474
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE

p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 27093; --<<value for party_id from step 2>
p_party_site_rec.location_id := 2474; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
p_party_site_rec.party_site_number := '0003344';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 2944
x_party_site_number: 0003344
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 2571; --<<value for

cust_account_id you get from step 2>


p_cust_acct_site_rec.party_site_id := 2944; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 2943
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 2943; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
p_cust_site_use_rec.location := 'LOC_XXXSS';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,

'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/* END address */
***************************
Output information ....
x_site_use_id: 2963
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************

commit;
/* BEGIN contact to an address */
------------------------------------- 7. Create a contact definition
-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'FennerDDD';
p_create_person_rec.person_last_name := 'GiraldoDDD';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
p_create_person_rec.party_rec.party_number := '0001255';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,

x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_party_id: 27094
x_party_number: 0001255
x_profile_id: 25186
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_org_contact_rec.department_code := 'ACCOUNTING';
p_org_contact_rec.job_title := 'APC';
p_org_contact_rec.decision_maker_flag := 'Y';
p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := 27094; --<<value for party_id
from step 7>
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := 27093; --<<value for party_id
from step 2>
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';

p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
p_org_contact_rec.party_rel_rec.party_rec.party_number := '0012277';
p_org_contact_rec.contact_NUMber := '0012266';
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,
x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');
END;
***************************
Output information ....
x_org_contact_id: 1906
x_party_rel_id: 1908
x_party_id: 27095
x_party_number: 0012277
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 9. Create a contact using party_id you get 8, cust_account_id from step
2 and cust_acct_site_id from step 5
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);

BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := 27095; --<<value for party_id from step
8>
p_cr_cust_acc_role_rec.cust_account_id := 2571; --<<value for
cust_account_id from step 2>
p_cr_cust_acc_role_rec.cust_acct_site_id := 2943; --<<value for
cust_acct_site_id from step 5>
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(
'T',
p_cr_cust_acc_role_rec,
x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
END;
***************************
Output information ....
x_cust_account_role_id: 1906
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* END contact */
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************

How To Create A Contact At Customer Level With Phone Via TCA API
---------------------------------------------------------------Example of How To Add A Contact At Customer Level With Phone Via TCA API
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'Fenner_01';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'Fenner_01';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 10033
x_account_number: 2441
x_party_id: 11337
x_party_number: 20413
x_profile_id: 3231
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address4';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');

dbms_output.put_line('Output information ....');


dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 21581
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11337; --<<value for party_id from step 2>
p_party_site_rec.location_id := 21581; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');

END;
/
***************************
Output information ....
x_party_site_id: 5967
x_party_site_number: 4476
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 10033; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 5967; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4672
x_return_status: S
x_msg_count: 0
x_msg_data:

***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4672; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
/* END address

*/

commit;
/* BEGIN contact to an organization */
------------------------------------- 7. Create a definition contact
-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;

x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'FENNERCTFN_01';
p_create_person_rec.person_last_name := 'FENNERCTLN_01';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_party_id: 11338
x_party_number: 20414
x_profile_id: 8323
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);

x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
--p_org_contact_rec.department_code := 'ACCOUNTING';
--p_org_contact_rec.job_title := 'ACCOUNTS OFFICER';
--p_org_contact_rec.decision_maker_flag := 'Y';
--p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := 11338; --<<value for party_id
from step 7>
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := 11337; --<<value for party_id
from step 2>
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,
x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');
END;
/
***************************
Output information ....
x_org_contact_id: 4566
x_party_rel_id: 5789
x_party_id: 11339
x_party_number: 20415
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 9. Create a contact using party_id you get in step 8 and cust_account_id
from step 2
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := 11339; --<<value for party_id from step
8>
p_cr_cust_acc_role_rec.cust_account_id := 10033; --<<value for
cust_account_id from step 2>
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(
'T',
p_cr_cust_acc_role_rec,
x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_role_id: 4556
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* END contact */
commit;

/* Begin phone */
------------------------------------------------------- 10. Create phon using party_id you get in atep 8
-----------------------------------------------------DECLARE
p_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
p_phone_rec HZ_CONTACT_POINT_V2PUB.phone_rec_type;
p_edi_rec_type HZ_CONTACT_POINT_V2PUB.edi_rec_type;
p_email_rec_type HZ_CONTACT_POINT_V2PUB.email_rec_type;
p_telex_rec_type HZ_CONTACT_POINT_V2PUB.telex_rec_type;
p_web_rec_type HZ_CONTACT_POINT_V2PUB.web_rec_type;
x_contact_point_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_contact_point_rec.contact_point_type := 'PHONE';
p_contact_point_rec.owner_table_name := 'HZ_PARTIES';
p_contact_point_rec.owner_table_id := 11339; --<value for party_id from
step 8>
p_contact_point_rec.created_by_module := 'TCAPI_EXAMPLE';
p_phone_rec.Phone_number := '407';
p_phone_rec.phone_line_type := 'GEN';
HZ_CONTACT_POINT_V2PUB.create_contact_point (
'T',
p_contact_point_rec,
p_edi_rec_type,
p_email_rec_type,
p_phone_rec,
p_telex_rec_type,
p_web_rec_type,
x_contact_point_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_contact_point_id: '||x_contact_point_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('***************************');
END;
/
***************************
Output information ....
x_contact_point_id: 8141
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
Example of How To Create A Contact At Address Level With Phone Via TCA API
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'FennerAPIc001';

p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory

-- is not

p_organization_rec.organization_name := 'FennerAPIc001';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4251
x_account_number: 2029
x_party_id: 11204
x_party_number: 8739
x_profile_id: 2939
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location

-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'FennerAPIc001Add6';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 10080
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11204; --<<value for party_id from step 2>

p_party_site_rec.location_id := 10080; --<<value for location_id from step


3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5635
x_party_site_number: 4144
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4251; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 5635; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',

p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4280
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4280; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');

dbms_output.put_line('Output information ....');


dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4598
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
/* BEGIN contact to an address */
------------------------------------- 7. Create a contact definition
-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'FNFennerC001';
p_create_person_rec.person_last_name := 'LNGiraldoC001';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');

dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_party_id: 11205
x_party_number: 8740
x_profile_id: 8262
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_org_contact_rec.department_code := 'ACCOUNTING';
p_org_contact_rec.job_title := 'ACCOUNTS OFFICER';
p_org_contact_rec.decision_maker_flag := 'Y';
p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := 11205; --<<value for party_id
from step 7>
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := 11204; --<<value for party_id
from step 2>
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,

x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');
END;
/
***************************
Output information ....
x_org_contact_id: 4746
x_party_rel_id: 5869
x_party_id: 11206
x_party_number: 8741
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 9. Create a contact using party_id you get 8, cust_account_id from step
2 and cust_acct_site_id from step 5
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := 11206; --<<value for party_id from step
8>
p_cr_cust_acc_role_rec.cust_account_id := 4251; --<<value for

cust_account_id from step 2>


p_cr_cust_acc_role_rec.cust_acct_site_id := 4280; --<<value for
cust_acct_site_id from step 5>
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(
'T',
p_cr_cust_acc_role_rec,
x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_role_id: 4516
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* END contact */
commit;

/* Begin phone */
------------------------------------------------------- 10. Create phone using party_id you get in step 8
-----------------------------------------------------DECLARE
p_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
p_phone_rec HZ_CONTACT_POINT_V2PUB.phone_rec_type;
p_edi_rec_type HZ_CONTACT_POINT_V2PUB.edi_rec_type;
p_email_rec_type HZ_CONTACT_POINT_V2PUB.email_rec_type;
p_telex_rec_type HZ_CONTACT_POINT_V2PUB.telex_rec_type;
p_web_rec_type HZ_CONTACT_POINT_V2PUB.web_rec_type;

x_contact_point_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_contact_point_rec.contact_point_type := 'PHONE';
p_contact_point_rec.owner_table_name := 'HZ_PARTIES';
p_contact_point_rec.owner_table_id := 11206; --<value for party_id from
step 8>
p_contact_point_rec.created_by_module := 'TCAPI_EXAMPLE';
p_phone_rec.Phone_number := '4075555';
p_phone_rec.phone_line_type := 'GEN';
HZ_CONTACT_POINT_V2PUB.create_contact_point (
'T',
p_contact_point_rec,
p_edi_rec_type,
p_email_rec_type,
p_phone_rec,
p_telex_rec_type,
p_web_rec_type,
x_contact_point_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_contact_point_id: '||x_contact_point_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('***************************');
END;
/
***************************
Output information ....
x_contact_point_id: 8979
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
***************************************************************************
************************************************
***************************************************************************

************************************************
How To Create A Phone at Address level via TCA API
Example:
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'FennerAPIc001';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory
p_organization_rec.organization_name := 'FennerAPIc001';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,

-- is not

x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4251
x_account_number: 2029
x_party_id: 11204
x_party_number: 8739
x_profile_id: 2939
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'FennerAPIc001Add6';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,

x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 10080
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11204; --<<value for party_id from step 2>
p_party_site_rec.location_id := 10080; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5635
x_party_site_number: 4144
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4251; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 5635; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4280

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4280; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4598
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
------------------------------------------------------- 7. Create phone using party_site_id you get in step 4
-----------------------------------------------------DECLARE
p_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
p_phone_rec HZ_CONTACT_POINT_V2PUB.phone_rec_type;
p_edi_rec_type HZ_CONTACT_POINT_V2PUB.edi_rec_type;
p_email_rec_type HZ_CONTACT_POINT_V2PUB.email_rec_type;
p_telex_rec_type HZ_CONTACT_POINT_V2PUB.telex_rec_type;
p_web_rec_type HZ_CONTACT_POINT_V2PUB.web_rec_type;
x_contact_point_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_contact_point_rec.contact_point_type := 'PHONE';
p_contact_point_rec.owner_table_name := 'HZ_PARTY_SITES';
p_contact_point_rec.owner_table_id := 5635; --<value for party_site_id from
step 4>
p_contact_point_rec.created_by_module := 'TCAPI_EXAMPLE';
p_phone_rec.Phone_number := '40755556';
p_phone_rec.phone_line_type := 'GEN';
HZ_CONTACT_POINT_V2PUB.create_contact_point (
'T',
p_contact_point_rec,
p_edi_rec_type,
p_email_rec_type,
p_phone_rec,
p_telex_rec_type,
p_web_rec_type,
x_contact_point_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_contact_point_id: '||x_contact_point_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('***************************');
END;

***************************
Output information ....
x_contact_point_id: 8980
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
goal: How to add a new BILL_TO Address to an existing customer via TCA API
fact: Oracle Trading Community 11.5.4

fix:
------------------------------------- 1a. Setup the Org_id
-- In this example the Org_id = 204
----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-- !! IMPORTANT !! run this command
-----------------------------------set serveroutput on
------------------------------------- 2. search the party_id that you want
-to add the new bill_to
------------------------------------ you can use Help\diagnostics\examine:
-- from the apps menu in the customer record.
In this example the party_id = 15410
------------------------------------- 3. search the cust_account_id for
-- this party_id
-----------------------------------

select
CUST_ACCOUNT_ID
,PARTY_ID
from
hz_cust_accounts
where
party_id = 15410;
-- Example's result
CUST_ACCOUNT_ID
PARTY_ID
--------------- ---------12901
15410
------------------------------------- 4. Create a physical location
--- Take present the output in special: x_location_id
------------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Test';
p_location_rec.city := 'san Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_location_id: '||x_location_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);
END;
/
------------------------------------- 5. Create a party site using party_id you get from step 2
-and location_id from step 4
--

-- Take present the output in special: x_party_site_id


--- in this example :
-- party_id = 15410
-- and x_location_id: 5413
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 15410; --< !!!!! Here the PARTY_ID !!!!
p_party_site_rec.location_id := 5413; --< !!!!! Here the LOCATION_ID !!
!!
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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);
END;
/
------------------------------------- 6. Create an account site using account_id you get from step 3
-and party_site_id from step 5.
--- Take present the output in special: x_cust_acct_site_id
--- in this example :
-- cust_account_id = 12901
-- party_site_id = 14503
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN

p_cust_acct_site_rec.cust_account_id := 12901; --< !!!! Here the


CUST_ACCOUNT_ID !!!!
p_cust_acct_site_rec.party_site_id := 14503; --< !!!! Here the
PARTY_SITE_ID !!!.
!
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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);
END;
/
------------------------------------- 7. Create an account site use using cust_acct_site_id you
-get from step 5
--- In this example:
-- x_cust_acct_site_id: 10908
-- and site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 10908; --< !!! Here the
CUST_ACCOUNT_SITE_ID !!!
p_cust_site_use_rec.site_use_code := 'BILL_TO'; --< !!! Here the
BILL_TO !!!
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,

x_msg_data);
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
END;
/
-- remember commit
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: How to Create a customer (organization) with dunning info = N via TCA
API?
Fact: Oracle Trading Community 11.5.4
Fix: Example of how to insert a customer (organization) with dunning info =
N via TCA API?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'TORGBOB03';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';

p_organization_rec.organization_name := 'ORGBOBFennerT3';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_customer_profile_rec.cust_account_id := ;
p_customer_profile_rec.dunning_letters := 'N' ;
p_customer_profile_rec.dunning_letter_set_id := FND_API.G_MISS_NUM;
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 7691
x_account_number: 3997
x_party_id: 8035
x_party_number: 6379
x_profile_id: 4772
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------

-- 3. Create a physical location


-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address3';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 5166
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 8035; --<<value for party_id from step 2>

p_party_site_rec.location_id := 5166; --<<value for location_id from step


3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 6710
x_party_site_number: 5343
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7691; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 6710; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',

p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 6623
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 6623; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');

dbms_output.put_line('Output information ....');


dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 6677
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: How to Create a customer (organization) with dunning info = Y via TCA
API?
Fact: Oracle Trading Community 11.5.4
Fix: Example of how to Create a customer (organization) with dunning info =
Y via TCA API?
How to insert a customer (organization) with dunning info = Y via TCA API?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);

x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'TORGBOB04';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'ORGBOBFennerT4';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_customer_profile_rec.cust_account_id := ;
p_customer_profile_rec.dunning_letters := 'Y' ;
p_customer_profile_rec.dunning_letter_set_id := 1;
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 7692
x_account_number: 3998
x_party_id: 8036
x_party_number: 6380

x_profile_id: 4773
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address4';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 5167
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id
step 3

from step 2 and location_id from

-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 8036; --<<value for party_id from step 2>
p_party_site_rec.location_id := 5167; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 6711
x_party_site_number: 5344
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);

x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7692; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 6711; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 6624
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 6624; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',

p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 6678
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to Create an (ORGANIZATION) customer using Customer Information
Descriptive Flexfield via TCA API?
Goal: How to Create an (ORGANIZATION) customer using Customer Information
Descriptive Flexfield via TCA API?
Fact: Oracle Trading Community 11.5.7
Fix: Example of How to Create an (ORGANIZATION) customer using Customer
Information Descriptive Flexfield via TCA API?

Supposed that following situation:


1. The ORG_ID is 204.
2. In Descriptive Flexfield Form:

NAV:\Setup\Financials\Flexfields\Descriptive\Segments
.- Descriptive Flexfield title "Customer Information" is enable
.- In the Context field zone the displayed field is Checked
.- In the Context field Values zone the code is "Add Cust Info"
.- In the Segments summary Form (Button segments) are activated
Attribute1 (30 characters)
Attribute2 (30 characters)
Attribute3 (30 characters)
------------------------------------- 1. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 2. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 3. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'EX Flex Customer';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'EX Flex Customer';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
------------------------------------------------ Data for "Customer Information" Flexfield
----------------------------------------------p_cust_account_rec.attribute_category := 'Add Cust Info';
p_cust_account_rec.attribute1 := 'Customer Info1';
p_cust_account_rec.attribute2 := 'Customer Info2';
p_cust_account_rec.attribute3 := 'Customer Info3';
----------------------------------------------hz_cust_account_v2pub.create_cust_account(

'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4431
x_account_number: 2183
x_party_id: 11163
x_party_number: 8718
x_profile_id: 2934
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Test';

p_location_rec.city := 'san Mateo';


p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 10277
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create a party site
-party_id (from step 3)
-location_id (from step 4)
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11163;
p_party_site_rec.location_id := 10277;
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,

x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5690
x_party_site_number: 4199
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site
-- cust_account_id (from step 2)
-- party_site_id (from step 5).
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4431;
p_cust_acct_site_rec.party_site_id := 5690; -- 5689
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');

dbms_output.put_line('Output information ....');


dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4409
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
-------------------------------------------- 7. Create an account site use 'BILL_TO'
-- cust_acct_site_id (from step 6)
------------------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4409; -- 4405
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);

dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4751
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to Create an (ORGANIZATION) customer using Address Information
Descriptive Flexfield via TCA API?
Goal: How to Create an (ORGANIZATION) customer using Address Information
Descriptive Flexfield via TCA API?
Fact: Oracle Trading Community 11.5.7
Fix: Example of How to Create an (ORGANIZATION) customer using Address
Information Descriptive Flexfield via TCA API?

Supposed that following situation:


1. The ORG_ID is 204.
2. In Descriptive Flexfield Form:
NAV:\Setup\Financials\Flexfields\Descriptive\Segments
.- Descriptive Flexfield title "Address Information" is enable
.- In the Context field zone the displayed field is Checked
.- In the Context field Values zone the code is "Add Addr Info"
.- In the Segments summary Form (Button segments) are activated
Attribute1 (30 characters)
Attribute2 (30 characters)
Attribute3 (30 characters)
------------------------------------- 1. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');

------------------------------------- 2. Show the output variables


-----------------------------------set serveroutput on
------------------------------------- 3. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'EX Flex Customer';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'EX Flex Customer';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4431
x_account_number: 2183
x_party_id: 11163
x_party_number: 8718
x_profile_id: 2934
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Test';
p_location_rec.city := 'san Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/

***************************
Output information ....
x_location_id: 10277
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create a party site
-party_id (from step 3)
-location_id (from step 4)
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11163;
p_party_site_rec.location_id := 10277;
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5690
x_party_site_number: 4199

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site
-- cust_account_id (from step 2)
-- party_site_id (from step 5).
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4431;
p_cust_acct_site_rec.party_site_id := 5690; -- 5689
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
------------------------------------------------ Data for "Address Information" Flexfield
----------------------------------------------p_cust_acct_site_rec.attribute_category := 'Add Addr Info';
p_cust_acct_site_rec.attribute1 := 'Address Info1';
p_cust_acct_site_rec.attribute2 := 'Address Info2';
p_cust_acct_site_rec.attribute3 := 'Address Info3';
----------------------------------------------hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4409

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
-------------------------------------------- 7. Create an account site use 'BILL_TO'
-- cust_acct_site_id (from step 6)
------------------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4409; -- 4405
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4751
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: How to Create an (ORGANIZATION) customer using Site Use Information
Descriptive Flexfield via TCA API?
Fact: Oracle Trading Community 11.5.7
Fix: Example of How to Create an (ORGANIZATION) customer using Site Use
Information Descriptive Flexfield via TCA API?

Supposed that following situation:


1. The ORG_ID is 204.
2. In Descriptive Flexfield Form:
NAV:\Setup\Financials\Flexfields\Descriptive\Segments
.- Descriptive Flexfield title "Site Use Information" is enable
.- In the Context field zone the displayed field is Checked
.- In the Context field Values zone the code is "Add Site Use Info"
.- In the Segments summary Form (Button segments) are activated
Attribute1 (30 characters)
Attribute2 (30 characters)
Attribute3 (30 characters)
------------------------------------- 1. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 2. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 3. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);

x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'EX Flex Customer';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'EX Flex Customer';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4431
x_account_number: 2183
x_party_id: 11163
x_party_number: 8718
x_profile_id: 2934
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 4. Create a physical location


-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Test';
p_location_rec.city := 'san Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 10277
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create a party site
-party_id (from step 3)
-location_id (from step 4)
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;

x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11163;
p_party_site_rec.location_id := 10277;
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5690
x_party_site_number: 4199
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site
-- cust_account_id (from step 2)
-- party_site_id (from step 5).
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN

p_cust_acct_site_rec.cust_account_id := 4431;
p_cust_acct_site_rec.party_site_id := 5690; -- 5689
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4409
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
-------------------------------------------- 7. Create an account site use 'BILL_TO'
-- cust_acct_site_id (from step 6)
------------------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4409; -- 4405
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
------------------------------------------------ Data for "Site Use Information" Flexfield
-----------------------------------------------

p_cust_account_rec.attribute_category := 'Add Site Use Info';


p_cust_account_rec.attribute1 := 'Site Use Info1';
p_cust_account_rec.attribute2 := 'Site Use Info2';
p_cust_account_rec.attribute3 := 'Site Use Info3';
----------------------------------------------hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4751
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to create a customer with salesperson information via TCA API?
Note: The salesrep information is entered only at site level uses.
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');

------------------------------------- 1b. Show the output variables


-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'CUSTSALES01';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'CUSTSALES01';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4485
x_account_number: 2255
x_party_id: 11152
x_party_number: 20228
x_profile_id: 3066
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address1';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');

END;
/
***************************
Output information ....
x_location_id: 21392
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11152; --<<value for party_id from step 2>
p_party_site_rec.location_id := 21392; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5784

x_party_site_number: 4293
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4485; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 5784; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4486
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------------------------------------ 6a. Review what is the salesrep_id that you want to insert

----------------------------------------------------------------col salesrep_id format 99999999


col name format a30
col salesrep_number format a20
select
salesrep_id
,name
,salesrep_number
from
ra_salesreps_all
where
sysdate between nvl(start_date_active, sysdate)
and nvl(end_date_active, sysdate)
and nvl(status, 'A') = 'A'
and salesrep_id != -1
and salesrep_id != -2
and rownum <= 5; --<< in this case only want to query 5 salesreps.
SALESREP_ID
----------1419
1420
1421
1422
1423

NAME
-----------------------------March, Ms. Rebecca
Dolech, Ms. Elaine
Jones, Mr. Scott
Cheung, Mr. Kwan
Lieberman, Mr. Douglas DDS

SALESREP_NUMBER
--------------178
180
189
191
197

In this case I want to insert the salesrep_id = 1421 (Jones, Mr. Scott)
------------------------------------- 6b. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-and salesrep_id from 6a.
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4486; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'SHIP_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
p_cust_site_use_rec.primary_salesrep_id := 1421; --<<value for salesrep_id
from step 6a>
hz_cust_account_site_v2pub.create_cust_site_use(
'T',

p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4810
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to create Customer Account Relationship via TCA API?
In this example will be created two organizations
and then the relationship between then.
------------------------------------- 1. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 2. Show the output variables
-----------------------------------set serveroutput on

---------------------------------------- Creation the first organization


--------------------------------------------------------------------------- 3. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'CUSACC1';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'ORGFENNER01';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');

END;
***************************
Output information ....
x_cust_account_id: 4305
x_account_number: 2097
x_party_id: 10995
x_party_number: 20071
x_profile_id: 2888
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 4. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'AddressAcc1';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 21216

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create a party site using party_id from step 3 and location_id from
step 4
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 10995; --<<value for party_id from step 3>
p_party_site_rec.location_id := 21216; --<<value for location_id from step
4>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 5606
x_party_site_number: 4115
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------

-- 6. Create an account site using cust_account_id from step 3 and


party_site_id from step 5.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4305; --<<value for
cust_account_id you get from step 3>
p_cust_acct_site_rec.party_site_id := 5606; --<<value for party_site_id
from step 5>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 4330
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 7. Create an account site use using cust_acct_site_id from step 6 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;

x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4330; --<<value for
cust_acct_site_id from step 6>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 4656
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;

---------------------------------------- Creation the second organization


--------------------------------------------------------------------------- 8. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec

HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'CUSACC2';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'ORGFENNER02';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 4306
x_account_number: 2098
x_party_id: 10996
x_party_number: 20072
x_profile_id: 2889
x_return_status: S
x_msg_count: 0

x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 9. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'AddressAcc2';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 21217
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 10. Create a party site using party_id from step 8 and location_id from
step 9
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;

x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 10996; --<<value for party_id from step 8>
p_party_site_rec.location_id := 21217; --<<value for location_id from step
9>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....
x_party_site_id: 5607
x_party_site_number: 4116
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 11. Create an account site using cust_account_id from step 8 and
party_site_id from step 10.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4306; --<<value for
cust_account_id you get from step 8>

p_cust_acct_site_rec.party_site_id := 5607; --<<value for party_site_id


from step 10>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 4331
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 12. Create an account site use using cust_acct_site_id from step 11 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4331; --<<value for
cust_acct_site_id from step 11>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',

x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 4657
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;

at this moment the two organizations were created, now will create the
customer account relationship.
------------------------------------------------------------------- 13. Required information in order to create the relationship:
-----------------------------------------------------------------a.
Obtain the cust_account_id from steps 3 and 8 (in this case: 4305 and 4306)
If you do not have this information run this select for each party_id (in
this case: 10995 and 10996)
select
party_id
,cust_account_id
,account_number
,orig_system_reference
,STATUS
,CUSTOMER_TYPE
,ACCOUNT_NAME
,ORG_ID
from

hz_cust_accounts
where
party_id in (10995,10996);
PARTY_ID CUST_ACCOUNT_ID ACCOUNT_NU ORIG_SYSTEM_REFERENCE
ACCOUNT_NA
ORG_ID
---------- --------------- ---------- ---------------------------------- ---------10995
4305 2097
4305
10996
4306 2098
4306

S C
- A
A

CUSACC1
CUSACC2

b.
Obtain the valid relationship types
select
lookup_code
,lookup_type
,end_date_active
from
ar_lookups
where
lookup_type = 'RELATIONSHIP_TYPE'
and enabled_flag = 'Y';
LOOKUP_CODE
-----------------------------ALL
Parent
Reciprocal

LOOKUP_TYPE
END_DATE_
------------------------------ --------RELATIONSHIP_TYPE
RELATIONSHIP_TYPE
RELATIONSHIP_TYPE

----------------------------------------------------------------------- 14. Create a customer account relationship, need info from step 13
---------------------------------------------------------------------The relationship will be ORGFENNER02 (4305) to ORGFENNER01 (4306)
(Related customer ORGFENNER02)
DECLARE
p_cust_acct_relate_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCT_RELATE_REC_TYPE;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_acct_relate_rec.cust_account_id := 4305; --<< get from step 13(a)
p_cust_acct_relate_rec.related_cust_account_id := 4306; --<< get from step
13(a)
p_cust_acct_relate_rec.relationship_type := 'Reciprocal'; --<< get from

step 13(b)
p_cust_acct_relate_rec.created_by_module := 'TCAPI_EXAMPLE';
p_cust_acct_relate_rec.comments := 'test API';
-- if you need to use BILL_TO_FLAG or SHIP_TO_FLAG do
-- Use p_cust_acct_relate_rec.BILL_TO_FLAG = 'Y';
-- Use p_cust_acct_relate_rec.SHIP_TO_FLAG = 'Y';
HZ_CUST_ACCOUNT_V2PUB.create_cust_acct_relate(
'T',
p_cust_acct_relate_rec,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
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('***************************');
END;
***************************
Output information ....
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
Example of how to create a customer for an specific organization
but using different country location instead of the default location
defined for this organization.
Suppose
===========
.- The ORG_ID is 889 (this is for Netherlands Organization)
.- Netherlads Oragnization has Netherlands as default country
.- The customer has an address in Japan (country = 'JP') --> Different home
country
.- The Address style is defined for Japan Country
(Review: Setup\System\Countries)
.- Japan address has the following location fields as required:
postal_code

state
province
city
address1
address2
address3
address_lines_phonetic
.- In system option forms these flags are activated: (Trans and Customers
Tab)
Automatic customer Numbering
Automatic Site Numbering
Create Reciprocal Customer
.- The following Profile Options are set in Yes: (Site Level)
HZ: Generate Contact Number
HZ: Generate Party Number
HZ: Generate Party Site Number
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('889');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'FennerJP002';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'FennerJP002';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,

p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 4260
x_account_number: 2034
x_party_id: 11211
x_party_number: 8746
x_profile_id: 2944
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'JP';
p_location_rec.address1 := 'FennerJP001_02';
p_location_rec.city := 'Tokyo';

p_location_rec.postal_code := '44521';
p_location_rec.state := 'TK';
p_location_rec.province := 'ProvJP';
p_location_rec.address2 := 'FennerJP002_02';
p_location_rec.address3 := 'FennerJP003_02';
p_location_rec.address_lines_phonetic := 'Ni Ju Dou_02';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 10087
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 11211; --<<value for party_id from step 2>
p_party_site_rec.location_id := 10087; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';

p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 5640
x_party_site_number: 4149
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 4260; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 5640; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,

x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 4285
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 4285; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 4609
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
This is an example of How To Create A Customer Profile Amount At Customer
Level Using TCA API.
------------------------------------- 0. In order to use this TCA-API you need to know:
-----------------------------------.- What is the cust_account_profile_id which you want to create the
profile amounts? (In this case is 5341)
.- What is the cust_account_id which you want to create the
profile amounts? (In this case is 4262)
------------------------------------- 1. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 2. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 3. Create a Customer Profile Amount At Customer Level
-----------------------------------DECLARE
p_cpamt_rec HZ_CUSTOMER_PROFILE_V2PUB.cust_profile_amt_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;

x_msg_data VARCHAR2(2000);
x_cust_acct_profile_amt_id NUMBER;
BEGIN
p_cpamt_rec.cust_account_profile_id := 5341;
p_cpamt_rec.currency_code := 'COP'; --<< Currency Code
p_cpamt_rec.created_by_module := 'TCAAPI';
p_cpamt_rec.overall_credit_limit := 1000000;
p_cpamt_rec.cust_account_id := 4262;
-- if you want to create the amounts at site level use this line
-- p_cpamt_rec.site_use_id := <site_use_id>;
HZ_CUSTOMER_PROFILE_V2PUB.create_cust_profile_amt (
'T',
'T',
p_cpamt_rec,
x_cust_acct_profile_amt_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('<x_cust_acct_profile_amt_id: '||
x_cust_acct_profile_amt_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
<x_cust_acct_profile_amt_id: 6472
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;

***************************************************************************
************************************************
***************************************************************************
************************************************
Example about: How To Create A Contact Role At Customer(Org) Level Via TCA
API ?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'CUSEXAPIFIG02';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'CUSEXAPIFIG02';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,

x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_cust_account_id: 6075
x_account_number: 3040
x_party_id: 17092
x_party_number: 14444
x_profile_id: 5290
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address4';

p_location_rec.city := 'San Mateo';


p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_location_id: 13326
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 17092; --<<value for party_id from step 2>

p_party_site_rec.location_id := 13326; --<<value for location_id from step


3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_party_site_id: 8885
x_party_site_number: 6893
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;

BEGIN
p_cust_acct_site_rec.cust_account_id := 6075; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 8885; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_cust_acct_site_id: 6155
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);

x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 6155; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_site_use_id: 7149
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
/* BEGIN contact to an organization */
------------------------------------- 7. Create a definition contact

-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'ExFennerct4';
p_create_person_rec.person_last_name := 'ExGiraldoct4';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_party_id: 17093
x_party_number: 14445
x_profile_id: 17187

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_org_contact_rec.department_code := 'ACCOUNTING';
-- p_org_contact_rec.job_title := 'ACCOUNTS OFFICER';
-- p_org_contact_rec.decision_maker_flag := 'Y';
-- p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := 17093; --<<value for party_id
from step 7>
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := 17092; --<<value for party_id
from step 2>
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,
x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_org_contact_id: 7110
x_party_rel_id: 7788
x_party_id: 17094
x_party_number: 14446
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 9. Create a contact using party_id you get 8 and cust_account_id from
step 2
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := 17094; --<<value for party_id from step
8>
p_cr_cust_acc_role_rec.cust_account_id := 6075; --<<value for
cust_account_id from step 2>
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(

'T',
p_cr_cust_acc_role_rec,
x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_cust_account_role_id: 5857
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* END contact */
/* Create the contact ROLE for the Org Contact - (Contact Roles zone on
Customers Form)*/
------------------------------------- 10. Create the org contact role using x_cust_account_role_id from step 9
-----------------------------------DECLARE
p_role_responsibility_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.ROLE_RESPONSIBILITY_REC_TYPE;
x_responsibility_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN

p_role_responsibility_rec.cust_account_role_id := 5857; --<<value for


x_cust_account_role_id from step 9>
p_role_responsibility_rec.responsibility_type := 'SOLD_TO';
p_role_responsibility_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_role_responsibility (
'T',
p_role_responsibility_rec,
x_responsibility_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_responsibility_id: '||x_responsibility_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_responsibility_id: 3162
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* End contact ROLE */
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How To Create A Contact Role At Address Level Via TCA API ?

Solution
Checked for relevance on 10-Nov-2008
Example about: How To Create A Contact Role At Address Level Via TCA API ?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'CUSEXAPIFIG03';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'CUSEXAPIFIG03';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_cust_account_id: 6081
x_account_number: 3042
x_party_id: 17115
x_party_number: 14457
x_profile_id: 5293
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address4';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';

p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_location_id: 13336
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 17115; -- value for party_id from step 2
p_party_site_rec.location_id := 13336; -- value for location_id from step 3
p_party_site_rec.identifying_address_flag := 'Y';

p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_party_site_id: 8899
x_party_site_number: 6901
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 6081; -- value for cust_account_id
you get from step 2

p_cust_acct_site_rec.party_site_id := 8899; -- value for party_site_id from


step 4
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_cust_acct_site_id: 6157
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 6157; -- value for

cust_acct_site_id from step 5


p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_site_use_id: 7154
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address */
commit;
/* BEGIN contact to an organization */
------------------------------------- 7. Create a definition contact
-----------------------------------DECLARE
p_create_person_rec HZ_PARTY_V2PUB.person_rec_type;
x_party_id NUMBER;

x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_create_person_rec.person_pre_name_adjunct := 'MR.';
p_create_person_rec.person_first_name := 'ExFennerct5';
p_create_person_rec.person_last_name := 'ExGiraldoct5';
p_create_person_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_PARTY_V2PUB.create_person(
'T',
p_create_person_rec,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_party_id: 17116
x_party_number: 14458
x_profile_id: 17193
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 8. Create a relation cont-org using party_id from step 7 and party_id
from step 2
-----------------------------------DECLARE
p_org_contact_rec HZ_PARTY_CONTACT_V2PUB.ORG_CONTACT_REC_TYPE;
x_org_contact_id NUMBER;
x_party_rel_id NUMBER;
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_org_contact_rec.department_code := 'ACCOUNTING';
-- p_org_contact_rec.job_title := 'ACCOUNTS OFFICER';
-- p_org_contact_rec.decision_maker_flag := 'Y';
-- p_org_contact_rec.job_title_code := 'APC';
p_org_contact_rec.created_by_module := 'TCAPI_EXAMPLE';
p_org_contact_rec.party_rel_rec.subject_id := 17116; -- value for party_id
from step 7
p_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
p_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.object_id := 17115; -- value for party_id
from step 2
p_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
p_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
p_org_contact_rec.party_rel_rec.relationship_code := 'CONTACT_OF';
p_org_contact_rec.party_rel_rec.relationship_type := 'CONTACT';
p_org_contact_rec.party_rel_rec.start_date := SYSDATE;
hz_party_contact_v2pub.create_org_contact(
'T',
p_org_contact_rec,
x_org_contact_id,
x_party_rel_id,
x_party_id,
x_party_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_org_contact_id: '||x_org_contact_id);
dbms_output.put_line('x_party_rel_id: '||x_party_rel_id);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
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('***************************');

IF x_msg_count >1 THEN


FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_org_contact_id: 7118
x_party_rel_id: 7793
x_party_id: 17117
x_party_number: 14459
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 9. Create a contact using party_id you get 8 and cust_acct_site_id from
step 5
-- and cust_account_id from step 2
-----------------------------------DECLARE
p_cr_cust_acc_role_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.cust_account_role_rec_type;
x_cust_account_role_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-- NOTE:
-- must be unique CUST_ACCOUNT_ID, PARTY_ID,ROLE_TYPE
-- must be unique CUST_ACCT_SITE_ID, PARTY_ID,ROLE_TYPE
p_cr_cust_acc_role_rec.party_id := 17117; -- value for party_id from step 8
p_cr_cust_acc_role_rec.cust_account_id := 6081; -- value for
cust_account_id from step 2
p_cr_cust_acc_role_rec.cust_acct_site_id := 6157; -- value for
cust_acct_site_id from step 5
p_cr_cust_acc_role_rec.primary_flag := 'Y';
p_cr_cust_acc_role_rec.role_type := 'CONTACT';
p_cr_cust_acc_role_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_cust_account_role(
'T',
p_cr_cust_acc_role_rec,

x_cust_account_role_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_cust_account_role_id: '||x_cust_account_role_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_cust_account_role_id: 5858
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* END contact */
/* Create the contact ROLE for the Org Contact - (Contact Roles zone on
Customers Form)*/
------------------------------------- 10. Create the org contact role using x_cust_account_role_id from step 9
-----------------------------------DECLARE
p_role_responsibility_rec
HZ_CUST_ACCOUNT_ROLE_V2PUB.ROLE_RESPONSIBILITY_REC_TYPE;
x_responsibility_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_role_responsibility_rec.cust_account_role_id := 5858; -- value for
x_cust_account_role_id from step 9

p_role_responsibility_rec.responsibility_type := 'SOLD_TO';
p_role_responsibility_rec.created_by_module := 'TCAPI_EXAMPLE';
HZ_CUST_ACCOUNT_ROLE_V2PUB.create_role_responsibility (
'T',
p_role_responsibility_rec,
x_responsibility_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('***************************');
dbms_output.put_line('x_responsibility_id: '||x_responsibility_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
***************************
x_responsibility_id: 3163
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* End contact ROLE */
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
This is an example of How To Create A Customer Profile For A Specific
Account Using TCA API.

Note: This note will use the profile class: DEFAULT. If the profile class
DEFAULT is not active then the record is not created. Review the note on
the API code.
Fix
------------------------------------- 0. In order to use this TCA-API you need to know:
-----------------------------------.- What is the cust_account_id which you want to create the profile?
(In this case is 7510)
------------------------------------- 1. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
(In this case is 204)
------------------------------------- 2. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 3. Create a Customer Profile Amount At Customer Level
-----------------------------------DECLARE
p_cp_rec HZ_CUSTOMER_PROFILE_V2PUB.customer_profile_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_account_profile_id NUMBER;
BEGIN
-- Note: If you need to use specific profile class use this line:
-- p_cp_rec.profile_class_id := <profile class id>;
p_cp_rec.created_by_module := 'TCA-APIV2';
p_cp_rec.cust_account_id := XXXX; -- This is the value for the step 0 you
need use. (Ex: 7510)
HZ_CUSTOMER_PROFILE_V2PUB.create_customer_profile (
'T',
p_cp_rec,
'T',
x_cust_account_profile_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');

dbms_output.put_line('x_cust_account_profile_id: '||
x_cust_account_profile_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('***************************');
IF x_msg_count >1 THEN
FOR I IN 1..x_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;
END;
/
***************************
Output information ....
x_cust_account_profile_id: 9540
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Commit
-- (If you do not this, you will not able to see the new record)
-----------------------------------commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How To Insert A Customer Information With Profile Information Using TCA
API?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE

p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
p_create_profile_amt VARCHAR2(2000);
BEGIN
-- record for the account
p_cust_account_rec.account_name := 'FennerProfAPIc001';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001';
mandatory

-- is not

-- record for the organization


p_organization_rec.organization_name := 'FennerProfAPIc001';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
-- record for the profile (this will use he DEFAULT profile but change
these fields)
p_customer_profile_rec.credit_checking := 'Y';
p_customer_profile_rec.interest_charges := 'N';
-- as interest charges is N, you need to set this two values in null
p_customer_profile_rec.charge_on_finance_charge_flag :=
FND_API.G_MISS_CHAR;
p_customer_profile_rec.interest_period_days := FND_API.G_MISS_NUM;
p_customer_profile_rec.created_by_module := 'TCAPI_EXAMPLE';
-- record for the profile amount
-- you only are able to created by default or not create the record
-- You are not able to assign values for the amounts in this API
p_create_profile_amt := 'F';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
p_create_profile_amt,
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,

x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 7742
x_account_number: 3989
x_party_id: 19564
x_party_number: 16477
x_profile_id: 8673
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'FennerAPIc001Add6';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,

x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 15536
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 19564; --<<value for party_id from step 2>
p_party_site_rec.location_id := 15536; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 10708
x_party_site_number: 8435
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7742; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 10708; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 7259

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 7259; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 8941
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to Insert a customer Information with profile and default profiles
amounts information using TCA API?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
p_create_profile_amt VARCHAR2(2000);
BEGIN
-- record for the account
p_cust_account_rec.account_name := 'FennerProfAPIamtc001';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001'; -- is not
mandatory
-- record for the organization
p_organization_rec.organization_name := 'FennerProfAPIamtc001';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
-- record for the profile (this will use he DEFAULT profile but change
these fields)
p_customer_profile_rec.credit_checking := 'Y';
p_customer_profile_rec.interest_charges := 'N';

-- as interest charges is N, you need to set this two values in null


p_customer_profile_rec.charge_on_finance_charge_flag :=
FND_API.G_MISS_CHAR;
p_customer_profile_rec.interest_period_days := FND_API.G_MISS_NUM;
p_customer_profile_rec.created_by_module := 'TCAPI_EXAMPLE';
-- record for the profile amount
-- You are not able to assign values for the amounts in this API
-- you are able to created profile amounts by default using:
p_create_profile_amt := 'T';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
p_create_profile_amt,
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 7743
x_account_number: 3990
x_party_id: 19565
x_party_number: 16478
x_profile_id: 8676
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'FennerProfAPIamtc001';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 15537
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);

x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 19565; --<<value for party_id from step 2>
p_party_site_rec.location_id := 15537; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 10709
x_party_site_number: 8436
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7743; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 10709; --<<value for party_site_id

from step 4>


p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 7260
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 7260; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,

x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 8942
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How to Insert a customer Information with profile and profiles amounts-(No
default values) information using TCA API?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2a. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec

HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
p_create_profile_amt VARCHAR2(2000);
BEGIN
-- record for the account
p_cust_account_rec.account_name := 'FennerProfAPIamtc002';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- p_cust_account_rec.orig_system_reference := '001_001'; -- is not
mandatory
-- record for the organization
p_organization_rec.organization_name := 'FennerProfAPIamtc002';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
-- record for the profile (this will use he DEFAULT profile but change
these fields)
p_customer_profile_rec.credit_checking := 'Y';
p_customer_profile_rec.interest_charges := 'N';
-- as interest charges is N, you need to set this two values in null
p_customer_profile_rec.charge_on_finance_charge_flag :=
FND_API.G_MISS_CHAR;
p_customer_profile_rec.interest_period_days := FND_API.G_MISS_NUM;
p_customer_profile_rec.created_by_module := 'TCAPI_EXAMPLE';
-- Record for the profile amounts
-- You are not able to assign values for the amounts in this API
-- As you want to create specific values for the amounts set the field in
'F'
-- You will insertthe information later
p_create_profile_amt := 'F';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
p_create_profile_amt,
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 7744
x_account_number: 3991
x_party_id: 19566
x_party_number: 16479
x_profile_id: 8679
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 2b. Create the profile amounts record
-----------------------------------DECLARE
p_cpamt_rec HZ_CUSTOMER_PROFILE_V2PUB.cust_profile_amt_rec_type;
v_cust_account_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_profile_amt_id NUMBER;
BEGIN
select cust_account_profile_id into v_cust_account_profile_id
from hz_customer_profiles where cust_account_id = 7744; --<<value for
cust_account_id from step 2a
p_cpamt_rec.cust_account_profile_id := v_cust_account_profile_id;
p_cpamt_rec.currency_code := 'USD'; --<< Currency Code
p_cpamt_rec.created_by_module := 'TCAPI_EXAMPLE';
p_cpamt_rec.overall_credit_limit := 1000000;
p_cpamt_rec.cust_account_id := 7744; --<<value for cust_account_id from
step 2a

HZ_CUSTOMER_PROFILE_V2PUB.create_cust_profile_amt (
'T',
'T',
p_cpamt_rec,
x_cust_acct_profile_amt_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('<x_cust_acct_profile_amt_id: '||
x_cust_acct_profile_amt_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('***************************');
END;
/
***************************
Output information ....
<x_cust_acct_profile_amt_id: 14883
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'FennerProfAPIamtc002';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,

x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 15538
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2a and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 19566; --<<value for party_id from step 2a>
p_party_site_rec.location_id := 15538; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 10710
x_party_site_number: 8437
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2a and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7744; --<<value for
cust_account_id you get from step 2a>
p_cust_acct_site_rec.party_site_id := 10710; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 7261

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 7261; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_site_use_id: 8943
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
How To Create An Organization Customer With Profile Information At Site
Level Using TCA-API?
Solution
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
p_create_profile_amt VARCHAR2(2000);
BEGIN
-- record for the account
p_cust_account_rec.account_name := 'FennerProfAPI_0010';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
-- record for the organization
p_organization_rec.organization_name := 'FennerProfAPI_0010';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,

p_organization_rec,
p_customer_profile_rec,
p_create_profile_amt,
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
x_cust_account_id: 7964
x_account_number: 4123
x_party_id: 20009
x_party_number: 16817
x_profile_id: 9363
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';

p_location_rec.address1 := 'FennerProfAPI_0010';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
/
***************************
Output information ....
x_location_id: 15997
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 20009; --<<value for party_id from step 2>
p_party_site_rec.location_id := 15997; --<<value for location_id from step
3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,

x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
/
***************************
Output information ....
x_party_site_id: 11068
x_party_site_number: 8702
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 5. Create an account site using cust_account_id from step 2 and
party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 7964; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 11068; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
/
***************************
Output information ....
x_cust_acct_site_id: 7401
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 7401; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
/

***************************
Output information ....
x_site_use_id: 9181
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

------------------------------------- 7. Create a profile site using site_use_id from step 6 and


cust_account_id from step 2
-----------------------------------DECLARE
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.customer_profile_rec_type;
x_cust_account_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
p_create_profile_amt VARCHAR2(2000);
BEGIN
p_create_profile_amt := 'F';
p_customer_profile_rec.created_by_module := 'TCAPI_EXAMPLE';
p_customer_profile_rec.site_use_id := 9181; --<< value site_use_id from
step 6
p_customer_profile_rec.cust_account_id := 7964; --<< cust_account_id from
step 2
HZ_CUSTOMER_PROFILE_V2PUB.create_customer_profile (
'T',
p_customer_profile_rec,
p_create_profile_amt,
x_cust_account_profile_id,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_profile_id: '||
x_cust_account_profile_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_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_cust_account_profile_id: 10009
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
commit;
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: how to update a customer (organization) with dunning info = N to
dunning info = Y via TCA API?
Fact: Oracle Trading Community 11.5.7
Fix: Example of how to update a customer (organization) with dunning info =
N to dunning info = Y via TCA API?
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
-------------------------------------------------- 1c. Initial information :
-- Output information: Record inserted before
-when using Create a party and an account
------------------------------------------------***************************
Output information ....
x_cust_account_id: 7691
x_account_number: 3997
x_party_id: 8035
x_party_number: 6379
x_profile_id: 4772

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
-------------------------------------------------- 1d. Review the data in HZ_CUSTOMER_PROFILES
------------------------------------------------select
CUST_ACCOUNT_PROFILE_ID
,OBJECT_VERSION_NUMBER
,DUNNING_LETTERS
,DUNNING_LETTER_SET_ID
from
HZ_CUSTOMER_PROFILES
where
CUST_ACCOUNT_ID = 7691; --<< CUST_ACCOUNT_ID from 1c >
CUST_ACCOUNT_PROFILE_ID OBJECT_VERSION_NUMBER D DUNNING_LETTER_SET_ID
----------------------- --------------------- - --------------------8934
1 N

------------------------------------- 2. Update customer profile


-----------------------------------DECLARE
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
xin_xout_object_version_number NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_customer_profile_rec.cust_account_profile_id := 8934; --<<
cust_account_profile_id from 1d >
p_customer_profile_rec.dunning_letters := 'Y';
p_customer_profile_rec.dunning_letter_set_id := 1;
xin_xout_object_version_number := 1; --<< object_version_number from 1d >
HZ_CUSTOMER_PROFILE_V2PUB.update_customer_profile(
'T',
p_customer_profile_rec,
xin_xout_object_version_number,
x_return_status,
x_msg_count,
x_msg_data);

dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('xin_xout_object_version_number: '||
xin_xout_object_version_number);
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('***************************');
END;
commit;
***************************
Output information ....
xin_xout_object_version_number: 2
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
---------------------------------------------------- 2a. Review the new data in HZ_CUSTOMER_PROFILES
--------------------------------------------------select
CUST_ACCOUNT_PROFILE_ID
,OBJECT_VERSION_NUMBER
,DUNNING_LETTERS
,DUNNING_LETTER_SET_ID
from
HZ_CUSTOMER_PROFILES
where
CUST_ACCOUNT_ID = 7691;
CUST_ACCOUNT_PROFILE_ID OBJECT_VERSION_NUMBER D DUNNING_LETTER_SET_ID
----------------------- --------------------- - --------------------8934
2 Y
1
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: how to update a customer (organization) with dunning info = Y to
dunning info = N via TCA API?
Fact: Oracle Trading Community 11.5.7
Fix: Example of how to update a customer (organization) with dunning info =
Y to dunning info = N via TCA API?

------------------------------------- 1a. Setup the Org_id


-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
-------------------------------------------------- 1c. Initial information :
-- Output information: Record inserted before
-when using Create a party and an account
------------------------------------------------***************************
Output information ....
x_cust_account_id: 7692
x_account_number: 3998
x_party_id: 8036
x_party_number: 6380
x_profile_id: 4773
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
-------------------------------------------------- 1d. Review the data in HZ_CUSTOMER_PROFILES
------------------------------------------------select
CUST_ACCOUNT_PROFILE_ID
,OBJECT_VERSION_NUMBER
,DUNNING_LETTERS
,DUNNING_LETTER_SET_ID
from
HZ_CUSTOMER_PROFILES
where
CUST_ACCOUNT_ID = 7692; --<< CUST_ACCOUNT_ID from 1c >
CUST_ACCOUNT_PROFILE_ID OBJECT_VERSION_NUMBER D DUNNING_LETTER_SET_ID
----------------------- --------------------- - --------------------8935
1 Y
1
------------------------------------- 2. Update customer profile
-----------------------------------DECLARE

p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
xin_xout_object_version_number NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_customer_profile_rec.cust_account_profile_id := 8935; --<<
cust_account_profile_id from 1d >
p_customer_profile_rec.dunning_letters := 'N';
p_customer_profile_rec.dunning_letter_set_id := FND_API.G_MISS_NUM;
xin_xout_object_version_number := 1; --<< object_version_number from 1d >
HZ_CUSTOMER_PROFILE_V2PUB.update_customer_profile(
'T',
p_customer_profile_rec,
xin_xout_object_version_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('xin_xout_object_version_number: '||
xin_xout_object_version_number);
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('***************************');
END;
commit;
***************************
Output information ....
xin_xout_object_version_number: 2
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
---------------------------------------------------- 2a. Review the new data in HZ_CUSTOMER_PROFILES
--------------------------------------------------select
CUST_ACCOUNT_PROFILE_ID
,OBJECT_VERSION_NUMBER

,DUNNING_LETTERS
,DUNNING_LETTER_SET_ID
from
HZ_CUSTOMER_PROFILES
where
CUST_ACCOUNT_ID = 7692;
CUST_ACCOUNT_PROFILE_ID OBJECT_VERSION_NUMBER D DUNNING_LETTER_SET_ID
----------------------- --------------------- - --------------------8935
2 N
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: how to update a customer (organization) with interest charges = Y
interest charges = N via TCA API?
Fact: Oracle Trading Community 11.5.7
Fix: Example of how to update a customer (organization) with interest
charges = Y to interest charges info = N via TCA API?
update; customer; organization; interest; charges; tca; api;
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
-------------------------------------------------- 1c. Initial information :
-- Output information: Record inserted before
-when using Create a party and an account
------------------------------------------------***************************
Output information ....
x_cust_account_id: 4401
x_account_number: 2159
x_party_id: 11116
x_party_number: 8671
x_profile_id: 2904
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
NOTE: if do not have this information do:

to

Go to Customer form -> query the customer that want update


when the form "Match Results" is open, review the value for
column PARTY_NUMBER
select
hca.cust_account_id
,hca.account_number
,hca.party_id
from
hz_cust_accounts hca
,hz_parties hzp
where
hzp.party_number = '8671' --< replace the party_number that obtain in
the form
and hca.party_id = hzp.party_id;
CUST_ACCOUNT_ID ACCOUNT_NUMBER
PARTY_ID
--------------- ------------------------------ --------4401 2159
11116
NOTE: that value is a varchar column not a number column.
-------------------------------------------------- 1d. Review the data in HZ_CUSTOMER_PROFILES
------------------------------------------------select
CUST_ACCOUNT_PROFILE_ID
,OBJECT_VERSION_NUMBER
,INTEREST_CHARGES
,INTEREST_PERIOD_DAYS
from
HZ_CUSTOMER_PROFILES
where
CUST_ACCOUNT_ID = 4401; --<< CUST_ACCOUNT_ID from 1c >
CUST_ACCOUNT_PROFILE_ID OBJECT_VERSION_NUMBER I INTEREST_PERIOD_DAYS
----------------------- --------------------- - -------------------5479
1 Y
30
------------------------------------- 2. Update customer profile
-----------------------------------DECLARE
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
xin_xout_object_version_number NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN

p_customer_profile_rec.cust_account_profile_id := 5479; --<<


cust_account_profile_id from 1d >
p_customer_profile_rec.INTEREST_CHARGES := 'N';
p_customer_profile_rec.INTEREST_PERIOD_DAYS := FND_API.G_MISS_NUM;
xin_xout_object_version_number := 1; --<< object_version_number from 1d >
HZ_CUSTOMER_PROFILE_V2PUB.update_customer_profile(
'T',
p_customer_profile_rec,
xin_xout_object_version_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('xin_xout_object_version_number: '||
xin_xout_object_version_number);
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('***************************');
END;
commit;
***************************
Output information ....
xin_xout_object_version_number: 2
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
---------------------------------------------------- 2a. Review the new data in HZ_CUSTOMER_PROFILES
--------------------------------------------------select
CUST_ACCOUNT_PROFILE_ID
,OBJECT_VERSION_NUMBER
,INTEREST_CHARGES
,INTEREST_PERIOD_DAYS
from
HZ_CUSTOMER_PROFILES
where
CUST_ACCOUNT_ID = 4401;
CUST_ACCOUNT_PROFILE_ID OBJECT_VERSION_NUMBER I INTEREST_PERIOD_DAYS

----------------------- --------------------- - -------------------5479


2 N
***************************************************************************
************************************************
***************************************************************************
************************************************
How to Update an addressee Field Information using TCA API
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'FennerAdd01';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'FennerAdd01';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,

x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 12270
x_account_number: 8077
x_party_id: 17723
x_party_number: 16168
x_profile_id: 8182
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address1';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,

x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 1000002012676
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 17723; --<<value for party_id from step 2>
p_party_site_rec.location_id := 1000002012676; --<<value for location_id
from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
p_party_site_rec.addressee := 'example1';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);

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('***************************');
END;
***************************
Output information ....
x_party_site_id: 12520
x_party_site_number: 10973
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 12270; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 12520; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;

***************************
Output information ....
x_cust_acct_site_id: 10102
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 10102; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 10400
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************

/* END address

*/

commit;

------------------------------------- 7. Update addressee using party_site_id from step 4


-----------------------------------***************************
Output information ....
x_party_site_id: 12520
x_party_site_number: 10973
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
a. Run this select
col addrformat format a15
select
party_site_id
,object_version_number
,addressee addrformat
from
hz_party_sites
where
party_site_id = 12520; --< party_site_id from step 4
PARTY_SITE_ID OBJECT_VERSION_NUMBER ADDRFORMAT
------------- --------------------- --------------12520
1 example1
b.
DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_ver_number NUMBER;
BEGIN
p_party_site_rec.party_site_id := 12520; --<<value for party_site_id from
step 4>
p_party_site_rec.addressee := 'example2';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
x_ver_number := 1; --< version_number obtained from prior select (a)

hz_party_site_v2pub.update_party_site(
'T',
p_party_site_rec,
x_ver_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_ver_number: '||x_ver_number);
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('***************************');
END;
***************************
Output information ....
x_ver_number: 2
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
c. Review that was modified:
col addrformat format a15
select
party_site_id
,object_version_number
,addressee addrformat
from
hz_party_sites
where
party_site_id = 12520; --< party_site_id from step 4
PARTY_SITE_ID OBJECT_VERSION_NUMBER ADDRFORMAT
------------- --------------------- --------------12520
2 example2
***************************************************************************
************************************************
***************************************************************************
************************************************

How to Update a location Information using TCA API


------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------- 2. Create a party and an account
-----------------------------------DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_account_rec.account_name := 'Fenner2401';
p_cust_account_rec.created_by_module := 'TCAPI_EXAMPLE';
p_organization_rec.organization_name := 'Fenner2401';
p_organization_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_v2pub.create_cust_account(
'T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');

dbms_output.put_line('Output information ....');


dbms_output.put_line('x_cust_account_id: '||x_cust_account_id);
dbms_output.put_line('x_account_number: '||x_account_number);
dbms_output.put_line('x_party_id: '||x_party_id);
dbms_output.put_line('x_party_number: '||x_party_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
***************************
Output information ....
x_cust_account_id: 12269
x_account_number: 8076
x_party_id: 17722
x_party_number: 16167
x_profile_id: 8181
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
/* BEGIN address */
------------------------------------- 3. Create a physical location
-----------------------------------DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_location_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_location_rec.country := 'US';
p_location_rec.address1 := 'Address1';
p_location_rec.city := 'San Mateo';
p_location_rec.postal_code := '94401';
p_location_rec.state := 'CA';
p_location_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_location_v2pub.create_location(
'T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_location_id: '||x_location_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('***************************');
END;
***************************
Output information ....
x_location_id: 1000002012675
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------- 4. Create a party site using party_id from step 2 and location_id from
step 3
-----------------------------------DECLARE
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_party_site_rec.party_id := 17722; --<<value for party_id from step 2>
p_party_site_rec.location_id := 1000002012675; --<<value for location_id
from step 3>
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_party_site_v2pub.create_party_site(
'T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_party_site_id: '||x_party_site_id);
dbms_output.put_line('x_party_site_number: '||x_party_site_number);
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('***************************');
END;
***************************
Output information ....

x_party_site_id: 12519
x_party_site_number: 10972
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 5. Create an account site using cust_account_id from step 2 and


party_site_id from step 4.
-----------------------------------DECLARE
p_cust_acct_site_rec hz_cust_account_site_v2pub.cust_acct_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_cust_acct_site_id NUMBER;
BEGIN
p_cust_acct_site_rec.cust_account_id := 12269; --<<value for
cust_account_id you get from step 2>
p_cust_acct_site_rec.party_site_id := 12519; --<<value for party_site_id
from step 4>
p_cust_acct_site_rec.language := 'US';
p_cust_acct_site_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_acct_site(
'T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_cust_acct_site_id: '||x_cust_acct_site_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('***************************');
END;
***************************
Output information ....
x_cust_acct_site_id: 10101
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************

------------------------------------- 6. Create an account site use using cust_acct_site_id from step 5 and
site_use_code='BILL_TO'
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
x_site_use_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.cust_acct_site_id := 10101; --<<value for
cust_acct_site_id from step 5>
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCAPI_EXAMPLE';
hz_cust_account_site_v2pub.create_cust_site_use(
'T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_site_use_id: '||x_site_use_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_count);
dbms_output.put_line('***************************');
END;
***************************
Output information ....
x_site_use_id: 10399
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
/* END address

*/

commit;

------------------------------------

-- 7. Update location using location_id from step 3


-----------------------------------a. Run this select
select
location_id
,object_version_number
from
hz_locations
where
location_id = 1000002012675; --< location from step 3
LOCATION_ID OBJECT_VERSION_NUMBER
---------- --------------------1.0000E+12
1
b.
DECLARE
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
x_ver_number NUMBER;
BEGIN
p_location_rec.location_id := 1000002012675;
p_location_rec.address1 := 'Address2';
x_ver_number := 1; --< version_number obtained from prior select (a)
hz_location_v2pub.update_location (
'T',
p_location_rec,
x_ver_number,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_p_version: '||x_ver_number);
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('***************************');
END;

***************************
Output information ....
x_p_version: 2

x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
c. Review that was modified:
select
location_id
,object_version_number
from
hz_locations
where
location_id = 1000002012675; --< location from step 3
LOCATION_ID OBJECT_VERSION_NUMBER
---------- --------------------1.0000E+12
2
***************************************************************************
************************************************
***************************************************************************
************************************************
How to update a Customer Account Relationship via TCA API?
------------------------------------- 0a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 0b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------------------------------------- 1. Required information in order to update the relationship:
-----------------------------------------------------------------a.
Obtain the relationship information that want to update:
In this example cust_account_id = 4305 (example done in Note: 224494.1)
(For more information review Note: 224494.1: How to create Customer Account
Relationship via TCA API?)
col comments format a15

select
CUST_ACCOUNT_ID
,RELATED_CUST_ACCOUNT_ID
,OBJECT_VERSION_NUMBER
,COMMENTS
,org_id
from
HZ_CUST_ACCT_RELATE
where
cust_account_id = 4305;
CUST_ACCOUNT_ID RELATED_CUST_ACCOUNT_ID OBJECT_VERSION_NUMBER COMMENTS
ORG_ID
--------------- ----------------------- ----------------------------------- ---------4305
4306
1 test API
204

----------------------------------------------- 2. Update a customer account relationship


---------------------------------------------comments field Will be updated to 'test APIUpd'
DECLARE
p_cust_acct_relate_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCT_RELATE_REC_TYPE;
xio_object_version_number NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
xio_object_version_number := 1; --<< get from step 1(a)
p_cust_acct_relate_rec.cust_account_id := 4305; --<< get from step 1(a)
p_cust_acct_relate_rec.related_cust_account_id := 4306; --<< get from step
1(a)
p_cust_acct_relate_rec.comments := 'test APIUpd';
HZ_CUST_ACCOUNT_V2PUB.update_cust_acct_relate(
'T',
p_cust_acct_relate_rec,
xio_object_version_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
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('***************************');
END;
***************************
Output information ....
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
------------------------------------------------------------ 3. Review the updated customer account relationship
----------------------------------------------------------select
CUST_ACCOUNT_ID
,RELATED_CUST_ACCOUNT_ID
,OBJECT_VERSION_NUMBER
,COMMENTS
,org_id
from
HZ_CUST_ACCT_RELATE
where
cust_account_id = 4305;
CUST_ACCOUNT_ID RELATED_CUST_ACCOUNT_ID OBJECT_VERSION_NUMBER COMMENTS
ORG_ID
--------------- ----------------------- ----------------------------------- ---------4305
4306
2 test APIUpd
204
***************************************************************************
************************************************
***************************************************************************
************************************************
How to update the salesperson information for a specific customer via TCA
API?
Note: The salesrep information is entered only at site level uses.
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');

------------------------------------- 1b. Show the output variables


-----------------------------------set serveroutput on
------------------------------------------------------------------ 2. Review what is the new salesrep_id that you want to use
----------------------------------------------------------------col salesrep_id format 99999999
col name format a30
col salesrep_number format a20
select
salesrep_id
,name
,salesrep_number
from
ra_salesreps_all
where
sysdate between nvl(start_date_active, sysdate)
and nvl(end_date_active, sysdate)
and nvl(status, 'A') = 'A'
and salesrep_id != -1
and salesrep_id != -2
and rownum <= 5; --<< in this case only want to query 5 salesreps.
SALESREP_ID
----------1419
1420
1421
1422
1423

NAME
-----------------------------March, Ms. Rebecca
Dolech, Ms. Elaine
Jones, Mr. Scott
Cheung, Mr. Kwan
Lieberman, Mr. Douglas DDS

SALESREP_NUMBER
--------------178
180
189
191
197

In this case I want to update the salesrep_id = 1421 (Jones, Mr. Scott)
for salesrep_id = 1422 (Cheung, Mr. Kwan)
-------------------------------------------------------- 3. Review the information for specific site_use_id
------------------------------------------------------if you do not know the site_use_id review this information using:
Help \ Diagnostic \ Examine in customer form for the specific customer and
site
or
If you run API to create a customer with salesperson information
using hz_cust_account_site_v2pub.create_cust_site_use API, you
got this information: (in this case value from Step 6b of Note: 230750.1)

***************************
Output information ....
x_site_use_id: 4810
x_return_status: S
x_msg_count: 0
x_msg_data: 0
***************************
and run: (in this case site_use_id = 4810)
select
OBJECT_VERSION_NUMBER
,site_use_id
,CUST_ACCT_SITE_ID
,PRIMARY_SALESREP_ID
from
hz_cust_site_uses_all
where
site_use_id = 4810;
OBJECT_VERSION_NUMBER SITE_USE_ID CUST_ACCT_SITE_ID PRIMARY_SALESREP_ID
--------------------- ----------- ----------------- ------------------1
4810
4486
1421
NOTE: In this case I want to update the PRIMARY_SALESREP_ID = 1421
for PRIMARY_SALESREP_ID = 1422
------------------------------------- 4. Update an account site use using salesrep_id from step 2 and
site_use_id and OBJECT_VERSION_NUMBER from step 3
-----------------------------------DECLARE
p_cust_site_use_rec HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
xio_p_object_version NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_cust_site_use_rec.primary_salesrep_id := 1422; --<<value from salesrep_id
(step 2)>
p_cust_site_use_rec.site_use_id := 4810; --<<value from site_use_id (step
3)>
xio_p_object_version := 1; --<<value from OBJECT_VERSION_NUMBER (step 3)>
hz_cust_account_site_v2pub.update_cust_site_use(
'T',
p_cust_site_use_rec,
xio_p_object_version,

x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('x_return_status: '||x_return_status);
dbms_output.put_line('x_msg_count: '||x_msg_count);
dbms_output.put_line('xio_p_object_version: '||xio_p_object_version);
dbms_output.put_line('x_msg_data: '||x_msg_count);
dbms_output.put_line('***************************');
END;
/
***************************
Output information ....
x_return_status: S
x_msg_count: 0
xio_p_object_version: 2
x_msg_data: 0
***************************
commit;
------------------------------------------------------------------ 5. Review the updated information
----------------------------------------------------------------in this case site_use_id = 4810
select
OBJECT_VERSION_NUMBER
,site_use_id
,CUST_ACCT_SITE_ID
,PRIMARY_SALESREP_ID
from
hz_cust_site_uses_all
where
site_use_id = 4810;
OBJECT_VERSION_NUMBER SITE_USE_ID CUST_ACCT_SITE_ID PRIMARY_SALESREP_ID
--------------------- ----------- ----------------- ------------------2
4810
4486
1422
The new PRIMARY_SALESREP_ID is 1422 (Cheung, Mr. Kwan).
***************************************************************************
************************************************
***************************************************************************
************************************************

Goal: how to update the last name to a customer (PERSON).


Fact: Oracle Trading Community 11.5
Fix: Example of how to update the last name to a customer (PERSON).
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
-------------------------------------------------- 1c. Initial information :
------------------------------------------------Go to Customer form -> query the customer that want update
when the form "Match Results" is open, review the value for
column PARTY_NUMBER
select
hca.cust_account_id
,hca.account_number
,hca.party_id
from
hz_cust_accounts hca
,hz_parties hzp
where
hzp.party_number = '20303' --< replace the party_number that obtain in
the form
and hca.party_id = hzp.party_id;
CUST_ACCOUNT_ID ACCOUNT_NUMBER
PARTY_ID
--------------- ------------------------------ ---------4555 2331
11227
NOTE: that value is a varchar column not a number column.
-------------------------------------------------- 1d. Review the data in HZ_CUSTOMER_PROFILES
------------------------------------------------col ppname format a20
col plname format a20
select
hzp.person_first_name ppname
,hzp.person_last_name plname
,hzp.OBJECT_VERSION_NUMBER
,hzp.party_id
from
hz_parties hzp
where
hzp.party_number = '20303';

PPNAME
PLNAME
OBJECT_VERSION_NUMBER
PARTY_ID
-------------------- -------------------- --------------------- ---------FennerTEST
GiraldoTEST
1
11227
NOTE: that value is a varchar column not a number column.
------------------------------------- 2. Update customer profile
-----------------------------------DECLARE
p_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE;
xin_xout_object_version_number NUMBER;
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_person_rec.Party_rec.party_id := 11227; --<< party_id from 1d >
xin_xout_object_version_number := 1; --<< OBJECT_VERSION_NUMBER from 1d >
p_person_rec.person_last_name := 'GiraldoUpd'; --<< this is the new last
name >
HZ_PARTY_V2PUB.update_person(
'T',
p_person_rec,
xin_xout_object_version_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('xin_xout_object_version_number: '||
xin_xout_object_version_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');
END;
/
***************************
Output information ....
xin_xout_object_version_number: 2
x_profile_id: 8263
x_return_status: S
x_msg_count: 0

x_msg_data:
***************************
commit;
---------------------------------------------------- 2a. Review the new data in HZ_CUSTOMER_PROFILES
--------------------------------------------------select
hzp.person_first_name ppname
,hzp.person_last_name plname
,hzp.OBJECT_VERSION_NUMBER
,hzp.party_id
from
hz_parties hzp
where
hzp.party_number = '20303';

PPNAME
PLNAME
OBJECT_VERSION_NUMBER
PARTY_ID
-------------------- -------------------- --------------------- ---------FennerTEST
GiraldoUpd
2
11227
***************************************************************************
************************************************
***************************************************************************
************************************************
This is an example about how to update customer account related information
(Relationships Tab in Customer Form) using TCA-API
------------------------------------- 0a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 0b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------------------------------------- 1. Required information in order to update the related information
------------------------------------------------------------------- You need to know what is the account that related information is
belonging.
-- You can do this in order to know that:
col party_name format a25

col account_name format a15


a.
select
hca.cust_account_id
,hca.account_name
,hp.party_name
from
hz_cust_accounts hca
,hz_parties
hp
where
hca.party_id = hp.party_id
and hp.party_name like 'FENNER01%';
CUST_ACCOUNT_ID ACCOUNT_NAME
PARTY_NAME
--------------- --------------- ------------------------10042
FENNER01
b.
select
hzcar.BILL_TO_FLAG
,hzcar.SHIP_TO_FLAG
,hzcar.CUSTOMER_RECIPROCAL_FLAG
,hzcar.STATUS
,hzcar.OBJECT_VERSION_NUMBER
,hzcar.related_cust_account_id
,hp.party_name
from
HZ_CUST_ACCT_RELATE hzcar
,HZ_PARTIES hp
,HZ_CUST_ACCOUNTS hca
where
hca.CUST_ACCOUNT_ID = hzcar.CUST_ACCOUNT_ID
and hca.party_id = hp.party_id
and hzcar.CUST_ACCOUNT_ID = 10042; --<< cust_account_id from 1(a)
B S C S OBJECT_VERSION_NUMBER RELATED_CUST_ACCOUNT_ID PARTY_NAME
- - - - --------------------- ----------------------- -------------------N N N I
20
10044 FENNER02
-- That means that these fields
-- (BILL_TO_FLAG, SHIP_TO_FLAG, CUSTOMER_RECIPROCAL_FLAG and STATUS)
-- are "not checked" in the form
----------------------------------------------- 2. Update related information
---------------------------------------------DECLARE
p_update_cust_acct_relate_type
HZ_CUST_ACCOUNT_V2PUB.CUST_ACCT_RELATE_REC_TYPE;
xio_P_ObjVerNum NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;

x_msg_data VARCHAR2(2000);
BEGIN
xio_P_ObjVerNum := 20; --<< get from step 1(b)
p_update_cust_acct_relate_type.cust_account_id := 10042; --<< get from
step 1(b)
p_update_cust_acct_relate_type.related_cust_account_id := 10044; --<< get
from step 1(b)
----------------------------------------------- UPDATE SECTION
-- if you want to update other information please review the TCA-API user
guide
-- Note: There are some examples
----------------------------------------------- if you want to update the ship_to_flag from 'Unchecked' to 'Checked'
p_update_cust_acct_relate_type.ship_to_flag := 'Y';
-- if you want to update the bill_to_flag from 'Unchecked' to 'Checked'
p_update_cust_acct_relate_type.bill_to_flag := 'Y';
-- if you want to update status from 'No active' to 'Active'
p_update_cust_acct_relate_type.status := 'A';
---------------------------------------------HZ_CUST_ACCOUNT_V2PUB.update_cust_acct_relate(
'T',
p_update_cust_acct_relate_type,
xio_P_ObjVerNum,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('xio_P_ObjVerNum: '||xio_P_ObjVerNum);
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('***************************');
END;
/
***************************
Output information ....
xio_P_ObjVerNum: 21
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;

------------------------------------------------------------ 3. Review the updated customer account relationship


----------------------------------------------------------select
hzcar.BILL_TO_FLAG
,hzcar.SHIP_TO_FLAG
,hzcar.CUSTOMER_RECIPROCAL_FLAG
,hzcar.STATUS
,hzcar.OBJECT_VERSION_NUMBER
,hzcar.related_cust_account_id
,hp.party_name
from
HZ_CUST_ACCT_RELATE hzcar
,HZ_PARTIES hp
,HZ_CUST_ACCOUNTS hca
where
hca.CUST_ACCOUNT_ID = hzcar.CUST_ACCOUNT_ID
and hca.party_id = hp.party_id
and hzcar.CUST_ACCOUNT_ID = 10042;
B S C S OBJECT_VERSION_NUMBER RELATED_CUST_ACCOUNT_ID PARTY_NAME
- - - - --------------------- ----------------------- -------------------Y N N A
21
10044 FENNER02
-- That means that fields BILL_TO_FLAG was checked and Status
-- was actived
-- you can verify that using the customer form
***************************************************************************
************************************************
***************************************************************************
************************************************
Goal: how to update the category_code to a customer (ORGANIZATION).
Fact: Oracle Trading Community 11.5
Fix: Example of how to update category_code to a customer (ORGANIZATION).
------------------------------------- 1a. Setup the Org_id
-----------------------------------exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
-------------------------------------------------- 1c. Initial information :
------------------------------------------------Go to Customer form -> query the customer that want update
when the form "Match Results" is open, review the value for
column PARTY_ID

select
party_id
,object_version_number
,category_code
from
hz_parties
where
party_id = 11046; --< replace the party_id that obtain in the form
PARTY_ID OBJECT_VERSION_NUMBER CATEGORY_CODE
---------- --------------------- -------------11046
7 CUSTOMER

------------------------------------- 2. Update customer


-----------------------------------DECLARE
p_organization_rec HZ_PARTY_V2PUB.organization_REC_TYPE;
xin_xout_object_version_number NUMBER;
x_profile_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_organization_rec.Party_rec.party_id := 11046; --<< party_id from 1c >
xin_xout_object_version_number := 7; --<< OBJECT_VERSION_NUMBER from 1c >
p_organization_rec.party_rec.category_code := 'PROSPECT'; --<< this is
the new catregory_code >
HZ_PARTY_V2PUB.update_organization(
'T',
p_organization_rec,
xin_xout_object_version_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('xin_xout_object_version_number: '||
xin_xout_object_version_number);
dbms_output.put_line('x_profile_id: '||x_profile_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('***************************');

END;
/
***************************
Output information ....
xin_xout_object_version_number: 8
x_profile_id: 3004
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
commit;
---------------------------------------------------- 2a. Review the new data
--------------------------------------------------select
party_id
,object_version_number
,category_code
from
hz_parties
where
party_id = 11046; --< replace the party_id that obtain in the form
PARTY_ID OBJECT_VERSION_NUMBER CATEGORY_CODE
---------- --------------------- --------------11046
8 PROSPECT

---------------------------------------------------- 2b. Review the new data


--------------------------------------------------Go to Customer Standard Form and review the field Category on TAB
Classification.
It must has the new value.
***************************************************************************
************************************************
***************************************************************************
************************************************
Example about How To update A Contact Phone Information Via TCA API
(suppose that want to update phone extension for CONTACT_POINT_ID = 12414.)
------------------------------------- 1a. Setup the Org_id
------------------------------------

exec dbms_application_info.set_client_info('204');
------------------------------------- 1b. Show the output variables
-----------------------------------set serveroutput on
------------------------------------------------ 1c. Review the original phone information
----------------------------------------------col PHONE_NUMBER format a15
col PHONE_EXTENSION format a15
select
CONTACT_POINT_ID
,object_version_number
,PHONE_NUMBER
,PHONE_EXTENSION
from
hz_contact_points
where
CONTACT_POINT_ID = 12414; --< Contact_point_id that want to update
CONTACT_POINT_ID OBJECT_VERSION_NUMBER PHONE_NUMBER
PHONE_EXTENSION
---------------- --------------------- --------------- --------------12414
1 40766755
------------------------------------- 2. Update phone information
------------------------------------- in this example the phone extension will be change from NULL to '755'
DECLARE
p_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
p_phone_rec HZ_CONTACT_POINT_V2PUB.phone_rec_type;
p_object_version_number NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
p_contact_point_rec.contact_point_id := 12414; --< contact_point_id from
step 1c.
p_object_version_number := 1;
p_phone_rec.Phone_number := '40766755';
p_phone_rec.phone_extension := '755';
HZ_CONTACT_POINT_V2PUB.update_phone_contact_point(
'T',
p_contact_point_rec,
p_phone_rec,

p_object_version_number,
x_return_status,
x_msg_count,
x_msg_data
);
dbms_output.put_line('***************************');
dbms_output.put_line('Output information ....');
dbms_output.put_line('p_object_version_number: '||
p_object_version_number);
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('***************************');
END;
/
***************************
Output information ....
p_object_version_number: 2
x_return_status: S
x_msg_count: 0
x_msg_data:
***************************
------------------------------------------------ 3. Review the changed phone information
----------------------------------------------CONTACT_POINT_ID OBJECT_VERSION_NUMBER PHONE_NUMBER
PHONE_EXTENSION
---------------- --------------------- --------------- --------------12414
2 40766755
755
***************************************************************************
************************************************
***************************************************************************
************************************************

Das könnte Ihnen auch gefallen