while (qr.next()) { bankAccountTable = qr.get(tableNum(BankAccountTable)); bankAccountTrans = qr.get(tableNum(BankAccountTrans)); if(bankAccountTable.OABcashAccount == NoYes::Yes) { select sum(AmountCur) from bankAccountTransLocal where bankAccountTransLocal.TransDate < fromDate && bankAccountTransLocal.AccountId == bankAccountTrans.AccountId; closingBalance = bankAccountTransLocal.AmountCur; currentRow ; cell = null; cell = cells.get_Item(currentRow, 1); cell.set_Value(this.strDate(bankAccountTrans.TransDate)); cell = null; cell = cells.get_Item(currentRow, 2); cell.set_Value(bankAccountTrans.Voucher); while select * from ledgerJournalTrans where LedgerJournalTrans.BankAccountId == bankAccountTable.AccountId while select * from vendtrans where vendtrans.CompanyBankAccountId == bankAccountTable.AccountId join vendTable where vendTable.AccountNum == vendtrans.AccountNum while select * from custTrans where custTrans.CompanyBankAccountId == bankAccountTable.AccountId join custTable where custTable.AccountNum == custTrans.AccountNum if(vendtrans.Voucher == bankAccountTrans.Voucher) { cell = null; cell = cells.get_Item(currentRow, 3); cell.set_Value(vendtrans.AccountNum); cell = null; cell = cells.get_Item(currentRow, 4); cell.set_Value(vendtrans.vendTableName()); cell = null; cell = cells.get_Item(currentRow, 5); cell.set_Value(Global::OAIGetDimensionDisplayValue(vendTable.DefaultDimension,"@OAB:OABBusinessUnitnew")); cell = null; cell = cells.get_Item(currentRow, 6); cell.set_Value(vendTable.InventLocation ); cell = null; cell = cells.get_Item(currentRow, 7); cell.set_Value(enum2Str(vendTrans.TransType)); } else if(custTrans.Voucher == bankAccountTrans.Voucher) { cell = null; cell = cells.get_Item(currentRow, 3); cell.set_Value(custTrans.AccountNum); cell = null; cell = cells.get_Item(currentRow, 4); cell.set_Value(custTrans.custTableName()); cell = null; cell = cells.get_Item(currentRow, 5); cell.set_Value(Global::OAIGetDimensionDisplayValue(custTable.DefaultDimension,"@OAB:OABBusinessUnitnew")); cell = null; cell = cells.get_Item(currentRow, 6); cell.set_Value(custTable.InventLocation ); cell = null; cell = cells.get_Item(currentRow, 7); cell.set_Value(enum2Str(custTrans.TransType)); } else if (ledgerJournalTrans.Voucher == bankAccountTrans.Voucher) { cell = null; cell = cells.get_Item(currentRow, 3); cell.set_Value(''); cell = null; cell = cells.get_Item(currentRow, 4); cell.set_Value(''); cell = null; cell = cells.get_Item(currentRow, 5); cell.set_Value(Global::OAIGetDimensionDisplayValue(ledgerJournalTrans.DefaultDimension,"@OAB:OABBusinessUnitnew")); cell = null; cell = cells.get_Item(currentRow, 6); cell.set_Value(''); cell = null; cell = cells.get_Item(currentRow, 7); cell.set_Value(enum2Str(ledgerJournalTrans.TransactionType)); }
when i remove ledgerjournaltrans while select statement code shows data from 3 to 7 column , dont know what is happening can you please help out totally stuck on it
Hi Sachin,
Can you tell if you get errors or what exactly you mean with "code is not working"? What is the current behavior and what is the expectation?
I would have divided this one method into multiple methods for better readability. For instance, Line# 24 to 52 (excluding while select for customer) will go into different method and same for Customer and Ledger.
If a bank account can have transactions from Customer, Vendor and Ledger then call these methods one by one. However, if not then you can write switch statement or if else based on Voucher so only one gets executed. Also, you can check voucher within while loop as below
while select * from vendtrans where vendtrans.CompanyBankAccountId == bankAccountTable.AccountId && vendtrans.Voucher == bankAccountTrans.Voucher join vendTable where vendTable.AccountNum == vendtrans.AccountNum
22 line , requirement is from Bank account trans all transactions needs to be printed for a bank account , now for these transactions it can be of vendor , customer , or ledgerjournal . and it can ne multiple transactions so i added while but when i add 22 line code cells show empty values , and is there any way to combine these three while statements ?
Hi Sachin, May I know why do you need nested while loops here. Please let us know your requirement and from where are you removing ledgerjournaltrans.
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156