Month: January 2016

SSRS reporting with Controller Class in AX 2012 R2 CU7

Follow the underneath steps in order to create the SSRS based report by using controller class.

STEP I : Create a temp table within the AX Environment.

STEP II: Create a query with above mentioned table.

STEP III: Contract Class.

class EmplDetailContract
{
RecId _hcmWorkerId;

}

*************************************************************

[
DataMemberAttribute(“Employee ID”)
]
public Recid parmHcmWorkerId(RecId hcmworkerid = _hcmWorkerId)
{
_hcmWorkerId = hcmWorkerId;
return _hcmWorkerId;
}

 

 

STEP IV: Controller Class.

class EmplDetailController eXTENDS SrsReportRunController
{
HcmWorker _hcmWorker;
}

*************************************************************

protected void preRunModifyContract()
{
// super();
str reportnameLocal;
EmplDetailContract contract;

contract = this.parmReportContract().parmRdpContract() as EmplDetailContract;

if(this.parmArgs().menuItemName() == menuitemOutputStr(EmplDetailReport))
{
_hcmWorker = args.record();
contract.parmHcmWorkerId(_hcmWorker.RecId);
reportnameLocal = ssrsReportStr(EmplDetailReport, Report);
}
}

*************************************************************

public static void main(Args _args)
{
EmplDetailController controller = new EmplDetailController();
TmpEmployeeDetail _emplDetailTable;

_emplDetailTable = _args.record() as TmpEmployeeDetail;

controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(EmplDetailReport, Report));
controller.parmShowDialog(false);
controller.startOperation();
}

 

STEP V: Data Provider Class

[
SRSReportParameterAttribute(classStr(EmplDetailContract))
]
class EmplDetailDP extends SRSReportDataProviderBase
{
TmpEmployeeDetail _employeeDetailTable;
}

*************************************************************

[
SRSReportDataSetAttribute(tableStr(TmpEmployeeDetail))
]
public TmpEmployeeDetail getData()
{
select * from _employeeDetailTable;
return _employeeDetailTable;
}

*************************************************************

private void insertintoEmplDetailTbl(HcmWorker _hcmworker)
{
_employeeDetailTable.clear();
_employeeDetailTable.BankCode = _hcmworker.BankCode;
_employeeDetailTable.BankIBAN = _hcmworker.BankIBAN;
_employeeDetailTable.ContractEndDate = _hcmworker.ContractEndDate;
_employeeDetailTable.ContractStartDate = _hcmworker.ContractStartDate;
_employeeDetailTable.EmplIdentNumber= _hcmworker.EmplIdentNumber;
_employeeDetailTable.EmployeeArabicName = _hcmworker.EmployeeArabicName;
_employeeDetailTable.EmployeeLeaveGroup = _hcmworker.EmployeeLeaveGroup;
_employeeDetailTable.Nationality = _hcmworker.Nationality;
_employeeDetailTable.insert();
}

*************************************************************

[
SysEntryPointAttribute(false)
]
public void processReport()
{
RecId _hcmworkerid;
HcmWorker _hcmworker;
EmplDetailContract contact = this.parmDataContract();

_hcmworker = HcmWorker::find(contact.parmHcmWorkerId());

this.insertintoEmplDetailTbl(_hcmworker);

}

 

STEP V: Create a AX Model project within VS and include a report. Remember to export the project and include report with in the Application Object Tree (AOT).

STEP VI: Create a “Output” menu item and link it with the controller class.

STEP VII: Add the newly created menu within the respective Form.