Opening a Crystal Report from inside Navision

jorgitojorgito Member Posts: 115
Hi all.

I've been searching this forum for so many hours and I can't find the solution to my problem.

I have created a report using Crystal Reports 9. I have saved it as Report1.rpt in c:\

I have a button in a form and in its Push event I want to enter code that displays Report1.rpt.

I do not know what Automation objects to create and how to use them in order to define the filename of the report and display it to the user. (I do not wish to use HYPERLINK!!) I have found some sample code in this forum but no one explicitly mentions what subtype the Automation object is and what class it is.

After I get this right, the next step will be to pass variables to the saved report, in order to filter the data displayed.

Thank you in advance,

Jorgito

Comments

  • jorgitojorgito Member Posts: 115
    I tried the following:

    I created a report and used the table Customer as DataItem.

    I created 3 variables

    CRViewer Automation 'Crystal Report Viewer Control'.CRViewer
    CRReport Automation 'Crystal Reports 9 ActiveX Designer Design and Runtime Library'.Report
    CRApp Automation 'Crystal Reports 9 ActiveX Designer Design and Runtime Library'.Application

    Then I entered the following code:
    Customer - OnPreDataItem()
    CREATE(CRApp);
    CREATE(CRViewer);
    
    CRReport := OpenReport('C:\My Documents\Report1.rpt', 0);
    CRViewer.ReportSource := CRReport;
    CRViewer.ViewReport;
    
    

    When I run it, I get the following error:
    The data type is not supported by C/SIDE. You can access data from any of the following data types: VT_VOID, VT_I2, VT_I4, VT_R4, VT_R8, VT_CY, VT_DATE, VT_BSTR and VT_BOOL. 
    
    

    Any ideas? Should I use OCX instead of Automation objects? If yes, how?

    Thanx in advance,
    Jorgito
  • themavethemave Member Posts: 1,058
    you can use the hyperlink functions to launch the report

    here is a link to a discussion on it

    http://dynamicsuser.net/forums/thread/3561.aspx

    good luck
  • SavatageSavatage Member Posts: 7,142
    themave wrote:
    you can use the hyperlink functions to launch the report

    here is a link to a discussion on it

    http://dynamicsuser.net/forums/thread/3561.aspx

    good luck

    I must have been chatty that day - but the first post says he doesn't want to use Hyperlink. It sounds he already search the forum for "Crystal" :-k

    I simply don't have the time to test it right now.
  • jorgitojorgito Member Posts: 115
    As Savatage stated, I do not wish to use HYPERLINK, because I want to send parameters to the report in order to filter data.

    It seems a little strange that no one has a solution for my problem. You mean that no one has tried to open crystal reports from within navision? Everyone is either using standard navision reports or external (and complicated) mis tools?

    What I want to do is create more complicated reports that standard navision reports. If someone has another solution that Crystal, please let me know...

    Thanx
    Jorgito
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Well going forward the solution is Reporting Services, since that is where all reports in Navision are headed. This of course does not answer your question, since it means running outside Navision also (well maybe in 5.1).
    David Singleton
  • themavethemave Member Posts: 1,058
    jorgito wrote:
    As Savatage stated, I do not wish to use HYPERLINK, because I want to send parameters to the report in order to filter data.

    It seems a little strange that no one has a solution for my problem. You mean that no one has tried to open crystal reports from within navision? Everyone is either using standard navision reports or external (and complicated) mis tools?

    What I want to do is create more complicated reports that standard navision reports. If someone has another solution that Crystal, please let me know...

    Thanx
    Jorgito
    here is what we do
    1. Make more complicated reports in Navision, and use the Navision tools, not too hard to learn.
    2. Make other reports with Crystal and use Hyperlink from Navision, so user can run them without having to know anything.
    3. For user that need more complicated thing, I make a Crystal report and show then how to run it on there own.

    It seems you want your users to be able to run really complicated reports without having to know anything, and that is tough to do. What I have found is if your users are running really complicated reports but don't even have enough knowledge of how to create them, they probably don't really use the reports anyways. We used to run a whole set of batch reports every night and distribute to all the managers, what a waste of paper that was.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    themave wrote:

    ... We used to run a whole set of batch reports every night and distribute to all the managers, what a waste of paper that was.

    How true that is... I am sure we have all had a client like that.
    David Singleton
  • jorgitojorgito Member Posts: 115
    We could debate for days or even weeks on how important or not complicated reports are, or how much knowledge the users should have, but my question remains:

    Could you please show me some sample code on how to open a Crystal report using Navision code (Automation objects).

    I DO NOT WISH TO USE HYPERLINK!!

    Thank you
    Jorgito
  • archaingelsarchaingels Member Posts: 5
    the same with jorgito.

    Please help us how to Open Crystal Report within Navision (we don't want to use hyperlink). Anyone know how to create objects inside navision using crystal report?

    thanks,

    archaingels
    God loves us!!!
  • SavatageSavatage Member Posts: 7,142
    You could always use Shell to :lol:

    SHELL('C:\Program Files\Crystal Decisions\Crystal Reports 9\crw32.exe m:\daily\EditList.rpt');

    where m:\daily\editlist.rpt is the report name

    I think the real question is how do we pass parameters into a Crystal Report from Navision.

    NOT - we don't want to use Hyperlink!

    I still haven't found the time to try it out.

    It seems to me that if you create Parameter fields(Variables) in Crystal and assign them to the fields in the Select Export, then on running the report - the user will be asked to fill in code, texts, dates or whatever.

    It's not rocket science. What's the real time savings here?

    I guess if you had a customer report and while on the customer card you click a button and the report is run for THAT customer - sounds great!! But using shell or even better hyperlink & parameter fields all the user has to do it type in the customer #.
  • rj5570rj5570 Member Posts: 157
    I am able to pull a crystal report open via navision as suggested in this thread, but my question is, how do you allow the user to use a parameter field.

    I am using crystal viewer to open the reports, but it will only let you pull saved data.

    does anyone have any suggestions on how to view crystal reports that allows the user to set their own parameters?
    - So it Goes.
  • SavatageSavatage Member Posts: 7,142
    edited 2008-03-20
    Does the report have parameter fields instead of set values that need to be filled when the report runs. If so the "Enter Parameter" Dialog box will appear when you try to execute the report so the user can enter their own values. Else you can easily create them and replace the set value with the variable. And since you can make an unlimited amount of reports you can make many similar versions of the same reports with tweaks here & there.

    Just an update: I found a better way
    http://www.mibuso.com/forum/viewtopic.php?t=23298

    If you need help with Creating Parameter fields in Crystal let me know.
  • vyankuvyanku Member Posts: 791
    we are also trying to open the crystal report from navision.
    we also get the same problem of data type.
    We arr suscessfully run the crystal report 8.5 from navision as it have ocx control support.
    From crystalreport 9 to 2008 there is no ocx control for it.

    crystal report above 9 to 2008 can be open through .net but not opened in navision.
  • rj5570rj5570 Member Posts: 157
    ok, maybe i didn't describe my problem correctly :)

    I know how to do parameters, its that when you are using crystal viewer, it wont let you use the parameter. I want to let users input parameters, but i dont want to install crystal reports on all their machines, cause i dont want them to have access to the editor, i just want them to use the report and be able to select date ranges.

    make more sense?
    - So it Goes.
  • NobodyNobody Member Posts: 93
    This out of left field but, years back I worked with Dynamics - SL and their standard reporting engine was Cyrstal Reports and when you installed the SL client you also needed to install a Cyrstal "run-time" engine (like CRPE32.DLL and CRPEHLPR.DLL) which allowed you to run the reports without giving you access to the editor. I do not even know if Crystal still has a "run-time" engine. :-)
  • SavatageSavatage Member Posts: 7,142
    I never got as secure as you're trying to do.

    Everyone has Crystal Installed on teir machines. I simply click File->Report Options->Read Only - to stop any modifing of reports.

    I know that if they play around with crystal enough they might find that checkbox. So it's not 100 effective but nobody's found it yet 8) and I'm not really worried if they did. I have copys of all the reports in case someone messes 1 up.

    I see a bunch of automation & ocx controls but I never needed to play with them. If someone would post how to just open 1 with ocx or dll I'd like to see that too.

    I think I went the route of the Executing table
    http://www.mibuso.com/forum/viewtopic.php?t=23298
    was that don't you need to use up a Nav report to execute a CR report.

    Since we have only 100 I didn't want to use any just to access a crystal report.
  • rodbernardorodbernardo Member Posts: 34
    Hello there,

    Does anyone have solution for this?

    Calling Crystal in Navision with passing parameters?

    Can anybody share the coding?

    Appreciate it.


    Rodel
    Australia
    Rodel Bernardo
    Pressure is an opportunity.
  • xtinextine Member Posts: 3
    yes me too.
    i need it so bad.
    THanks in advance
  • ecokeyecokey Member Posts: 5
    Hello,

    To start the report from RTC or Classic is not a big problem. The problem is to pass parameters to that report.

    So , i found/made the solution :

    I made an program that will pass the parameters to report. From NAV i execute the program with parameters ... then everything works like a charm.


    Here is the steps to make it done :

    1. Download this application : https://rapidshare.com/files/154355060/report.zip

    2. copy the report.exe from that zip to Classic and RTC folder
    Ex:
    C:\Program Files\Microsoft Dynamics NAV\60\RoleTailored Client
    and C:\Program Files\Microsoft Dynamics NAV\60\Classic
    This have to be done on every client.
    3. Open report.exe and set the path where the Crystal reports files are located (i recommend a network path). Then close the application report.exe
    4. NAV report setup :
    Create a new report.

    Set these Globals :
    Name / Data Type / Subtype / Length
    Vbs / OCX / ScryptControl Object /
    code1 / text / / 250
    tctCR / text / / 30
    params/ text / / 250


    Select the DataItem ( Ex: Sales Invoice Header - for a invoice)

    The code
    Sales Invoice Header - OnAfterGetRecord()
    //      params like : reportname parm1 param2 param3 
    //      use espace between params - reportname is allways the first param
    
            params := 'facture.rpt '+ "Sales Invoice Header"."No.";
    
     // --> execute script - do not modify
            Vbs.Language := 'VBScript';
            txtCR := '';
            txtCR[1] := 13;
            code1 := code1 + 'sub OpenFile()' + txtCR;
            code1 := code1 + 'dim objShell' + txtCR;
            code1 := code1 + 'Set objShell = CreateObject("Wscript.Shell")' + txtCR;
            code1 := code1 + 'strArgument = "report.exe " & chr(34) & _' + txtCR;
            code1 := code1 + '"'+params+'" & chr(34)' + txtCR;
            code1 := code1 + 'objShell.Run strArgument' + txtCR;
            code1 := code1 + 'set objShell = Nothing' + txtCR;
            code1 := code1 + 'End Sub'+ txtCR;
            Vbs.AddCode(code1);
            Vbs.ExecuteStatement('OpenFile()'+ txtCR );
     // <-- execute script - do not modify
    

    Hope that helps.
  • ChowdaryChowdary Member Posts: 148
    3. Open report.exe and set the path where the Crystal reports files are located (i recommend a network path). Then close the application report.exe
    Hi,
    I couldn't open report.exe file. I'm getting the attached screen.
    If I say No nothing happening, If I say Yes it's taking me to Visual Studio.

    Please advise!

    Thanks in advance
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    Chowdary wrote:
    3. Open report.exe and set the path where the Crystal reports files are located (i recommend a network path). Then close the application report.exe
    Hi,
    I couldn't open report.exe file. I'm getting the attached screen.
    If I say No nothing happening, If I say Yes it's taking me to Visual Studio.

    Please advise!

    Thanks in advance

    Solved
    Just follow the download available here in this link
    http://mibuso.com/dlinfo.asp?FileID=1415
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    Hi ecokey

    can you please explain a bit more the following:
    params like : reportname parm1 param2 param3
    // use espace between params - reportname is allways the first param

    params := 'facture.rpt '+ "Sales Invoice Header"."No.";
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    Savatage wrote:
    You could always use Shell to :lol:

    SHELL('C:\Program Files\Crystal Decisions\Crystal Reports 9\crw32.exe m:\daily\EditList.rpt');

    where m:\daily\editlist.rpt is the report name

    I think the real question is how do we pass parameters into a Crystal Report from Navision.

    NOT - we don't want to use Hyperlink!

    I still haven't found the time to try it out.

    It seems to me that if you create Parameter fields(Variables) in Crystal and assign them to the fields in the Select Export, then on running the report - the user will be asked to fill in code, texts, dates or whatever.

    It's not rocket science. What's the real time savings here?

    I guess if you had a customer report and while on the customer card you click a button and the report is run for THAT customer - sounds great!! But using shell or even better hyperlink & parameter fields all the user has to do it type in the customer #.
    Hello Harry

    I am trying to use Crystal Reports in Navision. Just came here while searching the forum
    can you please tell me how to use SHELL?
    I am trying like this with no luck
    SHELL('C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise I 4.0\win32_x86\crw32.exe C:\Report1.rpt');
    and getting attached error message

    Thanks in advance
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    Chowdary wrote:
    Savatage wrote:
    You could always use Shell to :lol:

    SHELL('C:\Program Files\Crystal Decisions\Crystal Reports 9\crw32.exe m:\daily\EditList.rpt');

    where m:\daily\editlist.rpt is the report name

    I think the real question is how do we pass parameters into a Crystal Report from Navision.

    NOT - we don't want to use Hyperlink!

    I still haven't found the time to try it out.

    It seems to me that if you create Parameter fields(Variables) in Crystal and assign them to the fields in the Select Export, then on running the report - the user will be asked to fill in code, texts, dates or whatever.

    It's not rocket science. What's the real time savings here?

    I guess if you had a customer report and while on the customer card you click a button and the report is run for THAT customer - sounds great!! But using shell or even better hyperlink & parameter fields all the user has to do it type in the customer #.
    Hello Harry

    I am trying to use Crystal Reports in Navision. Just came here while searching the forum
    can you please tell me how to use SHELL?
    I am trying like this with no luck
    SHELL('C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise I 4.0\win32_x86\crw32.exe C:\Report1.rpt');
    and getting attached error message

    Thanks in advance
    Okay SHELL working finally :thumbsup:

    But the main thing is to send parameters to Crystal Reports.
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    Hi All

    when I am trying the following code, am getting this error:
    An exception was raised in method Executestatement. The OLE Control ot Automation server has returned error (HRESULT) -2147352567

    I have been to other post and found COMDLG32.OCX was missing. I have registered it with custom controls with same error coming up ](*,)

    I spend lot of time on this issue to send parameters to crystal reports from Navision.
    can some one please help me out ?

    Thanks
    Sales Invoice Header - OnAfterGetRecord()
    params := 'Sales Invoice sample.rpt '+ "Sales Invoice Header"."No.";

    vbs.Language := 'VBScript';
    txtcr := '';
    txtcr[1] := 13;
    code1 := code1 + 'sub OpenFile()' + txtcr;
    code1 := code1 + 'dim objShell' + txtcr;
    code1 := code1 + 'Set objShell = CreateObject("Wscript.Shell")' + txtcr;
    code1 := code1 + 'strArgument = "report.exe " & chr(34) & _' + txtcr;
    code1 := code1 + '"'+params+'" & chr(34)' + txtcr;
    code1 := code1 + 'objShell.Run strArgument' + txtcr;
    code1 := code1 + 'set objShell = Nothing' + txtcr;
    code1 := code1 + 'End Sub'+ txtcr;
    vbs.AddCode(code1);
    vbs.ExecuteStatement('OpenFile()'+ txtcr );
    Pleasure in the job puts perfection in the work
Sign In or Register to comment.