Creating an SSRS report with classes

Hi, i will explain creating an SSRS report with classes and visual studio designs.
There must be 3 main (controller,contract,DP) and 1 optional classes (UIBuilder) if parameters needed.
Also 1 Temporary(TMP) table required to fill and then select data for the report.

1) Controller class is required for specifying the arguments(args) and the SSRS report name and the design.
2) Contract class is the parameter class. This class is used to return values.
3) DP class contains processReport method to fill a Temp table (TMP) and this table will be used to select data for the report.
4) UIBuilder class is used; if more parameters are needed. This class is used to create a dialog box that is helpful for the users who wants to call the report with specific parameters as selected.

Create a table with "TMP" suffix and create the fields for the required data that will be selected in the report. Go to table properties and check the "CreatedTransactionId" property as "Yes" (Required while creating the report design in Visual Studio).




1) Controller Class:

Contains a main method to specify the report and design name. Also can contain "prePromptModifyContract" method to send the args to contract method if args are transferred from a selected record on a form.


1
2
3
class YourControllerClass extends SrsReportRunController
{
}

----------------------------------------------------------

1
2
3
4
5
6
7
8
public static client void main(Args _args)
{
   YourControllerClass controller = new YourControllerClass ();
   controller.parmArgs(_args);
   controller.parmReportName(ssrsReportStr(YourReportName,ReportDesignName));
   controller.prePromptModifyContract(); //if you will have a preset recId...
   controller.startOperation();
}
----------------------------------------------------------

Use this if you want to send recID of a record on a form where you will use the report.
This method takes the selected record's recId when on a form and transfers recId data to contract //class.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
protected void prePromptModifyContract()
{
    DataSelectedTable DataSelectedTable; //table where you will take the recId as parameter.
    YourContractClass contract; 
    contract = this.parmReportContract().parmRdpContract() as YourContractClass;

    if (this.parmArgs() && this.parmArgs().record())
    {
        DataSelectedTable = this.parmArgs().record();
        contract.parmRecordId(DataSelectedTable.RecId);
    }
}



2) Contract Class:

This class contains only parm methods to return values that you sent as parameters.


1
2
3
4
5
6
7
8
[DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(YourReportUIBuilder))
]//This part is required if you have a UIBuilder class.Otherwise not necessary.

public class YourContractClass
{
    RecId   recordId;
}
----------------------------------------------------------

1
2
3
4
5
6
[DataMemberAttribute('RecordId')]
public RecId parmRecordId(RecId _recordId = recordId)
{
    recordId = _recordId;
    return recordId;
}

These parm methods can be multiple for other fields if necessary.

3) DP Class:

This class is used to transfer data from contract class and fill your TMP table and so will be used on your report.


1
2
3
4
5
6
7
8
[
SRSReportParameterAttribute(classStr(YourContractClass))
]
public class YourDPCLass extends SrsReportDataProviderPreProcess
{
    YourTableTMP   yourTableTMP;
    RecId          tableRecId; //parmed datatableRecId. Now will be transferred to this class for use to fill the TMP table.
}

SrsReportDataProviderPreProcess => you can debug your code like this; better than SrsReportDataProviderBase.

----------------------------------------------------------


1
2
3
4
5
6
7
// Returning the TMP table to use in SSRS report dataset.
[SRSReportDataSetAttribute(tableStr(YourTableTMP))]
public YourTableTMP getYourTableTMP()
{
    select * from yourTableTMP;
    return yourTableTMP;
}

----------------------------------------------------------

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[SysEntryPointAttribute(false)]
public void processReport()
{
    YourContractClass contract;
    contract = this.parmDataContract();

    tableRecId = contract.parmRecordId(); //get recId as parameter.

    //fill your TMPtable in here as what query do you want to use.
} 

----------------------------------------------------------
4) UIBuilder Class:

This class is used to let users to select or enter parameters manually and take the report connected with that parameters if necessary.

1
2
3
4
5
6
7
// You can define your dialog fields as shown below.
class YourReportUIBuilder extends SrsReportDataContractUIBuilder
{
    YourReportContract     contract;
    DialogField            DFparamfield;
    DialogGroup            dlgGrp; //Not necessary. Used for grouping parameters only.
}

----------------------------------------------------------

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
public void build()
{
    Dialog          dialogLocal = this.dialog();
    ;

    contract = this.dataContractObject() as YourContractClass;

    dlgGrp = dialogLocal.addGroup("group name");
    this.addDialogField(methodStr(YourContractClass,parmRecId),contract);
}

----------------------------------------------------------

1
2
3
4
5
public void getFromDialog()
{
    contract = this.dataContractObject();
    super();
}

----------------------------------------------------------

1
2
3
4
5
public void postBuild()
{
    super();
    DFparamfield = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(YourCotractClass, parmContainerId));
}

* In order to debug your codes, first you need to have a design created in Visual Studio.

Click on the link below on how to design SSRS report on Visual Studio and Deploy on AX System

Visual Studio SSRS Report Design

Comments

Post a Comment

Popular posts from this blog

How to find Company Logo (X++)

How to find MainAccount with LedgerDimension (X++)

How to do barcode in SSRS (X++)