API to create a Person Type Party and Customer Account TCA R12 (HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT)
DESCRIPTION:
This routine is used to create a Customer Account.
The API creates a record in the HZ_CUST_ACCOUNTS table for party type
Person. Account can be created for an existing party by passing party_id
of the party. Alternatively, this routine creates a new party and an
account for the party. Customer profile record in the
HZ_CUSTOMER_PROFILES table can also be created while calling this
routine based
on value passed in p_customer_profile_rec. The routine
is overloaded for Person and Organization. If an orig_system_reference
is passed in, the API creates a record in the HZ_ORIG_SYS_REFERENCES
table to store the mapping between the source system reference and the
TCA primary key. If orig_system_reference is not passed in, the default is UNKNOWN.
API: HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT
BASE TABLES AFFECTED : HZ_PARTIES, HZ_CUST_ACCOUNTS , HZ_CUSTOMER_PROFILES
TEST INSTANCE : R12.1.3
NOTE: p_create_profile_amt
indicates whether to create profile amounts for the customer profile
being created. If value equals to FND_API.G_TRUE, profile amounts will
be created by copying over the profile amounts for the profile class on which this customer profile is based.
SCRIPT:
SET SERVEROUTPUT ON;
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
-- Setting the Context --
mo_global.init('AR');
fnd_global.apps_initialize ( user_id => 1318
,resp_id => 50559
,resp_appl_id => 222);
mo_global.set_policy_context('S',204);
fnd_global.set_nls_context('AMERICAN');
-- Initializing the Mandatory API parameters
p_cust_account_rec.account_name := 'TEST_PERSON_ACCT';
p_cust_account_rec.created_by_module := 'BO_API';
p_person_rec.person_first_name := 'Team';
p_person_rec.person_last_name := 'Search';
DBMS_OUTPUT.PUT_LINE('Calling the API hz_cust_account_v2pub.create_cust_account');
HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT
(
p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec =>p_cust_account_rec,
p_person_rec =>p_person_rec,
p_customer_profile_rec=>p_customer_profile_rec,
p_create_profile_amt =>'F',
x_cust_account_id =>x_cust_account_id,
x_account_number =>x_account_number,
x_party_id =>x_party_id,
x_party_number =>x_party_number,
x_profile_id =>x_profile_id,
x_return_status =>x_return_status,
x_msg_count => x_msg_count,
x_msg_data =>x_msg_data
);
IF x_return_status = fnd_api.g_ret_sts_success THEN
COMMIT;
DBMS_OUTPUT.PUT_LINE('Creation of Party of Type Person and customer account is Successful ');
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);
ELSE
DBMS_OUTPUT.put_line ('Creation of Party of Type Person and customer account failed:'||x_msg_data);
ROLLBACK;
FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| x_msg_data);
END LOOP;
END IF;
DBMS_OUTPUT.PUT_LINE('Completion of API');
END;
/
VERFICATION SCRIPT:
SELECT party_id,
party_number,
party_name,
person_last_name,
person_first_name,
object_version_number,
created_by_module
FROM hz_parties
WHERE party_id = '5426';
SELECT person_profile_id,
party_id,
effective_start_date,
object_version_number,
created_by_module
FROM hz_person_profiles
WHERE person_profile_id = '4524';
No comments:
Post a Comment