Dynamics AX Blog - ssrs

These posts are machine-translated.
Currently, only posts are displayed, which contain the tag »ssrs« Filter entfernen

Debugging SSRS-Dataprovider which extends SrsReportDataProviderPreProce

In Debugging SSRS-Dataprovider I have already described how to "debug" a DataProvider derived from SRSReportDataProviderBase.

The following job basically does the same, but for preprocessed reports, where the DataProvider is derived from SrsReportDataProviderPreProcess. In the example, I use the DataProvider of an invoice (SalesInvoice).

static void testSSRSDataProvider_SalesInvoice(Args _args)
{
    SalesInvoiceTmp salesInvoiceTmp;
    SalesInvoiceDP dataProvider = new SalesInvoiceDP();
    SalesInvoiceContract contract;
    CustInvoiceJour CustInvoiceJour = CustInvoiceJour::findRecId(35637191172);
    UserConnection UserConnection;

    try
    {
        ttsBegin;

        UserConnection = new UserConnection();

        contract = new SalesInvoiceContract();
        contract.parmFormLetterRecordId(CustInvoiceJour.RecId);
        contract.parmRecordId(CustInvoiceJour.RecId);

        dataProvider = new SalesInvoiceDP();
        dataProvider.parmDataContract(contract);
        dataProvider.parmUserConnection(UserConnection);
        dataProvider.processReport();

        salesInvoiceTmp = dataProvider.getSalesInvoiceTmp();
        
        while select salesInvoiceTmp
            where SalesInvoiceTmp.createdTransactionId == appl.curTransactionId()
        {
            info(strFmt("%1 %2", SalesInvoiceTmp.InvoiceId, SalesInvoiceTmp.ItemId));
        }

        ttsCommit;
    }
    catch (Exception::Break)
    {
        info("Aborted");
    }
}

 


 
 
 

Call SSRS-Report through code

A common requirement is that a report / report should be printed automatically at a certain point in time.

It is usually important to be able to give certain parameters to the report to be printed, and depending on how the report is structured on the development side this can be more or less complicated.

The following code calls a relatively simple Dataprovider-based report:

TutorialMyReportDataContract dataContract;
SrsReportDataContract srsReportDataContract;

controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(TutorialMyReport, MyDesign)); 
controller.parmShowDialog(false);    
controller.parmLoadFromSysLastValue(false);  

srsReportDataContract =
controller.parmReportContract();

dataContract = srsReportDataContract.parmRdpContract();

dataContract.parmSalesId("S1000"); 

The next example calls the standard report Transactions (Customer Accounts > Reports > Transactions > Customer). The special feature of this report is that it uses a query within the data provider. To access these was the challenge:


 
 
 

Get design names of a SSRS report

Anyone who has the need to get the available designs of a SSRS report, can use the following job.

static void listDesignsOfSSRSReport(Args _args)
{
    TreeNode treeNode;
    TreeNode treeNodeDesign;
    #aot
  
    treeNode = TreeNode::findNode(#SSRSReportsPath + #AOTRootPath);
    treeNode = treeNode.AOTfindChild("SalesPackingSlip");
    treeNodeDesign = treeNode.AOTfindChild("Designs");
  
    treeNodeDesign =
    treeNodeDesign.AOTfirstChild();
    while(treeNodeDesign)
    {
        info(treeNodeDesign.AOTname());   
      
        treeNodeDesign = treeNodeDesign.AOTnextSibling();
    }
}

 
 
 

Debugging SSRS-Dataprovider

In the past i often had the problem, that i had to debug a dataprovider of a SSRS-Report, which could not be debugged using the well known Dynamics AX Debugger (for example because the dataprovider is executed only on server).

Therefore i created the below job (DataProvider has to extend SRSReportDataProviderBase), which only puts the content of the created (temporary) table to an simple infolog.

In the example the report "Work note" of the service module is used.

static void testSSRSDatProvider(Args _args)
{
    SMAWorkNoteTmp      tempTable;
    SMAWorkNoteDP       dataProvider = new SMAWorkNoteDP();
    SMAWorkNoteContract contract = new SMAWorkNoteContract();
    Query               query = new Query(identifierStr(SMAWorkNote));

    try
    {
        SysQuery::findOrCreateRange(
            query.dataSourceTable(
                tableNum(SMAServiceOrderTable)),
                fieldNum(SMAServiceOrderTable, ServiceOrderId)).value("00018");

        contract.parmItemConsumption(true);
        contract.parmItemRequirement(true);
        contract.parmExpense(true);
        contract.parmFee(true);
        contract.parmAdditionalNotes(true);
        contract.parmLineText(true);

        if( !contract.validate())
        {
            throw error(error::missingParameter(contract));    
        }

        dataProvider.parmDataContract(contract);
        dataProvider.parmQuery(query);
        dataProvider.processReport();

        tempTable = dataProvider.getSMAWorkNoteTmp();

        while select tempTable
        {
            info(tempTable.otServiceOrderId);
        }
    }
    catch (Exception::Break)
    {
        info("Aborted");
    }
}

 
 
 

 

 
 
 
Posts of the actual month
Juli 2019
MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
293031 
 
© 2006-2019 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.