Hi All,
Today I would like to share you ,how to use UI Builder Class, Contract class and RDP class in SSRS report in Ax 2012 R2?
Following are the scenarios where UI Builder Class can be used:
Step 1:
Create New Class SRCustomLookupsUIBuilder which extends SrsReportDataContractUIBuilder
Here I have created one enum called YearEnum in AOT and add the values to the enum dynamically through code .
public class SRCustomLookupsUIBuilder extends SrsReportDataContractUIBuilder
{
DialogField dialogYear;
SRCustomLookUpContract rdpContract;
FormBuildComboBoxControl formComboBoxControl;
}
public void build()
{
int i;
rdpContract = this.dataContractObject();
dialogYear= dialog.addField(EnumStr(YearEnum));
formComboBoxControl=dialogYear.control();
formComboBoxControl.enumType(0);
formComboBoxControl.label("Year");
formComboBoxControl.items(11);
for(i=0;i<=10;i++)
{
formComboBoxControl.item(i+1);
formComboBoxControl.text(int2str(year(systemDateGet())-i));
}
}
public void getFromDialog()
{
super();
formComboBoxControl.item(dialogYear.value()+1);
rdpContract.parmYear(str2int(formComboBoxControl.text()));
}
Step 2:
Create a Temporary Table SalesCountTmp and create the fields listed below
Step 3:
Create New Class SRCustomLookUpContract
[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(SRCustomLookupsUIBuilder))]
class SRCustomLookUpContract
{
int yearVal;
}
[DataMemberAttribute('YearBase')]
public int parmYear(int _year = yearVal)
{
yearVal= _year;
return yearVal;
}Step 4:
Create New Class SRCustomLookupDP which extends SRSReportDataProviderBase
[SRSReportParameterAttribute(classStr(SRCustomLookUpContract))]
class SRCustomLookupDP extends SRSReportDataProviderBase
{
SRCustomLookUpContract contract;
SalesCountTmp salesCountTmp;
}
[SRSReportDataSetAttribute('SalesCountTmp')]
public SalesCountTmp getTmpSRSalesTableDetails()
{
select * from salesCountTmp;
return salesCountTmp;
}
[SysEntryPointAttribute]
public void processReport()
{
Query query;
QueryRun qRun;
QueryBuildRange qbr;
SalesTable salesTable;
date fromdate,todate;
utcDateTime _UtcStartPeriod,_UtcEndPeriod;
int yearval;
contract = this.parmDataContract() as SRCustomLookUpContract;
yearval=contract.parmYear();fromdate=mkDate(1,1,yearval);
todate=mkDate(31,12,yearval);
_UtcStartPeriod=DateTimeUtil::newDateTime(fromdate,0);
_UtcEndPeriod= DateTimeUtil::newDateTime(todate,86400);
query = new Query();
qbr = query.addDataSource(tableNum(SalesTable)).addRange(fieldNum(SalesTable,CreatedDateTime));
qbr.value(queryRange( _UtcStartPeriod, _UtcEndPeriod)); qRun = new QueryRun(query);
while(qRun.next()){
salesTable = qRun.get(tableNum(SalesTable));
salesCountTmp.SalesId=salesTable.SalesId;
salesCountTmp.SalesCreatedDateTime=salesTable.createdDateTime;
salesCountTmp.SalesStatus=salesTable.SalesStatus;
salesCountTmp.insert();
}
}
Today I would like to share you ,how to use UI Builder Class, Contract class and RDP class in SSRS report in Ax 2012 R2?
UI Builder Class Overview
User Interface (UI) Builder Class is used to define the layout of the parameter dialog box that opens before a report is run in Microsoft Dynamics AX. It is used to add the customizations as well as additional fields in the dialog.Following are the scenarios where UI Builder Class can be used:
- Grouping dialog fields
- Overriding dialog field events
- Adding a customized lookup to a dialog field
- Binding dialog fields with Report contract parameters
- Changing the layout of the dialog
- Adding custom controls to the dialog
Step 1:
Create New Class SRCustomLookupsUIBuilder which extends SrsReportDataContractUIBuilder
Here I have created one enum called YearEnum in AOT and add the values to the enum dynamically through code .
public class SRCustomLookupsUIBuilder extends SrsReportDataContractUIBuilder
{
DialogField dialogYear;
SRCustomLookUpContract rdpContract;
FormBuildComboBoxControl formComboBoxControl;
}
public void build()
{
int i;
rdpContract = this.dataContractObject();
dialogYear= dialog.addField(EnumStr(YearEnum));
formComboBoxControl=dialogYear.control();
formComboBoxControl.enumType(0);
formComboBoxControl.label("Year");
formComboBoxControl.items(11);
for(i=0;i<=10;i++)
{
formComboBoxControl.item(i+1);
formComboBoxControl.text(int2str(year(systemDateGet())-i));
}
}
public void getFromDialog()
{
super();
formComboBoxControl.item(dialogYear.value()+1);
rdpContract.parmYear(str2int(formComboBoxControl.text()));
}
Step 2:
Create a Temporary Table SalesCountTmp and create the fields listed below
Step 3:
Create New Class SRCustomLookUpContract
[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(SRCustomLookupsUIBuilder))]
class SRCustomLookUpContract
{
int yearVal;
}
[DataMemberAttribute('YearBase')]
public int parmYear(int _year = yearVal)
{
yearVal= _year;
return yearVal;
}Step 4:
Create New Class SRCustomLookupDP which extends SRSReportDataProviderBase
[SRSReportParameterAttribute(classStr(SRCustomLookUpContract))]
class SRCustomLookupDP extends SRSReportDataProviderBase
{
SRCustomLookUpContract contract;
SalesCountTmp salesCountTmp;
}
[SRSReportDataSetAttribute('SalesCountTmp')]
public SalesCountTmp getTmpSRSalesTableDetails()
{
select * from salesCountTmp;
return salesCountTmp;
}
[SysEntryPointAttribute]
public void processReport()
{
Query query;
QueryRun qRun;
QueryBuildRange qbr;
SalesTable salesTable;
date fromdate,todate;
utcDateTime _UtcStartPeriod,_UtcEndPeriod;
int yearval;
contract = this.parmDataContract() as SRCustomLookUpContract;
yearval=contract.parmYear();fromdate=mkDate(1,1,yearval);
todate=mkDate(31,12,yearval);
_UtcStartPeriod=DateTimeUtil::newDateTime(fromdate,0);
_UtcEndPeriod= DateTimeUtil::newDateTime(todate,86400);
query = new Query();
qbr = query.addDataSource(tableNum(SalesTable)).addRange(fieldNum(SalesTable,CreatedDateTime));
qbr.value(queryRange( _UtcStartPeriod, _UtcEndPeriod)); qRun = new QueryRun(query);
while(qRun.next()){
salesTable = qRun.get(tableNum(SalesTable));
salesCountTmp.SalesId=salesTable.SalesId;
salesCountTmp.SalesCreatedDateTime=salesTable.createdDateTime;
salesCountTmp.SalesStatus=salesTable.SalesStatus;
salesCountTmp.insert();
}
}
Hi,
ReplyDeleteHow can I get query object initialized in post build the similar way as dialog field?
Thanks!