Neste post irei mostrar como criar uma transação no INV e depois processá-la automaticamente.
INSERT INTO mtl_transactions_interface (transaction_header_id, source_code, source_line_id, source_header_id, process_flag, transaction_mode, last_update_date, last_updated_by, creation_date, created_by, organization_id, transaction_quantity, transaction_uom, transaction_date, transaction_type_id, inventory_item_id, subinventory_code) VALUES (12345, --TRANSACTION_HEADER_ID, 'Teste', --SOURCE_CODE 83, --SOURCE_LINE_ID, 83, --SOURCE_HEADER_ID, 1, --PROCESS_FLAG, 3, --TRANSACTION_MODE, SYSDATE, --LAST_UPDATE_DATE , 26801, --LAST_UPDATED_BY , SYSDATE, --CREATION_DATE , 26801, --CREATED_BY , 196, --ORGANIZATION_ID , 3, --TRANSACTION_QUANTITY , 'Ea', --TRANSACTION_UOM , SYSDATE, --TRANSACTION_DATE , 42, --TRANSACTION_TYPE_ID , 149869, --INVENTORY_ITEM_ID, 'MAT-PRIMA');
Depois é só fazer a chamada abaixo.
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) := 'ALEX.PAGLIARINI'; --Need Modification l_resp_name VARCHAR2 (30) := 'INVENTORY'; --Need Modification 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 'Teste'; 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;
Deixe uma resposta