71) How to create a SSRS Report using the contract and Dp class

  I had a scenario where I need to create a SSRS report using the Dp Class :- 


Step 1 :- Create a contract class to define the parameter for the user input :- 

class AvaEntAssetChecklistReportContract

{

    TransDate          fromDate;

    TransDate          toDate;

    EntAssetObjectID   assetID;

     

    

    /// <summary>

    /// Gets or sets the value of the datacontract parameter RecordId.

    /// </summary>

    /// <param name="_recordId">

    /// The new value of the datacontract parameter fromDate; optional.

    /// </param>

    /// <returns>

    ///  The current value of datacontract parameter fromDate

    /// </returns>

    [DataMemberAttribute('From date')]

    public TransDate parmFromDate(TransDate _fromDate = fromDate)

    {

        fromDate = _fromDate;

        return fromDate;

    }


    /// <summary>

    /// Gets or sets the value of the datacontract parameter RecordId.

    /// </summary>

    /// <param name="_toDate">

    /// The new value of the datacontract parameter toDate; optional.

    /// </param>

    /// <returns>

    ///  The current value of datacontract parameter toDate

    /// </returns>

    [DataMemberAttribute('To date')]

    public TransDate parmToDate(TransDate _toDate = toDate)

    {

        toDate = _toDate;

        return toDate;

    }


    /// <summary>

    /// Gets or sets the value of the datacontract parameter In-house bank.

    /// </summary>

    /// <param name="_vendAccount">

    /// The new value of the datacontract parameter assetID; optional.

    /// </param>

    /// <returns>

    ///  The current value of datacontract parameter assetID

    /// </returns>

    [DataMemberAttribute('AssetID')]

    public EntAssetObjectID parmAssetID(EntAssetObjectID _assetID = assetID)

    {

        assetID = _assetID;

        return assetID;

    }


}

=====================================================================


Step 2 :- Create a Dp class and fill the data in temp Table :- 


[

    SRSReportParameterAttribute(classStr(AvaEntAssetChecklistReportContract))

]

class AvaEntAssetChecklistReportDP extends SRSReportDataProviderBase

{

    AvaEntAssetChecklistTmp             assetChecklistTmp;

    AvaEntAssetChecklistReportContract  assetChecklistDetailContract;

    AvaEntAssetChecklistDetailView      entAssetChecklistView;


           

    [SRSReportDataSetAttribute(tableStr(AvaEntAssetChecklistTmp))]

    public AvaEntAssetChecklistTmp getAvaEntAssetChecklistTmp()

    {

        select assetChecklistTmp;

        return assetChecklistTmp;

    }


    public void processReport()

    {

        

        TransDate                       fromDate;

        TransDate                       toDate;

        EntAssetObjectID                assetID;

        RecordInsertList                checkListDetailToBeInserted = new RecordInsertList(tableNum(AvaEntAssetChecklistTmp),

                                                                                           true, // skip insert

                                                                                           true, // skip database log

                                                                                           true, // skip events

                                                                                           true, // skip aos validation

                                                                                           false, // skip RLS validation

                                                                                           assetChecklistTmp);


        assetChecklistDetailContract = this.parmDataContract() as AvaEntAssetChecklistReportContract;


        fromDate = assetChecklistDetailContract.parmFromDate();

        toDate   = assetChecklistDetailContract.parmToDate();

        assetID  = assetChecklistDetailContract.parmAssetID();


        while select entAssetChecklistView

            where entAssetChecklistView.ObjectID == assetID

            && entAssetChecklistView.RegisteredDateTime >= DateTimeUtil::newDateTime(fromDate, 0)

            && entAssetChecklistView.RegisteredDateTime <= DateTimeUtil::newDateTime(toDate, 86399)


        if(entAssetChecklistView)

        {

            assetChecklistTmp.ObjectID           = assetID;

            assetChecklistTmp.ChecklistName      = entAssetChecklistView.ChecklistName;

            assetChecklistTmp.ChecklistValue     = entAssetChecklistView.ChecklistValue;

            assetChecklistTmp.RegisteredDateTime = entAssetChecklistView.RegisteredDateTime;

            assetChecklistTmp.CreatedWorkerName  = entAssetChecklistView.CreatedWorkerName;

            assetChecklistTmp.WorkOrderId        = entAssetChecklistView.WorkOrderId;


            checkListDetailToBeInserted.add(assetChecklistTmp);

        }


        ttsbegin;

        checkListDetailToBeInserted.insertDatabase();

        ttscommit;

        

    }


}


Step 3 :- Create a report and create a output menu item and define the report name and design build and syc and run the report


=======================================================================


Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++