SSRS Report Using RDP,Contract,UIBuilder Classes in Ax 2012
UI Builder Class is needed when you
want to customize your dialog which pop ups when you open a Report.
UI Builder Class helps you to add run time lookups and other controls
on the dialog form.
Step 1:
Create a Query in AOT.
Step 2:
Add tables as datasource into the
query.
Step 3:
Create a RDP Class.
ClassDeclaration:
[
SRSReportQueryAttribute(queryStr(CustTransReport)),
SRSReportParameterAttribute(classstr(RamaCustTransContract))
]
public class RamaCustTransDP extends
SRSReportDataProviderBase
{
CustTrans custTrans;
CustTable custTable;
CustTransTmp custTransTmp;
AccountNum
number,custaccount;
}
Create a new method():
getCustTransTmp():
[
SRSReportDataSetAttribute(tablestr(CustTransTmp))
]
public CustTransTmp
getCustTransListtmp()
{
select custTransTmp;
return custTransTmp;
}
Call the Override ProcessReport()
method:
ProcessReport():
[SysEntryPointAttribute]
public void processReport()
{
QueryBuildDataSource qbds;
QueryBuildRange qbr;
RamaCustTransContract contract =
this.parmDataContract() as RamaCustTransContract;
Query q = this.parmQuery();
QueryRun qr = new QueryRun(q);
qbds =
qr.query().dataSourceNo(1).addDataSource(tablenum(CustTable));
number =
contract.parmCustAccount();
while (qr.next())
{
custTable =
qr.get(tablenum(CustTable));
custTrans =
qr.get(tablenum(CustTrans));
IF(custTable.AccountNum ==
number)
{
custTransTmp.AccountNum =
custTable.AccountNum;
custTransTmp.CustName =
custTable.name();
custTransTmp.Voucher =
custTrans.Voucher;
custTransTmp.Invoice =
custTrans.Invoice;
custTransTmp.TransType =
custTrans.TransType;
custTransTmp.TransDate =
custTrans.TransDate;
custTransTmp.AmountCur =
custTrans.AmountCur;
custTransTmp.RemainAmountCur =
custTrans.remainAmountCur();
custTransTmp.insert();
}
}
Step 4:
Create Contract Class for Passing
AccountNumber of the Customer:
ClassDecLaration:
[
DataContractAttribute,SysOperationContractProcessingAttribute(classstr(RamaCustTransUIBuilder))
]
public class RamaCustTransContract
{
CustAccount accountNum;
}
Create new method():
[
DataMemberAttribute('accountNum'),
SysOperationLabelAttribute(literalstr("Customer Id")),
SysOperationHelpTextAttribute(literalstr("Customer Id")),
SysOperationDisplayOrderAttribute("1")
]
public CustAccount
parmCustAccount(CustAccount _custAccount = accountNum)
{
accountNum = _custAccount;
info("%1 contract class
parmcustaccount",accountNum );
return accountNum;
}
Step 5:
Create UIBuilder Class for making
Lookup in dialog.
ClassDeclaration:
class RamaCustTransUIBuilder extends
SrsReportDataContractUIBuilder
{
DialogField dialogEmplId;
RamaCustTransContract contract;
}
Override the build() method:
public void build()
{
contract = this.dataContractObject();
dialogEmplId =
this.addDialogField(methodStr(RamaCustTransContract,
parmCustAccount),contract);
}
Create new method():
private void
CustAccountLookup(FormStringControl formstringcontrol)
{
Query query = new Query();
QueryBuildDataSource qbds;
SysTableLookup sysTableLookup;
sysTableLookup =
SysTableLookup::newParameters(tableNum(CustTable),
formstringcontrol);
sysTableLookup.addLookupfield(fieldNum(CustTable,AccountNum));
qbds =
query.addDataSource(tableNum(CustTable));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
override the getFromDialog() method:
public void getFromDialog()
{
contract = this.dataContractObject();
super();
}
Override the Postbuild() method:
public void postBuild()
{
super();
dialogEmplId =
this.bindInfo().getDialogField(this.dataContractObject(),methodStr(RamaCustTransContract,parmCustAccount));
dialogEmplId.registerOverrideMethod(methodStr(FormStringControl,
lookup),methodStr(RamaCustTransUIBuilder,CustAccountLookup), this);
dialogEmplId.lookupButton(2);
}