Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

code is not working can you please help!!

(0) ShareShare
ReportReport
Posted on by

 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

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,996 Super User 2025 Season 1 on at
    RE: code is not working can you please help!!

    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?

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: code is not working can you please help!!

    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

  • RE: code is not working can you please help!!

    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 ?

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: code is not working can you please help!!

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans