UPDATE Person Details Through API:
/********************************UPDATE PERSON*****************************************/
DECLARE
l_person_rec_type HZ_PARTY_V2PUB.PERSON_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 := 149707;
l_party_rec.status := 'I';
l_person_rec_type.person_first_name := 'TEST';
l_person_rec_type.person_last_name := 'PERSON';
l_person_rec_type.party_rec := l_party_rec;
HZ_PARTY_V2PUB.UPDATE_PERSON(p_init_msg_list => FND_API.G_TRUE,
p_person_rec => l_person_rec_type,
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_person is completed');
--COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error::::'||SQLERRM);
ROLLBACK;
END;
/*********************UPDATE ALL PERSONS***************************************/
CREATE OR REPLACE PROCEDURE xxlr_update_per
IS
l_person_rec_type HZ_PARTY_V2PUB.PERSON_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 1=1
AND party_type = 'PERSON'
AND created_by_module = 'TCA_V2_API'
AND status = 'A'
AND PARTY_NAME <> 'TEST PERSON'
)
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_person_rec_type.person_first_name := 'TEST';
l_person_rec_type.person_last_name := 'PERSON';
l_person_rec_type.party_rec := l_party_rec;
SELECT NVL(MAX(object_version_number),1)
INTO l_party_obj_version
FROM hz_organization_profiles
WHERE party_id = i.party_id
AND effective_end_date IS NULL;
HZ_PARTY_V2PUB.UPDATE_PERSON(p_init_msg_list => FND_API.G_TRUE,
p_person_rec => l_person_rec_type,
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
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_per;
No comments:
Post a Comment