Use get the relationship between a Transaction and tables use the GetLevels method from the Transaction Structure:
using Artech.Genexus.Common.Objects; // for Transaction, Table, etc.
using Artech.Genexus.Common.Parts; // for TransactionLevel, etc.
Transaction trn = …;
foreach (TransactionLevel lvl in trn.Structure.GetLevels())
{
Table t = lvl.AssociatedTable;
String tblName = t.Name;
String lvlName = lvl.Name;
}