DECLARE
x_return_status VARCHAR2 (200) := NULL;
x_msg_count NUMBER := 0;
x_msg_data VARCHAR2 (200) := NULL;
t_output VARCHAR2 (200) := NULL;
t_msg_dummy VARCHAR2 (200) := NULL;
l_payee_upd_status iby_disbursement_setup_pub.ext_payee_update_tab_type;
p_external_payee_tab_type iby_disbursement_setup_pub.external_payee_tab_type;
p_ext_payee_id_tab_type iby_disbursement_setup_pub.ext_payee_id_tab_type;
i NUMBER := 0;
cursor c1 is
select
b.org_id
,e.ext_payee_id
,e.payee_party_id
,e.supplier_site_id
,e.party_site_id payee_party_site_id,
case when e.remit_advice_email is not null then (‘xxx’)
when e.remit_advice_email is null then ‘yyy’ end email_address
from
ap_suppliers a
,ap_supplier_sites_all b
,iby_external_payees_all e
where 1=1
and a.vendor_id = b.vendor_id
and b.vendor_site_id = e.supplier_site_id
and b.org_id=382
AND a.end_date_active IS NULL
AND b.inactive_date IS NULL
order by a.segment1;
BEGIN
FOR rec IN c1
LOOP
fnd_global.apps_initialize(
user_id => 43272,
resp_id => 54240,
resp_appl_id => 200
);
MO_GLOBAL.INIT(‘SQLAP’);
mo_global.set_policy_context(‘S’,382);
i := i + 1;
p_external_payee_tab_type (i).Remit_advice_delivery_method := ‘EMAIL’;
p_external_payee_tab_type (i).Remit_advice_email :=rec.email_address;
p_external_payee_tab_type (i).payment_function := ‘PAYABLES_DISB’;
p_external_payee_tab_type (i).exclusive_pay_flag := ‘N’;
p_external_payee_tab_type (i).payer_org_type := ‘OPERATING_UNIT’;
p_external_payee_tab_type (i).payer_org_id := rec.org_id;
p_ext_payee_id_tab_type (i).ext_payee_id := rec.ext_payee_id;
p_external_payee_tab_type (i).payee_party_id := rec.payee_party_id;
p_external_payee_tab_type (i).supplier_site_id := rec.supplier_site_id;
p_external_payee_tab_type (i).Payee_Party_Site_Id := rec.Payee_Party_Site_Id;
IBY_DISBURSEMENT_SETUP_PUB.UPDATE_EXTERNAL_PAYEE
(p_api_version => 1.0,
p_init_msg_list => ‘T’,
p_ext_payee_tab => p_external_payee_tab_type,
p_ext_payee_id_tab => p_ext_payee_id_tab_type,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_ext_payee_status_tab => l_payee_upd_status);
IF x_return_status <> ‘S’
THEN
IF x_msg_count > 0
THEN
FOR i IN 1 .. x_msg_count
LOOP
fnd_msg_pub.get (i,fnd_api.g_false,x_msg_data,t_msg_dummy);
–DBMS_OUTPUT.put_line (‘Error Message : ‘ || x_msg_data);
t_output := (TO_CHAR (i) || ‘: ‘ || x_msg_data);
END LOOP;
END IF;
DBMS_OUTPUT.put_line ( ‘Error occured while updating the Payment Details ‘ ||rec.supplier_site_id|| t_output);
ELSE
COMMIT;
END IF;
/*FOR j IN l_payee_upd_status.FIRST .. l_payee_upd_status.LAST
LOOP
DBMS_OUTPUT.put_line (‘Error Message from table type : ‘|| l_payee_upd_status (j).payee_update_msg);
END LOOP;*/
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE (‘Error ‘ || SQLERRM);
END;