Home computer programming, dynamics ax, others, sql server, ssrs [ax 2012] tutorial – how to create a printing form using SSRS
computer programmingdynamics axotherssql serverssrs

[ax 2012] tutorial – how to create a printing form using SSRS

tutorial – how to create a printing form using SSRS

to make a printing form using SSRS, we need 1 temporary tables, 1 SSRS Report, 1 controller class, 1 contract class and 1 DP (data provider) class. And also we gonna need menu items, and jobs (for testing data, incase we need it), and Modified PurchEditLines Form

as example, we’re gonna making a receipt print from purchase order

  1. create a temporary table
    1. see the picture below
    2. Set Table Type : In Memory
    3. Create a field just like the picture does, CustomerAddress (250), CustomerName (100), DeliveryAddress (250), DeliveryName (100), Description (250), InternalProduct (100), ItemId (20), Note (250), OrderedQty (real-Qty), PackingSlipId (20), PurchDate (date-transdate), ReceiveQty (real-Qty), RemainingQty (real-Qty), Unit (10)
  2. create Controller Class
    1. see the source code below
      public class GlkRptSjReturController extends SrsReportRunController
          GlkRptSjReturContract       _contract;    
          PurchParmUpdate             _PurchParmUpdate;
      protected void prePromptModifyContract()
          FormDataSource              fds;
          _contract = this.parmReportContract().parmRdpContract() as GlkRptSjReturContract;
          fds = args.record().dataSource();
          _PurchParmUpdate = args.record();
      public static client void main(Args args)
          GlkRptSjReturController ssrsController;
          FormDataSource          fds;
          fds = args.record().dataSource();
          ssrsController = new GlkRptSjReturController();


  3. create Contract Class
    1. see the source code below
      class GlkRptSjReturContract
          ParmId _ParmId;
      public ParmId parmParmId(ParmId ch = _ParmId)
          _ParmId = ch;
          return _ParmId;
      public boolean validate()
          return true;


  4. create DP Class
    1. see the source code below
      class GlkRptSjReturDP extends SRSReportDataProviderBase
          GlkTblTmpRptReturSJ   _temptable;
      public GlkTblTmpRptReturSJ getTempTable()
          select * from _tempTable;
          return _tempTable;
      public void processReport()
          PurchParmTable              _PurchParmTable;
          PurchParmLine               _PurchParmLine;
          ParmId                      _ParmId;
          PurchTable                  _PurchTable;
          PurchLine                   _PurchLine;
          GlkRptSjReturContract       _contract;
          VendTable                   _vend;
          LogisticsPostalAddressView2 _address1;
          _contract = this.parmDataContract() as GlkRptSjReturContract;
          _ParmId = _contract.parmParmId();
          while select * from _PurchParmTable
              join _PurchParmLine
              where _PurchParmTable.ParmId == _ParmId
                  && _PurchParmLine.ParmId == _ParmId
                  _PurchTable = PurchTable::find(_PurchParmTable.PurchId);
                  _vend = VendTable::find(_PurchTable.OrderAccount);
              _PurchLine = PurchLine::findRecId(_PurchParmLine.PurchLineRecId);
              _temptable.ItemId           = _PurchParmLine.ItemId;
              _temptable.PurchId          = _PurchParmTable.PurchId;
              _temptable.PurchDate        = systemDateGet();
              _temptable.PackingSlipId    = _PurchParmTable.Num;
              _temptable.Note             = _PurchParmTable.NoteDesc;
              _temptable.Description      = _PurchParmLine.name();
              _temptable.ReceiveQty       = -1 * _PurchParmLine.ReceiveNow;
              _temptable.Unit             = _PurchLine.PurchUnit;
              _temptable.CustomerName     = _vend.name();
              _temptable.CustomerAddress  = _vend.address_BR();
              _temptable.DeliveryName     = InventLocation::find(_PurchLine.inventDim().InventLocationId).Name;
              _temptable.DeliveryAddress  = InventLocation::find(_PurchLine.inventDim().InventLocationId).address();


  5. create SSRS Report
    1. create SSRS Report in Visual Studio
    2. named it GlkRptReturSJ
    3. Add data set. named it DataSet1, datasource type : Report Data Provider (RDP), click edit on Query
    4. Choose GlkRptSJReturDP as data provider 
    5. next button, pick all fields , then ok button
    6. on design, create precission design 
    7. rename it to RptReturSJ, set Style Template in properties to Table Style Template
    8. save it, and right click RptReturSJ, choose edit using designer
    9. design it, and save it
    10. Compile it and publish it
  6. Creating a Menu Action
    1. create menu action and link it to your controller 
    2. if object did not shows up, remember to clear the cache (tools-caches-refresh dictionary, refresh data, refresh element, and refresh report server)
    3. if object still not shows up, recompile the class, and generate cil incremental
  7. Inserting menu action into PurchEditLines Button
    1. see the picture below,


recompile it, (restart Aos incase you need it)

you can download PrivateProject_GlkRptSJRetur for your purposes




Leave a Reply