Günü Sözü

"Hiçbir şey bilmeyen cahildir, ama bilip de susan ahlaksızdır. " Bertolt Brecht.
"İyilik yapabildiğim zaman mutlu olurum; ama en büyük mutluluk yapılan bir haksızlığı düzeltmektir." Tolstoy

23 Şubat 2016 Salı

control class ile ms dynamics ax 2012 de ssrs rapor geliştirme örneği - using controller class in developing SSRS Reports in ms dynamics ax 2012

aşağıdaki seneryolar, controller class kullanılarak yapılacak
 
Giriş verileri temel alan bir rapor sorgusunu değiştirme
 
Following are the scenarios where Controller class can be used:
  1. Modifying a report query based on the input data
  2. Modifying report contract data based on the input data
  3. Control a report parameters dialog
  4. Open different reports/designs from the same menu item based on the input data
  5. Reports that are opened from a form
To create a controller class, extend it with SrsReportRunController.
 

Prerequisites

  1. Microsoft Dynamics AX 2012
  2. Reporting services extensions must be installed in Dynamics AX

Sample Controller Class

  1. Create a new class. Open AOT → Classes
  2. Right Click on Classes and select New Class. Name it as SSRSDemoController.
  3. example of creating a new class in Dynamics AX
     
  4. Open the Class declaration by right clicking on it and selecting View code.
  5. example of viewing code in AOT class AX
     
  6. Now write the following code:


  7. Create a new method and write the following code:

16 Şubat 2016 Salı

Default boyutlu hareketlerin excele aktarımı

how to export transactions with default dimensions to Excel
public static void main(Args _args)
{
    AssetTrans assetTrans; 
    SysExcelApplication application;
    SysExcelWorkBooks workbooks;
    SysExcelWorkBook workbook;
    SysExcelWorksheets worksheets;
    SysExcelWorksheet worksheet;
    SysExcelCells cells;
    SysExcelCell cell;
    int row;
    DimensionAttributeValueSetItemView dimAttrSet;
    DimensionAttribute dimAttr;
    str dimAttrStr;
    Map dims;
    int dimNum;
    ;
    application = sysExcelApplication::construct();
    workbooks = application.workbooks();
    workbook = workbooks.add(); 
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    cells.range(‘A:A’).numberFormat(‘@’);
    dims = new Map(Types::String, Types::Integer);
    //generate header    row++;
    cell = cells.item(row, 1); 
    cell.value(“Voucher“);
    cell = cells.item(row, 2); 
    cell.value(“Transaction date“);
    cell = cells.item(row, 3); 
    cell.value(“Fixed asset number“);
    cell = cells.item(row, 4); 
    cell.value(“Transaction type“);
    cell = cells.item(row, 5);
    cell.value(“Amount“);
    cell = cells.item(row, 6); 
    cell.value(“Fixed asset group“);
    //generate lines    while select assetTrans
    //The following loop will provide the data to be populated in each column    {
        row++;
        //add fixed asset trans data        cell = cells.item(row,1);     
        cell.value(assetTrans.Voucher);
        cell = cells.item(row,2);
        cell.value(assetTrans.TransDate);
        cell = cells.item(row,3);
        cell.value(assetTrans.AssetId);
        cell = cells.item(row,4);
        cell.value(enum2str(assetTrans.TransType));
        cell = cells.item(row,5);
        cell.value(assetTrans.AmountCur);
        cell = cells.item(row,6);
        cell.value(assetTrans.AssetGroup);
        // add dimensions        while select dimAttrSet
            where dimAttrSet.DimensionAttributeValueSet == assetTrans.DefaultDimension
        join Name from dimAttr
            where dimattr.RecId == dimAttrSet.DimensionAttribute
        {
            if (!dims.exists(dimAttr.Name)) // if dim column does not exists            {
               //add dimension column               dims.insert(dimAttr.Name, dimNum + 7);
               dimNum++;
               cell = cells.item(1, dims.lookup(dimAttr.Name));
               cell.value(dimAttr.Name);
            }
           //add dimension value           cell = cells.item(row, dims.lookup(dimAttr.Name));
           cell.value(dimAttrSet.DisplayValue);
        }
    }
    application.visible(true); // opens the excel worksheet}