Using The 'Report Data Provider' As The Data Source For AX 2012 SSRS Report

In this case, we will build a simple vendor report including the fields 'Vendor group', 'Vendor account' and the 'Vendor name'.

1、At first, we should define a temp table that it will be used as a returning data set for the report.

2、Create a query for the report.

 3、Define a new 'DataContract' class to add the additional query ranges for the report, this kind of query range dosen't include in the base query.

[DataContractAttribute]
public class VendTableDetailContract
{
    VendName    vendName;
}

[DataMemberAttribute("Vendor name")]
public VendName parmVendName(VendName _vendName = vendName)
{
    vendName = _vendName;
    
    return vendName;
}

4、Define a new 'SRSReportDataProviderBase' class as the data source for the report.

[
    SRSReportQueryAttribute(queryStr(VendTableDetaill)),
    SRSReportParameterAttribute(classStr(VendTableDetailContract))
]
public class VendTableDetailDP extends SRSReportDataProviderBase
{
    VendTableTmp    vendTableTmp;
}

[SysEntryPointAttribute]
public void processReport()
{
    QueryRun                    QR;
    VendTableDetailContract     contract;
    VendTable                   vendTable;
    VendName                    vendName;

    contract = this.parmDataContract() as VendTableDetailContract;
    vendName = contract.parmVendName();

    QR = new QueryRun(this.parmQuery());
    while (QR.next())
    {
        vendTable = QR.get(tableNum(VendTable));
        
        if (vendTable.name() like strFmt("*%1*", vendName))
        {
            vendTableTmp.clear();
            vendTableTmp.VendGroup  = vendTable.VendGroup;
            vendTableTmp.AccountNum = vendTable.AccountNum;
            vendTableTmp.VendName   = vendTable.name();
            vendTableTmp.doInsert();
        }
    }
}

[SRSReportDataSetAttribute("VendTableTmp")]
public VendTableTmp getVendTableTmp()
{
    select vendTableTmp;

    return vendTableTmp;
}

5、Use the new data source for the report.

 

posted @ 2016-04-05 15:52  Sprite.z  Views(419)  Comments(0Edit  收藏  举报