UPDATE Organization Details Through API:
/********************************UPDATE ORGANIZATION*****************************************/
DECLARE
l_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
l_party_rec HZ_PARTY_V2PUB.PARTY_REC_TYPE;
l_party_obj_version NUMBER := 1;
x_profile_id NUMBER;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(4000);
BEGIN
l_party_rec.party_id := 5297;
l_party_rec.status := 'I';
l_organization_rec.organization_name := 'TEST_ORG';
l_organization_rec.party_rec := l_party_rec;
HZ_PARTY_V2PUB.update_organization(p_init_msg_list => FND_API.G_TRUE,
p_organization_rec => l_organization_rec,
p_party_object_version_number => l_party_obj_version,
x_profile_id => x_profile_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data);
DBMS_OUTPUT.PUT_LINE('API Status: '||x_return_status);
IF (x_return_status <> 'S')
THEN
DBMS_OUTPUT.PUT_LINE('ERROR :'|| x_msg_data );
END IF;
DBMS_OUTPUT.PUT_LINE('update_organization is completed');
--COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error::::'||SQLERRM);
ROLLBACK;
END;
/*********************UPDATE ALL ORGANIZATIONS***************************************/
===================================================================================================================
CREATE OR REPLACE PROCEDURE APPS.xxlr_update_org
IS
l_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
l_party_rec HZ_PARTY_V2PUB.PARTY_REC_TYPE;
l_party_obj_version NUMBER := 1;
x_profile_id NUMBER;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(4000);
l_success_count NUMBER := 0;
l_failure_count NUMBER := 0;
l_all_count NUMBER := 0;
BEGIN
FOR i IN (SELECT party_id
FROM hz_parties
WHERE party_type = 'ORGANIZATION'
AND party_name <> 'TEST_ORG'
AND status ='A'
)
LOOP
l_all_count := l_all_count + 1;
--DBMS_OUTPUT.PUT_LINE('Party_id='||i.party_id);
l_party_rec.party_id := i.party_id;
l_party_rec.status := 'I';
l_organization_rec.organization_name := 'TEST_ORG';
l_organization_rec.party_rec := l_party_rec;
SELECT max(object_version_number)
INTO l_party_obj_version
FROM hz_parties
WHERE party_id = i.party_id
AND status ='A';
HZ_PARTY_V2PUB.update_organization(p_init_msg_list => FND_API.G_TRUE,
p_organization_rec => l_organization_rec,
p_party_object_version_number => l_party_obj_version,
x_profile_id => x_profile_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data);
--DBMS_OUTPUT.PUT_LINE(x_return_status);
IF (x_return_status <> 'S')
THEN
DBMS_OUTPUT.PUT_LINE('Object Version: '||l_party_obj_version );
l_failure_count := l_failure_count + 1;
fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
p_count => x_msg_count,
p_data => x_msg_data);
IF x_msg_count = 1
THEN
DBMS_OUTPUT.PUT_LINE('ERROR Party_id = '||i.party_id ||';'|| x_msg_data );
ELSE
FOR j IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get(fnd_msg_pub.g_next,fnd_api.g_false);
DBMS_OUTPUT.PUT_LINE('ERROR Party_id = '||i.party_id ||';'|| x_msg_data );
END LOOP;
END IF;
ELSE
l_success_count := l_success_count + 1;
IF MOD(l_success_count,100)=0
THEN
COMMIT;
END IF;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('+--------------------------------------+');
DBMS_OUTPUT.PUT_LINE(' Total Record count : '||L_ALL_COUNT);
DBMS_OUTPUT.PUT_LINE(' Total Success Record Count : '||L_SUCCESS_COUNT);
DBMS_OUTPUT.PUT_LINE(' Total Fail Record Count :'||L_FAILURE_COUNT);
DBMS_OUTPUT.PUT_LINE('+--------------------------------------+');
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error::::'||SQLERRM);
ROLLBACK;
END xxlr_update_org;
/
/********************************UPDATE ORGANIZATION*****************************************/
DECLARE
l_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
l_party_rec HZ_PARTY_V2PUB.PARTY_REC_TYPE;
l_party_obj_version NUMBER := 1;
x_profile_id NUMBER;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(4000);
BEGIN
l_party_rec.party_id := 5297;
l_party_rec.status := 'I';
l_organization_rec.organization_name := 'TEST_ORG';
l_organization_rec.party_rec := l_party_rec;
HZ_PARTY_V2PUB.update_organization(p_init_msg_list => FND_API.G_TRUE,
p_organization_rec => l_organization_rec,
p_party_object_version_number => l_party_obj_version,
x_profile_id => x_profile_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data);
DBMS_OUTPUT.PUT_LINE('API Status: '||x_return_status);
IF (x_return_status <> 'S')
THEN
DBMS_OUTPUT.PUT_LINE('ERROR :'|| x_msg_data );
END IF;
DBMS_OUTPUT.PUT_LINE('update_organization is completed');
--COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error::::'||SQLERRM);
ROLLBACK;
END;
/*********************UPDATE ALL ORGANIZATIONS***************************************/
===================================================================================================================
CREATE OR REPLACE PROCEDURE APPS.xxlr_update_org
IS
l_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
l_party_rec HZ_PARTY_V2PUB.PARTY_REC_TYPE;
l_party_obj_version NUMBER := 1;
x_profile_id NUMBER;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(4000);
l_success_count NUMBER := 0;
l_failure_count NUMBER := 0;
l_all_count NUMBER := 0;
BEGIN
FOR i IN (SELECT party_id
FROM hz_parties
WHERE party_type = 'ORGANIZATION'
AND party_name <> 'TEST_ORG'
AND status ='A'
)
LOOP
l_all_count := l_all_count + 1;
--DBMS_OUTPUT.PUT_LINE('Party_id='||i.party_id);
l_party_rec.party_id := i.party_id;
l_party_rec.status := 'I';
l_organization_rec.organization_name := 'TEST_ORG';
l_organization_rec.party_rec := l_party_rec;
SELECT max(object_version_number)
INTO l_party_obj_version
FROM hz_parties
WHERE party_id = i.party_id
AND status ='A';
HZ_PARTY_V2PUB.update_organization(p_init_msg_list => FND_API.G_TRUE,
p_organization_rec => l_organization_rec,
p_party_object_version_number => l_party_obj_version,
x_profile_id => x_profile_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data);
--DBMS_OUTPUT.PUT_LINE(x_return_status);
IF (x_return_status <> 'S')
THEN
DBMS_OUTPUT.PUT_LINE('Object Version: '||l_party_obj_version );
l_failure_count := l_failure_count + 1;
fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
p_count => x_msg_count,
p_data => x_msg_data);
IF x_msg_count = 1
THEN
DBMS_OUTPUT.PUT_LINE('ERROR Party_id = '||i.party_id ||';'|| x_msg_data );
ELSE
FOR j IN 1 .. x_msg_count
LOOP
x_msg_data := fnd_msg_pub.get(fnd_msg_pub.g_next,fnd_api.g_false);
DBMS_OUTPUT.PUT_LINE('ERROR Party_id = '||i.party_id ||';'|| x_msg_data );
END LOOP;
END IF;
ELSE
l_success_count := l_success_count + 1;
IF MOD(l_success_count,100)=0
THEN
COMMIT;
END IF;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('+--------------------------------------+');
DBMS_OUTPUT.PUT_LINE(' Total Record count : '||L_ALL_COUNT);
DBMS_OUTPUT.PUT_LINE(' Total Success Record Count : '||L_SUCCESS_COUNT);
DBMS_OUTPUT.PUT_LINE(' Total Fail Record Count :'||L_FAILURE_COUNT);
DBMS_OUTPUT.PUT_LINE('+--------------------------------------+');
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error::::'||SQLERRM);
ROLLBACK;
END xxlr_update_org;
/
No comments:
Post a Comment