add LedgerTrans.DocumentNum field to BankAccountStatment report

645 views Asked by At

I want to add LedgerTrans.DocumentNum field to BankAccountStatment report

BankAccountStatment report has a datasource "BankAccountTable"

How can I perfrom this?

Note: LedgerTrans.DocumentNum can be reached through BankAccoutTrans.AccountId = BankAccountTable.AccountId then LedgerTrans.voucher = BankAccountTrans.Voucher

2

There are 2 answers

0
10p On

You can try declaring LedgerTrans ledgerTrans; in classDeclaration and adding following code in the report's fetch method before calling element.send(bankAccountTrans):

select firstonly ledgerTrans
    where ledgerTrans.TransDate     == bankAccountTrans.TransDate
       && ledgerTrans.Voucher       == bankAccountTrans.Voucher
       && ledgerTrans.DocumentNum   != "";

After that you'd only need to add a new display field in the ReportDesign\AutoDesignSpecs\Body:_2 section with the following code:

//BP Deviation Documented
display DocumentNum documentNum()
{
    return ledgerTrans.DocumentNum;
}

I didn't try it but it should work. As an alternative you can declare ledgerTrans in the fetch method, add element.send(ledgerTrans) after selecting ledgerTrans, and add a standard String field in the section mentioned above, Table=LedgerTrans, DataField=DocumentNum. Then no display method is needed.

P.S. I assumed you're using AX 2009 but for other versions of AX the logic remains the same.

0
Jan B. Kjeldsen On

This is simple:

display DocumentNum documentNum()
{
     return (select firstonly DocumentNum from ledgerTrans
         where ledgerTrans.TransDate     == bankAccountTrans.TransDate
            && ledgerTrans.Voucher       == bankAccountTrans.Voucher
            && ledgerTrans.DocumentNum   != "").DocumentNum;
}

Drag the method to the desired print location.