CREATE OR REPLACE procedure APPS.UPDATE_CUST_COLL_PROF(ERRBUF OUT VARCHAR2
,RETCODE OUT VARCHAR2)
AS
l_customer_profile_rec_type hz_customer_profile_v2pub.customer_profile_rec_type;
l_object_version_number NUMBER;
l_return_status VARCHAR2 (10);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
l_customer_number NUMBER;
l_customer_name VARCHAR2(100);
l_collector_name VARCHAR2(100);
l_CUST_ACCOUNT_PROFILE_ID NUMBER;
l_process VARCHAR2(3) :='N';
l_cust_account_id VARCHAR2(100);
l_collector_id VARCHAR2(100);
CURSOR cur_coll
IS
SELECT xct.*,rowid row_id
FROM temp_custgrcol_tab xct
WHERE 1=1;
BEGIN
fnd_global.apps_initialize (user_id => 1318,
resp_id => 50559,
resp_appl_id => 222
);
mo_global.set_policy_context ('M','');
for rec_coll in cur_coll
loop
-- UPDATE_CUST_PROFILE.collector_name
--START VALIDATION FOR THE REQUIRED COLUMNS
-- when u r doing the validation, assign the value for l_return_status like ('S' FOR SUCCESS, 'E' FOR ERROR).
--END VALIDATION FOR THE REQUIRED COLUMNS
begin
select hcp.CUST_ACCOUNT_PROFILE_ID,hca.CUST_ACCOUNT_ID
into l_CUST_ACCOUNT_PROFILE_ID , l_cust_account_id
from hz_customer_profiles hcp,
hz_cust_accounts hca
where hcp.CUST_ACCOUNT_ID = hca.CUST_ACCOUNT_ID
and hca.account_number =rec_coll.customer_number
and hcp.site_use_id is null;
dbms_output.put_line('Id is:'||l_CUST_ACCOUNT_PROFILE_ID);
exception
when no_data_found then
l_process :='Y';
when others then
l_process :='Y';
end;
/* Collector ID Receiving...*/
begin
select collector_id
into l_collector_id
from ar_collectors where 1=1
and name = (select collector_name FROM temp_custgrcol_tab xct
WHERE 1=1
and xct.CUSTOMER_NUMBER=rec_coll.customer_number);
exception
when others then
dbms_output.put_line('Id is not received for '||rec_coll.customer_number);
end;
/* Initializing the Mandatory API parameters */
l_customer_profile_rec_type.cust_account_profile_id := l_CUST_ACCOUNT_PROFILE_ID;
l_customer_profile_rec_type.cust_account_id := l_cust_account_id;
l_customer_profile_rec_type.collector_id :=l_collector_id;
SELECT object_version_number
INTO l_object_version_number
from hz_customer_profiles
WHERE cust_account_profile_id = l_cust_account_profile_id;
fnd_file.put_line(fnd_file.log,'Calling the API hz_customer_profile_v2pub.update_customer_profile');
hz_customer_profile_v2pub.update_customer_profile
(
p_init_msg_list => fnd_api.g_true,
p_customer_profile_rec => l_customer_profile_rec_type,
p_object_version_number => l_object_version_number,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
IF l_return_status = fnd_api.g_ret_sts_success
THEN
COMMIT;
fnd_file.put_line(fnd_file.log, 'Updation of Customer Profile is Successful '||l_cust_account_profile_id);
fnd_file.put_line(fnd_file.log, 'Output information ....');
fnd_file.put_line(fnd_file.log, 'Object Version Number = '||l_object_version_number );
fnd_file.put_line(fnd_file.log, 'Updation of Customer Profile is Successful '||l_cust_account_profile_id);
fnd_file.put_line(fnd_file.log, 'Output information ....');
fnd_file.put_line(fnd_file.log, 'Object Version Number = '||l_object_version_number );
update temp_custgrcol_tab
set STATUS_FLAG = 'S'
where rowid = rec_coll.row_id;
ELSE
fnd_file.put_line ( fnd_file.log, 'Updation of Customer Profile got failed:'
|| l_msg_data
);
fnd_file.put_line(fnd_file.log, 'Updation of Customer Profile got failed:'
|| l_msg_data
);
ROLLBACK;
update temp_custgrcol_tab
set STATUS_FLAG = 'E'
where rowid = rec_coll.row_id;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.log,SQLCODE||','||SQLERRM);
fnd_file.put_line (fnd_file.log,'Completion of API');
END UPDATE_CUST_COLL_PROF;
/
,RETCODE OUT VARCHAR2)
AS
l_customer_profile_rec_type hz_customer_profile_v2pub.customer_profile_rec_type;
l_object_version_number NUMBER;
l_return_status VARCHAR2 (10);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
l_customer_number NUMBER;
l_customer_name VARCHAR2(100);
l_collector_name VARCHAR2(100);
l_CUST_ACCOUNT_PROFILE_ID NUMBER;
l_process VARCHAR2(3) :='N';
l_cust_account_id VARCHAR2(100);
l_collector_id VARCHAR2(100);
CURSOR cur_coll
IS
SELECT xct.*,rowid row_id
FROM temp_custgrcol_tab xct
WHERE 1=1;
BEGIN
fnd_global.apps_initialize (user_id => 1318,
resp_id => 50559,
resp_appl_id => 222
);
mo_global.set_policy_context ('M','');
for rec_coll in cur_coll
loop
-- UPDATE_CUST_PROFILE.collector_name
--START VALIDATION FOR THE REQUIRED COLUMNS
-- when u r doing the validation, assign the value for l_return_status like ('S' FOR SUCCESS, 'E' FOR ERROR).
--END VALIDATION FOR THE REQUIRED COLUMNS
begin
select hcp.CUST_ACCOUNT_PROFILE_ID,hca.CUST_ACCOUNT_ID
into l_CUST_ACCOUNT_PROFILE_ID , l_cust_account_id
from hz_customer_profiles hcp,
hz_cust_accounts hca
where hcp.CUST_ACCOUNT_ID = hca.CUST_ACCOUNT_ID
and hca.account_number =rec_coll.customer_number
and hcp.site_use_id is null;
dbms_output.put_line('Id is:'||l_CUST_ACCOUNT_PROFILE_ID);
exception
when no_data_found then
l_process :='Y';
when others then
l_process :='Y';
end;
/* Collector ID Receiving...*/
begin
select collector_id
into l_collector_id
from ar_collectors where 1=1
and name = (select collector_name FROM temp_custgrcol_tab xct
WHERE 1=1
and xct.CUSTOMER_NUMBER=rec_coll.customer_number);
exception
when others then
dbms_output.put_line('Id is not received for '||rec_coll.customer_number);
end;
/* Initializing the Mandatory API parameters */
l_customer_profile_rec_type.cust_account_profile_id := l_CUST_ACCOUNT_PROFILE_ID;
l_customer_profile_rec_type.cust_account_id := l_cust_account_id;
l_customer_profile_rec_type.collector_id :=l_collector_id;
SELECT object_version_number
INTO l_object_version_number
from hz_customer_profiles
WHERE cust_account_profile_id = l_cust_account_profile_id;
fnd_file.put_line(fnd_file.log,'Calling the API hz_customer_profile_v2pub.update_customer_profile');
hz_customer_profile_v2pub.update_customer_profile
(
p_init_msg_list => fnd_api.g_true,
p_customer_profile_rec => l_customer_profile_rec_type,
p_object_version_number => l_object_version_number,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
IF l_return_status = fnd_api.g_ret_sts_success
THEN
COMMIT;
fnd_file.put_line(fnd_file.log, 'Updation of Customer Profile is Successful '||l_cust_account_profile_id);
fnd_file.put_line(fnd_file.log, 'Output information ....');
fnd_file.put_line(fnd_file.log, 'Object Version Number = '||l_object_version_number );
fnd_file.put_line(fnd_file.log, 'Updation of Customer Profile is Successful '||l_cust_account_profile_id);
fnd_file.put_line(fnd_file.log, 'Output information ....');
fnd_file.put_line(fnd_file.log, 'Object Version Number = '||l_object_version_number );
update temp_custgrcol_tab
set STATUS_FLAG = 'S'
where rowid = rec_coll.row_id;
ELSE
fnd_file.put_line ( fnd_file.log, 'Updation of Customer Profile got failed:'
|| l_msg_data
);
fnd_file.put_line(fnd_file.log, 'Updation of Customer Profile got failed:'
|| l_msg_data
);
ROLLBACK;
update temp_custgrcol_tab
set STATUS_FLAG = 'E'
where rowid = rec_coll.row_id;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.log,SQLCODE||','||SQLERRM);
fnd_file.put_line (fnd_file.log,'Completion of API');
END UPDATE_CUST_COLL_PROF;
/
Awesome, very helpful. Thanks!
ReplyDelete