Options

Crystal Reports in AXAPTA

mike_espinamike_espina Member Posts: 55
edited 2006-08-23 in Dynamics AX
Hi Experts,

Can Crsytal Reports v.11 be used in inside axapta through x++. FOr example I will make a sales invoice in crsytal reports. How can it be called using x++;

IF yes. Can you give me a sample code.

Thank you very much.


MIKE

Comments

  • Options
    SWZSWZ Member Posts: 8
    Hi Mike,

    I am not very keen on Crystal Reports.
    All I did is a couple of reports in CS that was based on data stored in Axapta Database.

    CS is now owned by Microsoft, isn't it?
    If it provides a COM interface which may be called from Axapta you could possibly do anything.

    Another solution would be (not sure if it is possible), when you create and save a report in CS maybe there is a CS library to call this report with some parameters e.g. Data needed for Sales Invoice

    Regards,

    Sebastian
    Regards,

    Sebastian
  • Options
    HarishHarish Member Posts: 172
    Hi Mike,

    I did some work on integrating CR with Axapta in the past. One solution that you might want to give it a go is -
    compiling CR report into an executable and calling them from Axapta.

    Just curious - is there any particular reason that you want to go down this route at all?

    Hope this helps,
    Harish Mohanbabu
    Long way to go before I sleep..
  • Options
    BigglesukBigglesuk Member Posts: 11
    Any more info you can give on this would be greatly appreciated. I use crystal a lot, as I dont quite have the ablility to create the same reports in Axapta X++ I can do in Crystal XI.

    I would love to learn how I can create a report in Axapta with the datasource set up from Crystal... if any such way exists.
  • Options
    mike_espinamike_espina Member Posts: 55
    Hi,

    I have integrted crsytal reports in axapta.. Use the Active X viewer of crystal reports. put it on the form and then call the crystal report .rpt.

    void ViewCrystalReport()
    {
    Com comapp;
    Com reporting;
    str paramwhole;
    str paramfilename;
    str paramCond;
    str ViewYesNo;
    int ret;
    COMVariant variant;

    ;

    variant = new COMvariant(COMVariantInOut::OUT,COMVariantType::VT_BOOL) ;
    paramwhole = this.args().parm();
    comapp = new COM("CrystalRuntime.Application.11");

    ret = strfind(paramwhole,"|",2,strlen(paramwhole));

    paramfilename = substr(paramwhole,2,ret-2) ;
    ViewYesNo = substr(paramwhole,1,1);
    reporting = comapp.openreport(paramfilename);
    reporting.discardsaveddata();
    reporting.readrecords();

    paramcond = substr(paramwhole,ret+1,strlen(paramwhole));

    reporting.RecordSelectionFormula(paramCond);

    if(ViewYesNo == 'N')
    {
    variant.boolean(false);
    reporting.PrintOut(variant);
    }
    else
    {
    ActiveX.ReportSource(reporting);
    ActiveX.width(1200);
    ActiveX.height(750);
    ActiveX.DisplayToolbar(true);
    ActiveX.DisplayGroupTree(false);
    ActiveX.Refresh();
    ActiveX.ViewReport();
    ActiveX.Refresh();
    }


    }
  • Options
    mnaeembaigmnaeembaig Member Posts: 1
    I am having the following error;

    Method 'add' in COM object of class 'INameValuePairs' returned error code 0x80070057 (E_INVALIDARG) which means: One or more arguments are invalid.

    This error is being generated on the following line of code;

    IConnectionProperty = INameValuePairs.add("Use DSN Default Properties",False);

    I want to change the value of “Use DSN Default Properties” at runtime.

    We have a TMS application, the reports of which we want to display in AX. These reports successfully run on TMS when “Use DSN Default Properties” is set to True. On setting it to False the reports do not work in TMS.

    d787mu0myria.png


    But with “Use DSN Default Properties=True” these reports are not working in AX. Following error is generated in AX.

    Method 'readrecords' in COM object of class 'IReport' returned error code 0x80047E48 (<unknown>) which means: Logon failed.
    Details: [Database Vendor Code: 18456 ].

    This error is being generated on the following line of code;

    reporting.readrecords();

    When I change this value to False at report level, no error is then generated in AX at reporting.readrecords(); line. But again, they stopped working in TMS when its value is changed to False.

    Hence, I want to change its value at runtime for running them in AX. How can I change the value of "Use DSN Default Properties" to False at runtime, any help will be appreciated.

    Following is the complete code;

    public void run()
    {
    Com comapp;
    Com reporting;
    Com IDatabase;
    Com IDatabaseTable;
    Com IDatabaseSingleTable;
    Com INameValuePairs;
    Com INameValuePairs2;
    Com INameValuePairs3;
    COM tc;
    COM IConnectionProperty2;

    Com IConnectionProperty;
    Com ds;
    COM DLL_Name;
    str paramwhole;
    str paramfilename;
    str paramCond;
    str ViewYesNo;
    int ret;
    str selectionFormula;
    COMVariant variant;

    DialogButton diagBut;
    str strMessage;
    str strTitle;
    ;

    super();

    variant = new COMvariant(COMVariantInOut::OUT,COMVariantType::VT_BOOL) ;
    //paramwhole = this.args().parm("'{Employee.empcode}'='11752'");
    paramwhole = this.args().parm();
    //paramwhole = this.args().parm("{Employee.empcode}='11752'");
    //paramwhole = this.args().parm("{?DateFrom}='01/01/2021';{?DateTo}='03/03/2021';{Employee.empcode}='11752'");

    comapp = new COM("CrystalRuntime.Application.11");
    ret = strfind(paramwhole,"|",2,strlen(paramwhole));


    paramfilename = "e:\\Report10.rpt"; //substr(paramwhole,2,ret-2) ;
    ViewYesNo = substr(paramwhole,1,1);
    reporting = comapp.openreport(paramfilename);

    reporting.discardsaveddata();


    comapp.LogonServer("crdb_odbc.dll","tms","tacs", "sa", "Hubleather123");
    // breakpoint;

    IDatabase =reporting.Database();

    IDatabaseTable = IDatabase.Tables();
    IDatabaseSingleTable = IDatabaseTable.Item(1);
    INameValuePairs = IDatabaseSingleTable.connectionproperties();
    IConnectionProperty = INameValuePairs.add("Use DSN Default Properties",False);


    paramcond = substr(paramwhole,ret+1,strlen(paramwhole));

    reporting.RecordSelectionFormula(paramCond);

    reporting.readrecords();


    if(ViewYesNo == 'N')
    {
    variant.boolean(false);
    reporting.PrintOut(variant);
    }
    else
    {
    ActiveX.ReportSource(reporting);
    ActiveX.width(600);
    ActiveX.height(350);
    ActiveX.DisplayToolbar(true);
    ActiveX.DisplayGroupTree(false);

    ActiveX.ViewReport();
    ActiveX.Refresh();
    }


    }



Sign In or Register to comment.