UPDATE Customer Account Details Through API:
DECLARE
l_cust_account_rec_type HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
l_object_version_number NUMBER := 1;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(4000);
BEGIN
l_cust_account_rec_type.cust_account_id := 4153;
l_cust_account_rec_type.account_name := fnd_api.g_miss_char;
l_cust_account_rec_type.status := 'I';
HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT(p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec => l_cust_account_rec_type,
p_object_version_number => l_object_version_number,
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 CUST ACCOUNT***************************************/
CREATE OR REPLACE PROCEDURE xxlr_update_cust_acct
IS
l_cust_account_rec_type HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
l_object_version_number NUMBER := 1;
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 cust_account_id
FROM hz_cust_accounts
WHERE 1=1
AND status ='A'
)
LOOP
l_all_count := l_all_count + 1;
--DBMS_OUTPUT.PUT_LINE('cust_account_id='||i.cust_account_id);
l_cust_account_rec_type.cust_account_id := i.cust_account_id;
l_cust_account_rec_type.account_name := fnd_api.g_miss_char;
l_cust_account_rec_type.status := 'I';
SELECT max(object_version_number)
INTO l_object_version_number
FROM hz_cust_accounts
WHERE cust_account_id = i.cust_account_id;
HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT(p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec => l_cust_account_rec_type,
p_object_version_number => l_object_version_number,
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 cust_account_id = '||i.cust_account_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 cust_account_id = '||i.cust_account_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_cust_acct;
DECLARE
l_cust_account_rec_type HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
l_object_version_number NUMBER := 1;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(4000);
BEGIN
l_cust_account_rec_type.cust_account_id := 4153;
l_cust_account_rec_type.account_name := fnd_api.g_miss_char;
l_cust_account_rec_type.status := 'I';
HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT(p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec => l_cust_account_rec_type,
p_object_version_number => l_object_version_number,
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 CUST ACCOUNT***************************************/
CREATE OR REPLACE PROCEDURE xxlr_update_cust_acct
IS
l_cust_account_rec_type HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
l_object_version_number NUMBER := 1;
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 cust_account_id
FROM hz_cust_accounts
WHERE 1=1
AND status ='A'
)
LOOP
l_all_count := l_all_count + 1;
--DBMS_OUTPUT.PUT_LINE('cust_account_id='||i.cust_account_id);
l_cust_account_rec_type.cust_account_id := i.cust_account_id;
l_cust_account_rec_type.account_name := fnd_api.g_miss_char;
l_cust_account_rec_type.status := 'I';
SELECT max(object_version_number)
INTO l_object_version_number
FROM hz_cust_accounts
WHERE cust_account_id = i.cust_account_id;
HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT(p_init_msg_list => FND_API.G_TRUE,
p_cust_account_rec => l_cust_account_rec_type,
p_object_version_number => l_object_version_number,
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 cust_account_id = '||i.cust_account_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 cust_account_id = '||i.cust_account_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_cust_acct;
No comments:
Post a Comment