API to create Miscellaneous Receipt in Inventory.

Objective.

The objective of the below API is used to increase the onhand quantity in Inventory through Miscellaneous Receipt.

Sample Code.

set serveroutput on
declare
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2(2) := FND_API.G_TRUE;
l_commit VARCHAR2(2) := FND_API.G_FALSE;
x_return_status VARCHAR2(2);
x_msg_count NUMBER := 0;
x_msg_data VARCHAR2(255);
x_trans_count number;
l_result number;
l_header_id NUMBER;

— WHO columns
l_user_id NUMBER := -1;
l_resp_id NUMBER := -1;
l_application_id NUMBER := -1;
l_row_cnt NUMBER := 1;
l_user_name VARCHAR2(30) := ‘OPERATIONS’;
l_resp_name VARCHAR2(30) := ‘INVENTORY_VISION_OPERATIONS’;

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;

select transaction_header_id into l_header_id
from mtl_transactions_interface
where source_code like ‘INVENTORY’;

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 );

— call API to process transaction
DBMS_OUTPUT.PUT_LINE(‘=======================================================’);
DBMS_OUTPUT.PUT_LINE(‘Calling inv_txn_manager_pub.process_Transactions API’);

l_result := inv_txn_manager_pub.process_Transactions( p_api_version => l_api_version,
p_init_msg_list => l_init_msg_list,
p_commit => l_commit,
p_validation_level => fnd_api.G_VALID_LEVEL_FULL,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_trans_count => x_trans_count,
p_table => 1,
p_header_id => l_header_id);

DBMS_OUTPUT.PUT_LINE(‘=======================================================’);
DBMS_OUTPUT.PUT_LINE(‘Return Status: ‘||x_return_status);

IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
DBMS_OUTPUT.PUT_LINE(‘Error Message :’||x_msg_data);
END IF;

IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
DBMS_OUTPUT.PUT_LINE(‘Transaction Processed Successfully’);
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;

 

Recent Posts