The following lines contain the word 'select', 'insert', 'update' or 'delete':
g_old_resource_id NUMBER; -- variable containing old resource_id; populated in Pre_Update hook
PROCEDURE Insert_MTL_Mat_Transaction(
p_resource_id NUMBER,
p_subinventory_code VARCHAR2,
p_organization_id NUMBER
)
IS
CURSOR c_mtl_mat_transactions (b_subinventory_code VARCHAR2, b_organization_id NUMBER) IS
SELECT TRANSACTION_ID, INVENTORY_ITEM_ID
FROM MTL_MATERIAL_TRANSACTIONS
WHERE SUBINVENTORY_CODE = p_SUBINVENTORY_CODE
AND ORGANIZATION_ID = b_organization_id
AND TRANSACTION_ACTION_ID = 2 --Subinventory transfer
AND SOURCE_CODE = 'CSP';
, v_message => 'Entering Insert_MTL_Mat_Transaction'
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
, v_message => 'Insert_MTL_Mat_Transaction => no transactions for sub inventory :' ||
p_subinventory_code ||', organization '||p_organization_id||
' for resource id ' || p_resource_id|| ' found'
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_MEDIUM);
, v_message => 'Inserting ACC record :' || p_subinventory_code || ' , ' || p_organization_id ||
' for resource id ' || p_resource_id
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
/*** Call common package to insert record into ACC table ***/
JTM_HOOK_UTIL_PKG.Insert_Acc
( p_publication_item_names => g_publication_item_name
,p_acc_table_name => g_acc_table_name
,p_resource_id => p_resource_id
,p_pk1_name => g_pk1_name
,p_pk1_num_value => r_mtl_mat_transactions.TRANSACTION_ID
);
/*** Also insert Lot numebers and serial numbers into their respective acc tables ***/
CSL_MTL_TRANS_LOT_NUM_ACC_PKG.Insert_MTL_trans_lot_num(
p_resource_id => p_resource_id,
p_transaction_id => r_mtl_mat_transactions.TRANSACTION_ID,
p_inventory_item_id => r_mtl_mat_transactions.inventory_item_id,
p_organization_id => p_organization_id
);
CSL_MTL_UNIT_TRANS_ACC_PKG.Insert_MTL_Unit_Trans(
p_resource_id => p_resource_id,
p_transaction_id => r_mtl_mat_transactions.TRANSACTION_ID,
p_inventory_item_id => r_mtl_mat_transactions.inventory_item_id,
p_organization_id => p_organization_id,
p_subinventory_code => p_subinventory_code
);
, v_message => 'Leaving Insert_MTL_Mat_Transaction'
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
END Insert_MTL_Mat_Transaction;
PROCEDURE Update_MTL_Mat_Transaction(
p_resource_id NUMBER,
p_subinventory_code VARCHAR2,
p_organization_id NUMBER
)
IS
CURSOR c_mtl_mat_transactions (b_subinventory_code VARCHAR2, b_organization_id NUMBER) IS
SELECT TRANSACTION_ID, INVENTORY_ITEM_ID
FROM MTL_MATERIAL_TRANSACTIONS
WHERE SUBINVENTORY_CODE = p_SUBINVENTORY_CODE
AND ORGANIZATION_ID = b_organization_id
AND TRANSACTION_ACTION_ID = 2 --Subinventory transfer
AND SOURCE_CODE = 'CSP';
, v_message => 'Entering Update_CSP_Sec_Inventory'
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
, v_message => 'Update_MTL_Mat_Transaction could not find records for :' || p_subinventory_code || ','
|| p_organization_id || ' for resource id ' || p_resource_id
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_MEDIUM);
, v_message => 'Update ACC record :' || p_subinventory_code || ' , ' || p_organization_id
|| ' for resource id ' || p_resource_id
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
/*** Call common package to insert record into ACC table ***/
l_acc_id := JTM_HOOK_UTIL_PKG.Get_Acc_Id
( P_ACC_TABLE_NAME => g_acc_table_name
,P_PK1_NAME => g_pk1_name
,P_PK1_NUM_VALUE => r_mtl_mat_transactions.TRANSACTION_ID
,P_RESOURCE_ID => p_resource_id);
/*** Record is not yet in ACC tables. Insert has to be done ***/
JTM_HOOK_UTIL_PKG.Insert_Acc
( p_publication_item_names => g_publication_item_name
,p_acc_table_name => g_acc_table_name
,p_resource_id => p_resource_id
,p_pk1_name => g_pk1_name
,p_pk1_num_value => r_mtl_mat_transactions.TRANSACTION_ID
);
/*** Record is already in ACC. Only an update is required for re-sending ***/
JTM_HOOK_UTIL_PKG.Update_Acc
( p_publication_item_names => g_publication_item_name
,p_acc_table_name => g_acc_table_name
,p_resource_id => p_resource_id
,p_access_id => l_acc_id
);
/*** Also Update Lot numebers and serial numbers into their respective acc tables ***/
CSL_MTL_TRANS_LOT_NUM_ACC_PKG.Update_MTL_trans_lot_num(
p_resource_id => p_resource_id,
p_transaction_id => r_mtl_mat_transactions.TRANSACTION_ID,
p_inventory_item_id => r_mtl_mat_transactions.inventory_item_id,
p_organization_id => p_organization_id
);
CSL_MTL_UNIT_TRANS_ACC_PKG.Update_MTL_Unit_Trans(
p_resource_id => p_resource_id,
p_transaction_id => r_mtl_mat_transactions.TRANSACTION_ID,
p_inventory_item_id => r_mtl_mat_transactions.inventory_item_id,
p_organization_id => p_organization_id,
p_subinventory_code => p_subinventory_code
);
, v_message => 'Leaving Update_MTL_Mat_Transaction'
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
END Update_MTL_Mat_Transaction;
PROCEDURE Delete_MTL_Mat_Transaction(
p_resource_id NUMBER,
p_subinventory_code VARCHAR2,
p_organization_id NUMBER
)
IS
CURSOR c_mtl_mat_transactions (b_subinventory_code VARCHAR2, b_organization_id NUMBER) IS
SELECT TRANSACTION_ID, INVENTORY_ITEM_ID
FROM MTL_MATERIAL_TRANSACTIONS
WHERE SUBINVENTORY_CODE = p_SUBINVENTORY_CODE
AND ORGANIZATION_ID = b_organization_id
AND TRANSACTION_ACTION_ID = 2 --Subinventory transfer
AND SOURCE_CODE = 'CSP';
, v_message => 'Entering Delete_MTL_Mat_Transaction'
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
, v_message => 'Delete_MTL_Mat_Transaction could not find records for :' || p_subinventory_code ||
' , ' || p_organization_id || ' for resource id ' || p_resource_id
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_MEDIUM);
, v_message => 'Inserting ACC record :' || p_subinventory_code || ' , ' || p_organization_id ||
' for resource id ' || p_resource_id
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL);
/*** Call common package to insert record into ACC table ***/
JTM_HOOK_UTIL_PKG.Delete_Acc
( p_publication_item_names => g_publication_item_name
,p_acc_table_name => g_acc_table_name
,p_resource_id => p_resource_id
,p_pk1_name => g_pk1_name
,p_pk1_num_value => r_mtl_mat_transactions.TRANSACTION_ID
);
/*** Also insert Lot numebers and serial numbers into their respective acc tables ***/
CSL_MTL_TRANS_LOT_NUM_ACC_PKG.Delete_MTL_trans_lot_num(
p_resource_id => p_resource_id,
p_transaction_id => r_mtl_mat_transactions.TRANSACTION_ID,
p_inventory_item_id => r_mtl_mat_transactions.inventory_item_id,
p_organization_id => p_organization_id
);
CSL_MTL_UNIT_TRANS_ACC_PKG.Delete_MTL_Unit_Trans(
p_resource_id => p_resource_id,
p_transaction_id => r_mtl_mat_transactions.TRANSACTION_ID,
p_inventory_item_id => r_mtl_mat_transactions.inventory_item_id,
p_organization_id => p_organization_id,
p_subinventory_code => p_subinventory_code
);
END Delete_MTL_Mat_Transaction;
/*Delete all records for non-existing user ( e.g user was deleted )*/
PROCEDURE DELETE_ALL_ACC_RECORDS( p_resource_id IN NUMBER
, x_return_status OUT NOCOPY VARCHAR2 )
IS
BEGIN
/*** get debug level ***/
g_debug_level := JTM_HOOK_UTIL_PKG.Get_Debug_Level;
, 'Entering DELETE_ALL_ACC_RECORDS'
, JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL
);
DELETE JTM_MTL_MAT_TRANS_ACC
WHERE RESOURCE_ID = p_resource_id;
, 'Leaving DELETE_ALL_ACC_RECORDS'
, JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_FULL
);
, v_message => 'Caught exception in DELETE_ALL_ACC_RECORDS hook:' || fnd_global.local_chr(10) || sqlerrm
, v_level_id => JTM_HOOK_UTIL_PKG.G_DEBUG_LEVEL_ERROR);
END DELETE_ALL_ACC_RECORDS;