We had a requirement to Update Supplier Name with "_DO_NOT_USE". When tried with AP_VENDOR_PUB_PKG.UPDATE_VENDOR API, it did not work. We used HZ_PARTY_V2PUB.update_organization to update Supplier Name.
Note: If you have such requirement please check with Oracle and take required action. Below code is just for testing purpose.
DECLARE
l_organization_rec hz_party_v2pub.organization_rec_type;
x_profile_id NUMBER;
l_vendor_id NUMBER := 1234;
l_party_id NUMBER;
l_object_version_number NUMBER;
l_msg_count NUMBER;
l_msg_data VARCHAR2(4000);
l_return_status VARCHAR2(10);
l_user_id fnd_user.user_id%TYPE;
l_resp_id fnd_responsibility_tl.responsibility_id%TYPE;
l_resp_appl_id fnd_responsibility_tl.application_id%TYPE;
l_org_id hr_operating_units.organization_id%TYPE;
CURSOR c1
IS
SELECT aps.party_id
,aps.vendor_name||'_DO_NOT_USE' vendor_name
,hzp.object_version_number
FROM ap_suppliers aps
,hz_parties hzp
WHERE aps.party_id = hzp.party_id
AND TRUNC(aps.creation_date) < TRUNC(SYSDATE-2)
;
begin
BEGIN
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = 'XX_USER';
EXCEPTION
WHEN OTHERS THEN
l_user_id := NULL;
END;
BEGIN
SELECT responsibility_id, application_id
INTO l_resp_id, l_resp_appl_id
FROM fnd_responsibility_tl
WHERE responsibility_name = 'Payables Manager'
AND language = USERENV('LANG')
;
EXCEPTION
WHEN OTHERS THEN
l_resp_id := NULL;
l_resp_appl_id := NULL;
END;
BEGIN
SELECT organization_id
INTO l_org_id
FROM hr_operating_units
WHERE name = 'XX Operating Unit';
EXCEPTION
WHEN OTHERS THEN
l_org_id := NULL;
END;
-- Initialize apps session
fnd_global.apps_initialize(user_id => l_user_id
,resp_id => l_resp_id
,resp_appl_id => l_resp_appl_id
);
mo_global.init('SQLAP');
fnd_client_info.set_org_context(l_org_id);
FOR i IN c1
LOOP
l_organization_rec.party_rec.party_id := i.party_id;
l_organization_rec.organization_name := i.vendor_name;
HZ_PARTY_V2PUB.update_organization (
p_init_msg_list => fnd_api.g_true,
p_organization_rec => l_organization_rec,
p_party_object_version_number => i.object_version_number,
x_profile_id => x_profile_id,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
FOR I IN 1..l_msg_count
LOOP
l_msg_data := l_msg_data||SUBSTR(FND_MSG_PUB.GET(p_encoded=>'T'),1,255);
dbms_output.put_line(l_msg_data);
END LOOP ;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
Thanks for sharing. I wasted lot of time to find the solution. Thanks a lot.
ReplyDeleteThanks for sharing information.keep up good work.
ReplyDelete