Вы находитесь на странице: 1из 2

create or replace procedure pure_cust_mc_updation (errbuf OUT

VARCHAR2,
rectcode OUT VARCHAR2)
as
--DECLARE
p_cust_account_rec HZ_CUST_ACCOUNT_SITE_V2PUB.cust_acct_site_rec_type;
p_object_version_number NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
v_count number := 0;

Cursor c1 is
select
b.*,d.cust_acct_site_id,a.customer_id,a.status,d.attribute2,d.attribute3,d.object_v
ersion_number
from ar_customers a,
pure_customer_market_circle b,
hz_cust_accounts c,
hz_cust_acct_sites_all d,
hz_cust_site_uses_all e
where a.customer_number = b.customer_number
and a.customer_id = c.cust_account_id
and c.cust_account_id = d.cust_account_id
and e.cust_acct_site_id = d.cust_acct_site_id
and e.site_use_id = b.cust_site_use_id
--and a.status = 'A'
and e.SITE_USE_CODE = 'BILL_TO'
and e.STATUS = 'A'
and b.market_code is not null ;

/*select
b.*,a.customer_id,a.status,a.attribute2,a.attribute3,c.object_version_number
from ar_customers a,
pure_customer_market_circle b,
hz_cust_accounts c
where a.customer_number = b.customer_number
and a.customer_id = c.cust_account_id
--and a.status = 'A'
and b.market_code is not null ;*/

BEGIN
-- Setting the Context --
mo_global.init('AR');
fnd_global.apps_initialize ( user_id => 1130
,resp_id => 50855
,resp_appl_id => 222);
--mo_global.set_policy_context('S',85);
fnd_global.set_nls_context('AMERICAN');
for i in c1 loop

p_cust_account_rec.cust_acct_site_id := i.cust_acct_site_id;
p_object_version_number:=i.object_version_number;
p_cust_account_rec.attribute2:=i.market_code;
p_cust_account_rec.attribute3:=i.area_of_operation;

DBMS_OUTPUT.PUT_LINE('Calling the API hz_cust_account_v2pub.update_cust_account');


fnd_file.put_line (fnd_file.LOG,'Calling the API
hz_cust_account_v2pub.update_cust_account');
/*HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT
(
p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec => p_cust_account_rec,
p_object_version_number => p_object_version_number,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data
);*/

hz_cust_account_site_v2pub.update_cust_acct_site (FND_API.G_TRUE,
p_cust_account_rec,
p_object_version_number,
x_return_status,
x_msg_count,
x_msg_data);

IF x_return_status = fnd_api.g_ret_sts_success THEN


-- COMMIT;
DBMS_OUTPUT.PUT_LINE('Updation of Customer Account is Successful ');
DBMS_OUTPUT.PUT_LINE('Output information ....');
dbms_output.put_line('Object Version Number ='||p_object_version_number);
fnd_file.put_line (fnd_file.LOG,'Updation of Customer Account is Successful ');
fnd_file.put_line (fnd_file.LOG,'Output information ....');
fnd_file.put_line (fnd_file.LOG,'Object Version Number ='||
p_object_version_number);

ELSE
DBMS_OUTPUT.put_line ('Updation of Customer Account got failed:'||x_msg_data);
fnd_file.put_line (fnd_file.LOG,'Updation of Customer Account 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);
fnd_file.put_line (fnd_file.LOG,i|| ') '|| x_msg_data);
END LOOP;
END IF;
commit;
delete pure_customer_market_circle
where CUST_SITE_USE_ID = i.CUST_SITE_USE_ID;
commit;
v_count := v_count + 1;
end loop;
DBMS_OUTPUT.PUT_LINE('Completion of API');
DBMS_OUTPUT.PUT_LINE('Total Count : '||v_count);
fnd_file.put_line (fnd_file.LOG,'Completion of API');
fnd_file.put_line (fnd_file.LOG,'Total Count : '||v_count);
END;

Вам также может понравиться