24 November 2020

Contract class example for SSRS report in D365FO

 Controller class example


/// TRG_AgedReceivables

/// <summary>

/// Controller class for Aged receivables report

/// </summary>

class TRG_SalesSummaryController extends SrsReportRunController

{

   


    public static TRG_SalesSummaryController construct()

    {

        return new TRG_SalesSummaryController();

    }


    public static void main(Args arg)

    {

        TRG_SalesSummaryController controller = TRG_SalesSummaryController::construct();

        

        controller.parmReportName(ssrsReportStr(TRG_SalesSummaryCurrencyReport, PrecisionDesign1));

        controller.parmArgs(arg);


        controller.startOperation();

    }


    protected void preRunModifyContract()

    {

        TRG_SalesSummaryContract   dataContract;

        

        TRG_SalesSummaryParameter TRG_SalesSummaryParameter;

        TRG_SalesSummary reportType;


        super();


        dataContract = this.parmReportContract().parmRdpContract() as TRG_SalesSummaryContract;


        reportType = dataContract.parmReportType();


        delete_from TRG_SalesSummaryParameter;


        TRG_SalesSummaryParameter.Fromdate =dataContract.parmFromDate();

        TRG_SalesSummaryParameter.Todate=dataContract.parmToDate();

        TRG_SalesSummaryParameter.Division=dataContract.parmDivisionId();

        TRG_SalesSummaryParameter.Category=dataContract.parmCategoryId();

        TRG_SalesSummaryParameter.Itemid=dataContract.parmItemId();

        TRG_SalesSummaryParameter.Warehouse=dataContract.parmInventLocationId();

        TRG_SalesSummaryParameter.Site = dataContract.parmInventSiteId();

        TRG_SalesSummaryParameter.Customer = dataContract.parmCustAccount();

        TRG_SalesSummaryParameter.SalesGroup= dataContract.parmCommissSalesGroup();

        TRG_SalesSummaryParameter.insert();

       

       

        switch (reportType)

        {

            case TRG_SalesSummary::Customer:

                this.getReportContract().parmReportName(ssrsReportStr(TRG_SalesSummaryCustomerReport, PrecisionDesign1));

                this.parmReportName(ssrsReportStr(TRG_SalesSummaryCustomerReport, PrecisionDesign1));

                break;


            case TRG_SalesSummary::Currency:

                this.getReportContract().parmReportName(ssrsReportStr(TRG_SalesSummaryCurrencyReport, PrecisionDesign1));

                this.parmReportName(ssrsReportStr(TRG_SalesSummaryCurrencyReport, PrecisionDesign1));

                

                break;

        }


       

    }


}


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



/// TRG_AgedReceivables

/// <summary>

/// Controller class for Aged receivables report

/// </summary>

class TRG_InvoiceHistoryController extends SrsReportRunController

{

   


    public static TRG_InvoiceHistoryController construct()

    {

        return new TRG_InvoiceHistoryController();

    }


    public static void main(Args arg)

    {

        TRG_InvoiceHistoryController controller = TRG_InvoiceHistoryController::construct();

        

        controller.parmReportName(ssrsReportStr(TRG_InvoiceHistory, DetailByEachBillingWithCost));

        controller.parmArgs(arg);


        controller.startOperation();

    }


    protected void preRunModifyContract()

    {

        TRG_InvoiceHistoryContract   dataContract;


        TRG_SalesSummaryParameter TRG_SalesSummaryParameter;

        TRG_InvoiceHistory reportType;


        super();


        dataContract = this.parmReportContract().parmRdpContract() as TRG_InvoiceHistoryContract;


        reportType = dataContract.parmReportType();


        //delete_from TRG_SalesSummaryParameter;


        //TRG_SalesSummaryParameter.Fromdate =dataContract.parmFromDate();

        //TRG_SalesSummaryParameter.Todate=dataContract.parmToDate();

        //TRG_SalesSummaryParameter.Division=dataContract.parmDivisionId();

        //TRG_SalesSummaryParameter.Category=dataContract.parmCategoryId();

        //TRG_SalesSummaryParameter.Itemid=dataContract.parmItemId();

        //TRG_SalesSummaryParameter.Warehouse=dataContract.parmInventLocationId();

        //TRG_SalesSummaryParameter.Site = dataContract.parmInventSiteId();

        //TRG_SalesSummaryParameter.Customer = dataContract.parmCustAccount();

        //TRG_SalesSummaryParameter.SalesGroup= dataContract.parmCommissSalesGroup();

        //TRG_SalesSummaryParameter.insert();



        switch (reportType)

        {

            case TRG_InvoiceHistory::DetailByEachBillingWithCost:

                this.getReportContract().parmReportName(ssrsReportStr(TRG_InvoiceHistory, DetailByEachBillingWithCost));

                this.parmReportName(ssrsReportStr(TRG_InvoiceHistory, DetailByEachBillingWithCost));

                break;


            case TRG_InvoiceHistory::DetailByEachBillingWithOutCost:

                this.getReportContract().parmReportName(ssrsReportStr(TRG_InvoiceHistory, DetailByEachBillingWithOutCost));

                this.parmReportName(ssrsReportStr(TRG_InvoiceHistory, DetailByEachBillingWithOutCost));


                break;

        }



    }


}


05 November 2020

How to get data and time from Excel using X++

Below is code snippet can be used to get the date and time from excel.

 // Convert into str from excel cell value

    str COMVariant2Str(COMVariant cv, int decimals = 0, int characters = 0, int separator1 = 0, int _separator2 = 0)

    {

        switch (_cv.variantType())

        {

            case (COMVariantType::VT_BSTR):

            return _cv.bStr();


            case (COMVariantType::VT_R4):

            return num2str(_cv.float(),_characters,_decimals,_separator1,_separator2);


            case (COMVariantType::VT_R8):

            return num2str(_cv.double(),_characters,_decimals,_separator1,_separator2);


            case (COMVariantType::VT_DECIMAL):

            return num2str(_cv.decimal(),_characters,_decimals,_separator1,_separator2);


            case (COMVariantType::VT_DATE):

            //return date2str(_cv.date(),123,2,1,2,1,4);

            return date2str(_cv.date(),213,2,1,2,1,4)+" "+time2str(_cv.time(),TimeSeparator::Colon, TimeSeparator::Colon);


            case (COMVariantType::VT_EMPTY):

            return '';


            default:

            throw error(strfmt('@SYS26908', _cv.variantType()));

        }

        return '';

    }

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...