To Create Business Purpose as Statements for Customer Site

To Create Business Purpose as Statements for Customer Site
/
SET SERVEROUTPUT ON;
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);
ln_cust_acct_id NUMBER;
lv_location VARCHAR2(240);
Cursor c1 is (select count(hcas.cust_acct_site_id) Total_bill_to_sites,
hca.cust_Account_id,hca.account_number,
(select party_name from hz_parties hp where hp.party_id=hca.party_id) Cutomer_name,
‘Available’ PRIMARY_BILL_TO
from hz_cust_accounts hca, hz_cust_acct_sites_all hcas
where hca.cust_account_id=hcas.cust_account_id
and hcas.org_id=928
–and hca.cust_account_id not in (6579443,6578104)–6574261
and exists (select 1
from hz_cust_acct_sites_all hcas1
where hcas1.BILL_TO_FLAG=’P’
and hca.cust_account_id=hcas1.cust_account_id)
group by hca.cust_Account_id,hca.account_name,hca.account_number,hca.party_id having count(hcas.cust_acct_site_id) >1);

BEGIN
— Setting the Context —

fnd_global.apps_initialize ( user_id => 24560
,resp_id => 57044
,resp_appl_id => 222);
mo_global.set_policy_context(‘S’,928);
fnd_global.set_nls_context(‘AMERICAN’);

for i in c1

loop

begin
select hcas.cust_acct_site_id,hcsu.location
into ln_cust_acct_id,lv_location
from hz_cust_acct_sites_all hcas,
hz_cust_site_uses_all hcsu
where cust_account_id = i.cust_account_id
and hcas.cust_acct_site_id=hcsu.cust_acct_site_id
and hcsu.site_use_code=’BILL_TO’
and hcsu.PRIMARY_FLAG=’Y’
and hcsu.status=’A’;

Exception when others then
DBMS_OUTPUT.PUT_LINE(‘Failed getting Cust Account site Id..’);
end;

— Initializing the Mandatory API parameters
p_cust_site_use_rec.cust_acct_site_id := ln_cust_acct_id;
p_cust_site_use_rec.site_use_code := ‘STMTS’;
p_cust_site_use_rec.location := lv_location;
p_cust_site_use_rec.created_by_module := ‘TCA_V2_API’;

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;

Recent Posts