/*DESCRIPTION:
This procedure creates a site use for the customer account site.
API: HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_SITE_USE
BASE TABLES AFFECTED : HZ_CUST_SITE_USES
TEST INSTANCE : R12.1.3
SCRIPT:
SET SERVEROUTPUT ON;*/
------------------------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);
CURSOR cur_customer IS select * from CUST_DATA_CKBP_STG where PROCESS_FLAG = 'P';
BEGIN
-- Setting the Context --
mo_global.init('AR');
fnd_global.apps_initialize ( user_id => 0
,resp_id => 50859
,resp_appl_id => 7000);
mo_global.set_policy_context('S',83);--Chikkaballapura
fnd_global.set_nls_context('AMERICAN');
FOR v_cust_rec IN cur_customer
LOOP
-- Initializing the Mandatory API parameters
p_cust_site_use_rec.cust_acct_site_id := v_cust_rec.x_cust_acct_site_id;--x_cust_acct_site_id;
p_cust_site_use_rec.site_use_code := 'BILL_TO';
p_cust_site_use_rec.created_by_module := 'TCA_V2_API';
p_cust_site_use_rec.primary_flag := 'Y';
p_cust_site_use_rec.org_id := 83;
p_cust_site_use_rec.payment_term_id := 5 ; ---IMMEDIATE
DBMS_OUTPUT.PUT_LINE('Calling the API hz_cust_account_site_v2pub.create_cust_site_use');
HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_SITE_USE
(
p_init_msg_list => FND_API.G_TRUE,
p_cust_site_use_rec => p_cust_site_use_rec,
p_customer_profile_rec => p_customer_profile_rec,
p_create_profile => FND_API.G_TRUE,
p_create_profile_amt => FND_API.G_TRUE,
x_site_use_id => x_site_use_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 Customer Accnt Site use is Successful ');
DBMS_OUTPUT.PUT_LINE('Output information ....');
DBMS_OUTPUT.PUT_LINE('Site Use Id = '||x_site_use_id);
DBMS_OUTPUT.PUT_LINE('Site Use = '||p_cust_site_use_rec.site_use_code);
ELSE
DBMS_OUTPUT.put_line ('Creation of Customer Accnt Site use got failed:'||x_msg_data);
ROLLBACK;
FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| x_msg_data);
END LOOP;
END IF;
end loop;
DBMS_OUTPUT.PUT_LINE('Completion of API');
END;
/
------------------------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);
CURSOR cur_customer IS select * from CUST_DATA_CKBP_STG where PROCESS_FLAG = 'P';
BEGIN
-- Setting the Context --
mo_global.init('AR');
fnd_global.apps_initialize ( user_id => 0
,resp_id => 50859
,resp_appl_id => 7000);
mo_global.set_policy_context('S',83); --CHIKKABALLAPURA
fnd_global.set_nls_context('AMERICAN');
FOR v_cust_rec IN cur_customer
LOOP
-- Initializing the Mandatory API parameters
p_cust_site_use_rec.cust_acct_site_id := v_cust_rec.x_cust_acct_site_id;--13071;--x_cust_acct_site_id;
p_cust_site_use_rec.site_use_code := 'SHIP_TO';
p_cust_site_use_rec.created_by_module := 'TCA_V2_API';
-- p_cust_site_use_rec.primary_flag := 'Y';
p_cust_site_use_rec.org_id := 83;
p_cust_site_use_rec.payment_term_id := 5 ; ---IMMEDIATE
DBMS_OUTPUT.PUT_LINE('Calling the API hz_cust_account_site_v2pub.create_cust_site_use');
HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_SITE_USE
(
p_init_msg_list => FND_API.G_TRUE,
p_cust_site_use_rec => p_cust_site_use_rec,
p_customer_profile_rec => p_customer_profile_rec,
p_create_profile => FND_API.G_TRUE,
p_create_profile_amt => FND_API.G_TRUE,
x_site_use_id => x_site_use_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 Customer Accnt Site use is Successful ');
DBMS_OUTPUT.PUT_LINE('Output information ....');
DBMS_OUTPUT.PUT_LINE('Site Use Id = '||x_site_use_id);
DBMS_OUTPUT.PUT_LINE('Site Use = '||p_cust_site_use_rec.site_use_code);
ELSE
DBMS_OUTPUT.put_line ('Creation of Customer Accnt Site use got failed:'||x_msg_data);
ROLLBACK;
FOR i IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| x_msg_data);
END LOOP;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Completion of API');
END;
/
/*
VERFICATION SCRIPT:
SELECT site_use_id,
cust_acct_site_id,
site_use_code,
location,
org_id
FROM hz_cust_site_uses_all
WHERE cust_acct_site_id = 14058;
*/