ssrs etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
ssrs etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

10 Kasım 2017 Cuma

AX 2012 - SSRS Report Carry Forward and Page Total

Unfortunately adding carry forward and page total are a bit tricky with SSRS. I used up a blog (Peter ?) for carry forward and another blog (Annette Theißen) for page total.

Name our field for use total AccountingCurrencyAmountDebit.

Add a textbox for carry forward named dCarry, and value like below:

=RunningValue(Fields!AccountingCurrencyAmountDebit.Value,SUM,"LedgerTransListAccountDS")

or if we will group by account num:


=RunningValue(Fields!AccountingCurrencyAmountDebit.Value,SUM,"AccountNum_0")


Carry previous named dCarryH and like this:

=RunningValue(Fields!AccountingCurrencyAmountDebit.Value,SUM,"AccountNum_0") - Fields!AccountingCurrencyAmountDebit.Value

Put visibility to no both of them. Even they hidden values will be calculated.

For show carry previous value add a textbox to Page Header,  it's value should be like:

=First(ReportItems!dCarryH.Value)

Visibility have to bound a condition (So there won't be carry previous at first page):

=Globals!PageNumber=1

Add a textbox for carry forward to Page Footer and put value like this:

=last(ReportItems!dCarry.Value)

It's Visibility bound a condition too (So there won't be carry forward at last page):

=Globals!PageNumber=Globals!TotalPages

We need two data methods and some variables for page total. For add Data method do right mouse - Add Data Method at treeview's Data Methods node under Designs. Than double click for open code window. Our code is red lined:

using System;
using System.Collections.Generic;
using System.Security.Permissions;
using System.Data;
using Microsoft.Dynamics.Framework.Reports;
using Microsoft.Dynamics.AX.Application.Reports;
public partial class LedgerTransListAccount
{
    static double previousTotal;
    static double pageTotal;
    static bool NewAccount;
    static string lastAccount;

     ...
   
 [DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    public static double PageTotal(double total)
    {
         if (NewAccount)
            return total;
         else
            return total - previousTotal;
    }

    [DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    public static double PreviousTotal(double total)
    {
        previousTotal = total;

        return 0;
    }
[DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    public static string Reset()
    {
        NewAccount = false;
        lastAccount = "";

        return "";
    }

    [DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    public static string FollowAccount(string account)
    {
        if (lastAccount != "" && lastAccount != account)
            NewAccount = true;
        lastAccount = account;

        return account;

    }
      
}

Add a textbox at Page Footer:

=PreviousTotal(First(ReportItems!dCarryH.Value))

Unfortunately if we make visible = false it doesn't calculate. Instead of make visible false we make display format as number and change Show zero as combobox value with blank (Not Nonel!!).

Add a textbox for page total:

=PageTotal(last(ReportItems!dCarry.Value))

If you ask why we used an extra textbox; unfortunately SSRS doesn't accept two field for expression parameters.

Add a textbox to page header:

=Reset()

29 Eylül 2014 Pazartesi

AX 2012 - R3 Installation

In first check  minimum system requirements . MS-SQL collate doesn't installed as turkish. With turkish like SAP and Oracle you'll have problems about "i" letter of turkish, after AX 2012 install, at database sync, installation will fail.
I used Dilip's Blog for installation instead of Microsoft's long and complex white paper. Installation of AX 2012 is so easy of it's mine change. :)

In first Active Directory should be installed. There are plenty of pages about AD installation at Google.

I just used basic AX 2012 like Dilip's, let SSRS etc. installation later. AX 2012 setup gives prerequisities links and configures some of prerequisities automatically. I didn't faced any problem at installation.

After installation I upload demo data again from a  blog page . Demo installation was harder than AX 2012 installation.

I installed SQL Server SSRS add-in and configured look from a blog . Anyway for developing SSRS reports (Doesn't require for deploy) don't forget install Business Intelligence Development Studio from SQL Server Setup. SSRS configure was so easy; in order run Service account, Web service URL, Database, Report Manager URL tabs with defaults was enough.

Again I used  another Dilip page for SSRS install. I haven't got any trouble and didn't need Dilip's manual complete way for install, reports deployed smootly. :)

4 Ağustos 2014 Pazartesi

AX 2012 - SSRS How to suppress zero as blank?

Put this instead of put field (At this time PurchPrice) itself:

=IIF(Fields!PurchPrice.Value = 0 ,"",Fields!PurchPrice.Value)

11 Temmuz 2014 Cuma

AX 2012 - Send marked records to SSRS RDP Report

SSRS DP Class don't accept table or container data types as parm method. I searched at forums and saw str data type adviced. But I think this's not best approach. At last learned best way already in standard AX SSRS reports. At this link there's a PDF file tells look for check report. I generated this report with look form ChequeDP and ChequeController classes:

Controller class:

class declaration:

class myController extends SrsReportRunController
{
    #define.ReportName('myreport.Report')
   myTMPTable   myTMPTable;
}

public static void main(Args _args)
{
    SysLastValue    SysLastValue;
    myController controller = new myController();
    controller.parmReportName(#ReportName);
    controller.parmArgs(_args);
    controller.DeleteTmpData();
    controller.init();
    controller.startOperation();
}


protected void prePromptModifyContract()
{

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

    new SRSReportRunPermission().assert();
    contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(myTMPTable));

}


public void init()
{
    FormDataSource      ds;
    TransDate           transDate;
    VendTrans           vendTrans;


    if (!this.parmArgs()             ||
        !this.parmArgs().record()    ||
        this.parmArgs().dataset() != tableNum(VendTrans))
        throw error("Report should be call with correct parameter!..");

    ds = this.parmArgs().record().dataSource();

    vendTrans = ds.getFirst(1);
    transDate = vendTrans.transDate;
    PaymentReceipt.VendAccount = vendTrans.AccountNum;

    for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
    {
        myTMPTable.Date             = vendTrans.TransDate;

...
        myTMPTable.insert();
    }
}


DP Class:

// <ETG - memre > GN:   T: 11.07.2014 A:
[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]
public class mpDP extends SRSReportDataProviderBase
{
    myTMPTAble myTMPTable;
}


private void initTmpTable()
{
    SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;

    new SRSReportRunPermission().assert();

    myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());

    SRSTmpTblMarshaller::deleteTmpTblData(contract.parmTmpTableDataRecId());
    CodeAccessPermission::revertAssert();
}


public void processReport()
{

    CompanyInfo                 Company;
    VendTable                   vendTable;
    AmountMST                   amount;
    TempStr                     NumtoTxt;
    LedgerJournalTrans          LedgerTrans;

    this.initTmpTable();

...
}

17 Haziran 2014 Salı

AX 2012 Add Query to SSRS report when developing with RDP

Add query attribute to data provider class:

[
    SRSReportQueryAttribute (querystr(Cust)),
    SRSReportParameterAttribute(classstr(myReportContract))
]
class myReportDP extends SRSReportDataProviderBase
{
    ...

}
Get query like this:

[SysEntryPointAttribute(false)]
public void processReport()
{
    QueryRun                    qRun;
    Query                       query;
     ...

    query = this.parmQuery();
    ...



Do not forget make Dynamics Filter property to true at SSRS report Dataset if you want to see select query button.

4 Şubat 2014 Salı

AX 2012 - Test RDP class at Axapta side

How do you test your RDP classes developed for SSRS reports at AX side?

DGHCreditDetailsDP  dp = new DGHCreditDetailsDP();
DGHCreditDetailsDC  dc = new DGHCreditDetailsDC();

Query q;

dc.parmTransDate(str2Date("28.12.2013",123));

q = dp.parmQuery();

         q.dataSourceTable(tableNum(BankAccountTrans)).addRange(Fieldnum(BankAccountTrans,accountid)).value("102 02 034 002");

dp.parmDataContract(dc);
dp.processReport();

6 Ocak 2014 Pazartesi

AX 2012 - Create SSRS report PDF output

I got help from Martin Drab's blog for create PDF with AX 2012:

void CreatePDF(Str60 _Subject,Notes _Body)
{
MYReportPurchController          controller;
MYReportPurchContract            rdpContract = new MyReportPurchContract();
SRSPrintDestinationSettings settings;
Args                        args = new args();
str                         fileName;

args.record(this);
controller = MYReportPurchController::construct(args);
// Define report and report design to use
controller.parmReportName(ssrsReportStr(EtgPurchOrderForm,PrecisionDesign1));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
// Suppress report dialog

// Explicitly provide all required parameters
controller.parmReportContract().parmRdpContract(rdpContract);
    //rdpContract.
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
//settings.

    #WinAPI

  fileName = WinApi::getTempPath() +this.PurchOrderDocNum+".PDF";
settings.fileName(fileName);
// Execute the report
    controller.parmShowDialog(false);
    controller.startOperation();
}


Or send selected records to PDF by RDP report:
 
SMAServiceOrderTable        serviceOrder;
    MultiSelectionHelper        helper;
    FormRun                     caller = _args.caller();
    FormDataSource              SMAServiceOrderTable_DS;
    SRSPrintDestinationSettings settings;
    ETGServiceReportContract    contract = new ETGServiceReportContract();
    SrsReportRunController      controller;
    Filename                    fileName;
    int                         counter;
    SysMailer                   mailer = new SysMailer();
    SysEmailParameters          parameters = SysEmailParameters::find();
    Dialog                      dialog;
    DialogField                 field;
    Email                       email;

    dialog = new Dialog("Servis Raporu Gönderme");
    field = dialog.addField(ExtendedTypeStr(email));
    dialog.run();

    if (!dialog.closedOK())
        return;
    email = field.value();
    if (email == "")
        throw error("Bir mail adresi girmelisiniz!..");

    SMAServiceOrderTable_DS = caller.dataSource();
    helper = MultiSelectionHelper::createFromCaller(caller);
    if (parameters.SMTPRelayServerName)
    {
        mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
    }
    else
    {
        mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
    }
    
    mailer.fromAddress('noreply@sinbo.com.tr');
    mailer.tos().appendAddress(email);
    mailer.htmlBody('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">Sayın Yetkili,<br><br> Servis raporu kopyanız ektedir.<br><br>Saygılarımızla,<br><br><br>Sinbo');
    mailer.subject('Sinbo Servis Raporu');
    mailer.bodyCharSet("Windows-1254");

    helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
    serviceOrder = helper.getFirst();

    while(serviceOrder)
    {
        controller = new SrsReportRunController();
        controller.parmReportName(ssrsReportStr(ETGServiceReport, Report));
        contract = controller.parmReportContract().parmRdpContract();
        controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
        controller.parmShowDialog(false);
        contract.parmServiceOrderId(serviceOrder.ServiceOrderId);

        counter++;
        fileName = WinApi::getTempPath() + strFmt("Servis Raporu %1.PDF",counter);
        
        settings = controller.parmReportContract().parmPrintSettings();
        settings.overwriteFile(true);
        settings.printMediumType(SRSPrintMediumType::File);
        settings.fileFormat(SRSReportFileFormat::PDF);
        settings.fileName(fileName);
        
        controller.startOperation();
        mailer.attachments().add(fileName);
        serviceOrder = helper.getNext();
    }
    if (counter == 0)
        return;
    infolog.clear();



    mailer.sendMail();