DECLARE
p_cust_account_rec hz_cust_account_v2pub.cust_account_rec_type;
p_customer_profile_rec hz_customer_profile_v2pub.customer_profile_rec_type;
p_person_rec hz_party_v2pub.person_rec_type;
p_organization_rec hz_party_v2pub.organization_rec_type;
v_party_type VARCHAR2 (30);
x_party_id NUMBER;
x_party_number VARCHAR2 (100);
x_profile_id NUMBER;
x_return_status VARCHAR2 (100);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (100);
x_cust_account_id NUMBER;
x_account_number VARCHAR2 (100);
p_init_msg_list VARCHAR2 (30);
l_msg_index_out NUMBER;
l_error_message VARCHAR2 (100);
BEGIN
v_party_type := '&party_type';
p_cust_account_rec.created_by_module := 'TCA_V2_API';
IF upper(v_party_type) = 'PERSON'
THEN
p_person_rec.person_first_name := '&p_person_first_name';
p_person_rec.person_last_name := '&p_person_last_name';
hz_cust_account_v2pub.create_cust_account
(p_init_msg_list => 'T',
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_profile_id => x_profile_id,
x_party_number => x_party_number,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data
);
ELSIF upper(v_party_type) = 'ORGANIZATION'
THEN
p_organization_rec.organization_name := '&p_org_name';
hz_cust_account_v2pub.create_cust_account
(p_init_msg_list => 'T',
p_cust_account_rec => p_cust_account_rec,
p_organization_rec => p_organization_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_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_party_id => x_party_id,
x_party_number => x_party_number,
x_profile_id => x_profile_id
);
END IF;
IF x_return_status = fnd_api.g_ret_sts_success
THEN
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_account_number:' || x_account_number);
ELSE
IF x_msg_count > 0
THEN
FOR i IN 1 .. x_msg_count
LOOP
apps.fnd_msg_pub.get (p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => x_msg_data,
p_msg_index_out => l_msg_index_out
);
END LOOP;
IF l_error_message IS NULL
THEN
l_error_message := SUBSTR (x_msg_data, 1, 250);
ELSE
l_error_message :=
l_error_message || ' /' || SUBSTR (x_msg_data, 1, 250);
END IF;
DBMS_OUTPUT.put_line ('*****************************************');
DBMS_OUTPUT.put_line ('API Error: ' || l_error_message);
DBMS_OUTPUT.put_line ('*****************************************');
END IF;
END IF;
END;
p_cust_account_rec hz_cust_account_v2pub.cust_account_rec_type;
p_customer_profile_rec hz_customer_profile_v2pub.customer_profile_rec_type;
p_person_rec hz_party_v2pub.person_rec_type;
p_organization_rec hz_party_v2pub.organization_rec_type;
v_party_type VARCHAR2 (30);
x_party_id NUMBER;
x_party_number VARCHAR2 (100);
x_profile_id NUMBER;
x_return_status VARCHAR2 (100);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (100);
x_cust_account_id NUMBER;
x_account_number VARCHAR2 (100);
p_init_msg_list VARCHAR2 (30);
l_msg_index_out NUMBER;
l_error_message VARCHAR2 (100);
BEGIN
v_party_type := '&party_type';
p_cust_account_rec.created_by_module := 'TCA_V2_API';
IF upper(v_party_type) = 'PERSON'
THEN
p_person_rec.person_first_name := '&p_person_first_name';
p_person_rec.person_last_name := '&p_person_last_name';
hz_cust_account_v2pub.create_cust_account
(p_init_msg_list => 'T',
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_profile_id => x_profile_id,
x_party_number => x_party_number,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data
);
ELSIF upper(v_party_type) = 'ORGANIZATION'
THEN
p_organization_rec.organization_name := '&p_org_name';
hz_cust_account_v2pub.create_cust_account
(p_init_msg_list => 'T',
p_cust_account_rec => p_cust_account_rec,
p_organization_rec => p_organization_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_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_party_id => x_party_id,
x_party_number => x_party_number,
x_profile_id => x_profile_id
);
END IF;
IF x_return_status = fnd_api.g_ret_sts_success
THEN
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_account_number:' || x_account_number);
ELSE
IF x_msg_count > 0
THEN
FOR i IN 1 .. x_msg_count
LOOP
apps.fnd_msg_pub.get (p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => x_msg_data,
p_msg_index_out => l_msg_index_out
);
END LOOP;
IF l_error_message IS NULL
THEN
l_error_message := SUBSTR (x_msg_data, 1, 250);
ELSE
l_error_message :=
l_error_message || ' /' || SUBSTR (x_msg_data, 1, 250);
END IF;
DBMS_OUTPUT.put_line ('*****************************************');
DBMS_OUTPUT.put_line ('API Error: ' || l_error_message);
DBMS_OUTPUT.put_line ('*****************************************');
END IF;
END IF;
END;
No comments:
Post a Comment