DECLARE
CURSOR c1
IS
SELECT inventory_item_id
, segment1
FROM mtl_system_items_b
WHERE organization_id = 103
AND inventory_item_status_code = 'PreRelease';
TYPE sku_tbl_typ IS TABLE OF c1%ROWTYPE
INDEX BY SIMPLE_INTEGER;
sku_tbl sku_tbl_typ;
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2(2) := fnd_api.g_true;
l_commit VARCHAR2(2) := fnd_api.g_false;
l_item_tbl ego_item_pub.item_tbl_type;
l_role_grant_tbl ego_item_pub.role_grant_tbl_type := ego_item_pub.g_miss_role_grant_tbl;
x_item_tbl ego_item_pub.item_tbl_type;
x_message_list error_handler.error_tbl_type;
x_return_status VARCHAR2(2);
x_msg_count NUMBER := 0;
l_user_id NUMBER := -1;
l_resp_id NUMBER := -1;
l_application_id NUMBER := -1;
l_rowcnt NUMBER := 1;
l_user_name VARCHAR2(30) := '<USER_NAME>';
l_resp_name VARCHAR2(30) := 'EGO_DEVELOPMENT_MANAGER';
i NUMBER;
BEGIN
-- Get the user_id
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = l_user_name;
-- Get the application_id and responsibility_id
SELECT application_id
, responsibility_id
INTO l_application_id
, l_resp_id
FROM fnd_responsibility
WHERE responsibility_key = l_resp_name;
fnd_global.apps_initialize(l_user_id
, l_resp_id
, l_application_id);
DBMS_OUTPUT.put_line( 'Initialized applications context: '
|| l_user_id
|| ' '
|| l_resp_id
|| ' '
|| l_application_id);
OPEN c1;
FETCH c1 BULK COLLECT INTO sku_tbl;
CLOSE c1;
IF sku_tbl.COUNT > 0
THEN
i := sku_tbl.FIRST;
LOOP
l_item_tbl( i).transaction_type := 'UPDATE';
l_item_tbl( i).inventory_item_id := sku_tbl(i).inventory_item_id;
l_item_tbl( i).inventory_item_status_code := 'Active';
l_item_tbl( i).organization_id := 103;
EXIT WHEN i = sku_tbl.LAST;
i := sku_tbl.NEXT( i);
END LOOP;
END IF;
-- call API to load Items
DBMS_OUTPUT.put_line( '=====================================');
DBMS_OUTPUT.put_line( 'Calling EGO_ITEM_PUB.Process_Items API');
ego_item_pub.process_items(p_api_version => l_api_version
, p_init_msg_list => l_init_msg_list
, p_commit => l_commit
, p_item_tbl => l_item_tbl
, p_role_grant_tbl => l_role_grant_tbl
, x_item_tbl => x_item_tbl
, x_return_status => x_return_status
, x_msg_count => x_msg_count);
DBMS_OUTPUT.put_line( '=====================================');
DBMS_OUTPUT.put_line( 'Return Status: '
|| x_return_status);
IF x_return_status = fnd_api.g_ret_sts_success
THEN
FOR i IN 1 .. x_item_tbl.COUNT
LOOP
DBMS_OUTPUT.put_line( 'Inventory Item Id :'
|| TO_CHAR( x_item_tbl( i).inventory_item_id));
DBMS_OUTPUT.put_line( 'Organization Id :'
|| TO_CHAR( x_item_tbl( i).organization_id));
END LOOP;
COMMIT;
ELSE
DBMS_OUTPUT.put_line( 'Error Messages :');
error_handler.get_message_list( x_message_list => x_message_list);
FOR i IN 1 .. x_message_list.COUNT
LOOP
DBMS_OUTPUT.put_line( x_message_list( i).MESSAGE_TEXT);
END LOOP;
END IF;
DBMS_OUTPUT.put_line( '=====================================');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line( 'Exception Occured :');
DBMS_OUTPUT.put_line( SQLCODE
|| ':'
|| SQLERRM);
DBMS_OUTPUT.put_line( '=====================================');
END;
CURSOR c1
IS
SELECT inventory_item_id
, segment1
FROM mtl_system_items_b
WHERE organization_id = 103
AND inventory_item_status_code = 'PreRelease';
TYPE sku_tbl_typ IS TABLE OF c1%ROWTYPE
INDEX BY SIMPLE_INTEGER;
sku_tbl sku_tbl_typ;
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2(2) := fnd_api.g_true;
l_commit VARCHAR2(2) := fnd_api.g_false;
l_item_tbl ego_item_pub.item_tbl_type;
l_role_grant_tbl ego_item_pub.role_grant_tbl_type := ego_item_pub.g_miss_role_grant_tbl;
x_item_tbl ego_item_pub.item_tbl_type;
x_message_list error_handler.error_tbl_type;
x_return_status VARCHAR2(2);
x_msg_count NUMBER := 0;
l_user_id NUMBER := -1;
l_resp_id NUMBER := -1;
l_application_id NUMBER := -1;
l_rowcnt NUMBER := 1;
l_user_name VARCHAR2(30) := '<USER_NAME>';
l_resp_name VARCHAR2(30) := 'EGO_DEVELOPMENT_MANAGER';
i NUMBER;
BEGIN
-- Get the user_id
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = l_user_name;
-- Get the application_id and responsibility_id
SELECT application_id
, responsibility_id
INTO l_application_id
, l_resp_id
FROM fnd_responsibility
WHERE responsibility_key = l_resp_name;
fnd_global.apps_initialize(l_user_id
, l_resp_id
, l_application_id);
DBMS_OUTPUT.put_line( 'Initialized applications context: '
|| l_user_id
|| ' '
|| l_resp_id
|| ' '
|| l_application_id);
OPEN c1;
FETCH c1 BULK COLLECT INTO sku_tbl;
CLOSE c1;
IF sku_tbl.COUNT > 0
THEN
i := sku_tbl.FIRST;
LOOP
l_item_tbl( i).transaction_type := 'UPDATE';
l_item_tbl( i).inventory_item_id := sku_tbl(i).inventory_item_id;
l_item_tbl( i).inventory_item_status_code := 'Active';
l_item_tbl( i).organization_id := 103;
EXIT WHEN i = sku_tbl.LAST;
i := sku_tbl.NEXT( i);
END LOOP;
END IF;
-- call API to load Items
DBMS_OUTPUT.put_line( '=====================================');
DBMS_OUTPUT.put_line( 'Calling EGO_ITEM_PUB.Process_Items API');
ego_item_pub.process_items(p_api_version => l_api_version
, p_init_msg_list => l_init_msg_list
, p_commit => l_commit
, p_item_tbl => l_item_tbl
, p_role_grant_tbl => l_role_grant_tbl
, x_item_tbl => x_item_tbl
, x_return_status => x_return_status
, x_msg_count => x_msg_count);
DBMS_OUTPUT.put_line( '=====================================');
DBMS_OUTPUT.put_line( 'Return Status: '
|| x_return_status);
IF x_return_status = fnd_api.g_ret_sts_success
THEN
FOR i IN 1 .. x_item_tbl.COUNT
LOOP
DBMS_OUTPUT.put_line( 'Inventory Item Id :'
|| TO_CHAR( x_item_tbl( i).inventory_item_id));
DBMS_OUTPUT.put_line( 'Organization Id :'
|| TO_CHAR( x_item_tbl( i).organization_id));
END LOOP;
COMMIT;
ELSE
DBMS_OUTPUT.put_line( 'Error Messages :');
error_handler.get_message_list( x_message_list => x_message_list);
FOR i IN 1 .. x_message_list.COUNT
LOOP
DBMS_OUTPUT.put_line( x_message_list( i).MESSAGE_TEXT);
END LOOP;
END IF;
DBMS_OUTPUT.put_line( '=====================================');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line( 'Exception Occured :');
DBMS_OUTPUT.put_line( SQLCODE
|| ':'
|| SQLERRM);
DBMS_OUTPUT.put_line( '=====================================');
END;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.