/* Formatted on 2013/07/24 11:11 (Formatter Plus v4.8.8) */
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);
l_resource_id NUMBER;
l_bill_site_use_id NUMBER;
l_p_object_version_number NUMBER;
l_site_use_id number;
l_cust_account_id number;
CURSOR cur_contr
IS
SELECT customernumber, sitenumber, salesperson,
customersitecollectorname, customersitecollectorcode
FROM oomco_cust_master_update_j
WHERE customernumber LIKE '%Lubes%'
AND UPPER(TRIM(salesperson)) =UPPER(TRIM('Suliman Al Burtomani'))
AND salesperson not IN ('SALIM MOHAMMED AWADH AL BUSI','PRAKASH RANGARAJ','MOHAMMED SHAMEEL SHEIKH ',' KHALID HASSAN AL AWAD','#N/A','0')
ORDER BY 1;
BEGIN
FOR c1 IN cur_contr
LOOP
mo_global.init ('AR');
mo_global.set_policy_context ('S', '81');
fnd_global.apps_initialize (1131, 20678, 222, 0);
BEGIN
SELECT SALESREP_ID
INTO l_resource_id
FROM jtf_rs_resources_vl a,RA_SALESREPS_ALL rsa
WHERE a.resource_id=rsa.resource_id
and TRIM (UPPER (resource_name)) = TRIM (UPPER (c1.salesperson));
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Sales Person does not exist'
|| c1.salesperson
);
END;
BEGIN
SELECT site_use_id, hcas.CUST_ACCT_SITE_ID, hcsua.object_version_number
INTO l_site_use_id, l_cust_account_id, l_p_object_version_number
FROM hz_parties hp,
hz_party_sites hps,
hz_cust_accounts_all hca,
hz_cust_acct_sites_all hcas,
hz_cust_site_uses_all hcsua
WHERE hp.party_id = hps.party_id
AND hps.party_id = hca.party_id
AND hca.cust_account_id = hcas.cust_account_id
AND hcas.party_site_id = hps.party_site_id
AND hcas.cust_acct_site_id = hcsua.cust_acct_site_id
AND hcsua.site_use_code = 'SHIP_TO'
AND hca.account_number = c1.customernumber
AND hps.party_site_number = c1.sitenumber;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Site Number does not exist'
|| c1.customernumber
|| ' Site Number'
|| c1.sitenumber
);
END;
p_cust_site_use_rec.cust_acct_site_id := l_cust_account_id;
p_cust_site_use_rec.site_use_id := l_site_use_id;
p_cust_site_use_rec.primary_salesrep_id := l_resource_id;
hz_cust_account_site_v2pub.update_cust_site_use
(p_init_msg_list => 'T',
p_cust_site_use_rec => p_cust_site_use_rec,
p_object_version_number => l_p_object_version_number,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data
);
dbms_output.put_line('Status'|| x_return_status);
COMMIT;
END LOOP;
END;
No comments :
Post a Comment