How to get a datatable from AX to SSRS report

 

We can easily get a datatable from AX to SSRS report. All the business logic can be written in AX, and the SSRS is the data showing platform.

[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
public static DataTable GetData(string _PurchaseOrderId)
{
    AxaptaWrapper ax = SessionManager.GetSession();
    DataTable dt = (DataTable)ax.CallStaticClassMethod("ClassName", "StaticMethod", Parm1, Parm2...);

    return dt;
}

 

public static System.Data.DataTable GetData()
{
    System.Data.DataTable               m_DataTable;
    System.Data.DataColumnCollection    m_DataColumnCon;
    System.Data.DataRowCollection       m_DataRowCon;
    System.Data.DataRow                 m_DataRow;
    CustTable                           m_CustTable;
    InteropPermission                   permission = new InteropPermission(InteropKind::ClrInterop);
    ;

    permission.assert();

    m_DataTable     = new System.Data.DataTable();
    m_DataColumnCon = m_DataTable.get_Columns();
    m_DataRowCon    = m_DataTable.get_Rows();

    m_DataColumnCon.Add("AccountNum");
    m_DataColumnCon.Add("NameAlias");

    while select m_CustTable
    {
        m_DataRow = m_DataTable.NewRow();
        m_DataRow.set_Item("AccountNum", m_CustTable.AccountNum);
        m_DataRow.set_Item("NameAlias", m_CustTable.NameAlias);
        m_DataRowCon.Add(m_DataRow);
    }

    return m_DataTable;
}

  

  

posted @ 2014-09-10 09:11  Sprite.z  Views(318)  Comments(0Edit  收藏  举报