Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

RDP with AOT query in Ax 2012 r3

Posted on by 5,885

HI al,

i have made SSRS report RDP based with Query

[
    SRSReportQueryAttribute (querystr(GDJ_JPN_VendQR)),
    SRSReportParameterAttribute(classStr(GDJ_JPN_VendorTransactionContract))
]
class GDJ_JPN_VendorTransactionDP extends SrsReportDataProviderPreProcessTempDB
{
}

i have mentioned Query here

ProcessReport method

[SysEntryPointAttribute(false)]
public void processReport()
{
    ;
    contract = this.parmDataContract() as GDJ_JPN_VendorTransactionContract;

    if(contract)
    {
        fromDate    = contract.parmfromDate();
        toDate      = contract.parmtoDate();

        this.insertDataTmpTable(fromDate,toDate);
    }
}

InsertDataTempTable method

public void insertDataTmpTable(transdate   _fromDate,
                        transdate   _toDate)
{
    VendTrans   vendTransOpng;

    boolean     flag;
    query = new query();

    qbds    = query.addDataSource(tableNum(VendTrans));
    qbds.relations(true);

    // date range mapping
    if(_fromDate && _toDate)
    {
        qbds.addRange(fieldNum(VendTrans,TransDate)).value(queryRange(_fromDate, _toDate));
    }

    qbds.addRange(fieldNum(VendTrans,AccountNum)).value();

    qr = new QueryRun(query);

    while(qr.next())
    {
        vendTrans = qr.get(tableNum(VendTrans));
    }
}

here in dialog i am given 

3113.vendor.jpg

Note - date filter is working fine BUT the Vendor account which i am given in query is  NOT  FILTERING data based on vendor.

Please let me know how to resolve ?

please give me more shed on this.

thanks!

  • Suggested answer
    udaY-ch Profile Picture
    udaY-ch 4,616 on at
    RE: RDP with AOT query in Ax 2012 r3

    Hi,

    Adding new data sources as a joining data source shouldn't be added directly to the query (query.adddataSource)

     public static void query(Args _args)
    {
        Query                   query;
        QueryRun                queryrRun;
        QueryBuildDataSource    qbdVendTrans, qbdsVendTable;
        QueryBuildRange         qbr;
        VendTrans               vendTrans;
    
        query = new Query(queryStr(Your Query));
    
        //Solution 1
        //qbdsVendTable = q.dataSourceTable(TableNum(vendTable));
        //qbdVendTrans = qbdsVendTable.addDataSource(TableNum(VendTrans));
        //or
        qbdVendTrans = query.dataSourceTable(TableNum(vendTable)).addDataSource(TableNum(VendTrans));
    
        //Solution2
        //qbdVendTrans = query.dataSourceNo(1).addDataSource(TableNum(VendTrans)); 
        
        qbdVendTrans.relations(true);
        qbdVendTrans.joinMode(JoinMode::InnerJoin);
    
        qbr = qbdVendTrans.addRange(FieldNum(VendTrans, AccountNum));
        qbr.value("1000000");  
    
        queryrRun = new QueryRun(query);
    
        while (queryrRun.next())
        {
            vendTrans = queryrRun.get(tableNum(VendTrans));
            info(strFmt("%1", vendTrans.AccountNum));
        }
    }

    Uday

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: RDP with AOT query in Ax 2012 r3

    yes, single data source ( vend table )

  • Suggested answer
    udaY-ch Profile Picture
    udaY-ch 4,616 on at
    RE: RDP with AOT query in Ax 2012 r3

    Hi

    Is your query having vendtable as a single datasource?

    If not, then you need to use, query.datasourceno(1).adddatasource(your table) to make the right connection.

    Uday

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: RDP with AOT query in Ax 2012 r3

    I debugged the query

    V2.jpg

    in the above query, i have required, the Vendor account which i am given in query that should match with VendTrans.AccountNum. So, that it will fetch the record based on ( date range + AccountNum ) from vendTrans.

    Please give me more shed on this.

    thanks!

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: RDP with AOT query in Ax 2012 r3

    I have modified the insertTempTable method

    public void insertDataTmpTable(transdate   _fromDate,
                            transdate   _toDate)
    {
        VendTrans   vendTransOpng;
    
        boolean     flag;
        
        query = this.parmQuery();
        
        qbds    = query.addDataSource(tableNum(VendTrans));
        qbds.relations(true);
    
        // date range mapping
        if(_fromDate && _toDate)
        {
            qbds.addRange(fieldNum(VendTrans,TransDate)).value(queryRange(_fromDate, _toDate));
        }
    
        qbds.addRange(fieldNum(VendTrans,AccountNum)).value();
    
        queryRun = new QueryRun(query);
    
        while(queryRun.next())
        {
            vendTrans = queryRun.get(tableNum(VendTrans));
        }
    
    }
    

    but still it's not FILTERING VEND ACCOUNT

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans