Thursday 9 January 2014

Find bank account from specification of main account


The following method finds a bank account from the main account attached to it. This is a general approach for relating the main account number to a record storing an account or account+dimensions combination.

Note use of DimensionAttributeValueCombination and MainAccount tables.


BankAccountTable bankAccountFromMainAccount(MainAccountNum mainAccountNum)
{
// Lookup bank account from main account

BankAccountTable bankAccountTable;
DimensionAttributeValueCombination valueCom;
MainAccount mainAccount;

select firstOnly bankAccountTable
join valueCom
where valueCom.RecId == bankAccountTable.LedgerDimension
join mainAccount
where mainAccount.RecId == valueCom.MainAccount
&& mainAccount.MainAccountId == mainAccountNum;

if(!bankAccountTable)
this.throwError(strFmt("Could not find bank account with main account '%1'",mainAccountNum));

return bankAccountTable;
}

No comments:

Post a Comment