Anda di halaman 1dari 3

/* Formatted on 11/21/2016 9:49:30 AM (QP5 v5.256.13226.

35538) */
DECLARE
/*Creates the customer and customer profile Data*/
custAcccountRec
HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
custProfileRec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
custOrgRec
HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
custPartyRec
HZ_PARTY_V2PUB.PARTY_REC_TYPE;
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

NUMBER;
VARCHAR2
NUMBER;
VARCHAR2
NUMBER;
VARCHAR2
NUMBER;
VARCHAR2

(30);
(30);
(3);
(3000);

l_collector_id
NUMBER;
l_user_id
NUMBER;
l_resp_id
NUMBER;
l_resp_appl_id NUMBER;
vMsgDummy
VARCHAR2 (5000);
lErrMsg
VARCHAR2 (5000);
BEGIN
DBMS_OUTPUT.PUT_LINE ('In createCustomer Procedure.');
BEGIN
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = 'NGUNTI';
END;
BEGIN
SELECT responsibility_id, application_id
INTO l_resp_id, l_resp_appl_id
FROM fnd_responsibility_tl
WHERE responsibility_name = 'Order Management Super User' ;
END;
mo_global.init ('AR');
fnd_global.apps_initialize ( l_user_id, l_resp_id, l_resp_appl_id ) ; -- pass
in user_id, responsibility_id, and application_id
mo_global.set_policy_context ('S', 103); --103 is the org_id that I am using
for the organization
-----

SELECT
INTO
FROM
WHERE

collector_id
l_collector_id
ar_collectors
name = 'Arun Raj';

--Values assigned to the Customer Account Record Type


custAcccountRec.account_number := newCustRec.account_number;
custAcccountRec.attribute_category := newCustRec.cust_att_category;
custAcccountRec.customer_type
:= 'R';
custAcccountRec.attribute1
:= '198216';
custAcccountRec.attribute7
:= TO_DATE(SYSDATE, 'DD-MON-RRRR HH24:M
I:SS');
custAcccountRec.attribute15
:= 'US';
custAcccountRec.attribute17
:= '90960972';
custAcccountRec.customer_class_code := 'GOV';
custAcccountRec.sales_channel_code := 'DIRECT';
---

custAcccountRec.price_list_id
:= 12042;
custAcccountRec.tax_header_level_flag := 'N';
custAcccountRec.account_name
:= 'Test_FennerAccN12';
custAcccountRec.created_by_module := 'TCA_V2_API';
custAcccountRec.status := 'A';
--Status is Active
custAcccountRec.created_by_module := 'TCA_V2_API';
custAcccountRec.ship_sets_include_lines_flag := 'N';
custAcccountRec.arrivalsets_include_lines_flag := 'N';
custAcccountRec.sched_date_push_flag
:= 'N';
--

--Values assinged to the Party Record Type.


custPartyRec.orig_system_reference := newCustRec.orig_system_reference;
custPartyRec.status
:= 'A';
custPartyRec.category_code := 'HOSTED';
custPartyRec.attribute1
:= '198640';
custPartyRec.attribute15 := 'US';
custPartyRec.gsa_indicator_flag := 'N';
--Values assinged to the Organization Record Type. Party Type = Organizati

on
custOrgRec.organization_name
:= 'Test_FennerAccN12';
custOrgRec.created_by_module
:= 'TCA_V2_API';
custOrgRec.party_rec := custPartyRec;

--

/*Get Profile Details as well*/


custProfileRec.profile_class_id := 0;
custProfileRec.collector_id
:= 1001;
custProfileRec.credit_checking := 'Y';
custProfileRec.tolerance
:= 0;
custProfileRec.discount_terms := 'N';
custProfileRec.dunning_letters := 'N';
custProfileRec.interest_charges := 'Y';
custProfileRec.send_statements := 'N';
custProfileRec.credit_balance_statements := 'N';
custProfileRec.credit_hold := newCustRec.credit_hold;
/*API to create customer account, party and customer profile*/
HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT (
p_init_msg_list
=> FND_API.G_TRUE,
p_cust_account_rec
=> custAcccountRec,
p_organization_rec
=> custOrgRec,
p_customer_profile_rec => custProfileRec,
p_create_profile_amt
=> FND_API.G_TRUE,
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 Organization and customer account is Succ
essful ');
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 Organization and customer account fail
ed:'
|| 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;
COMMIT;
END;

Anda mungkin juga menyukai