locked
Crystal Report file location

    Question

  • Hi,

    I am using VS2008 with crystal and trying to automatically create pdf reports. Previously this was done with VB6 and I am now converting to VB.Net. The problem I am having is, when the report is loaded a copy is created and put into a temp directory and the filename contains a GUID. We have over 500 existing reports and they use the "Filename" parameter within Crystal to display the path and filename in the footer. We now have a long path and filename that no longer formats onto the page. We need to display the original path and filename.

    Is there some way to get .Net to load the report from the original location instead of copying to the temp directory.

    I have tried:

    crReport.Load(myReport, OpenReportMethod.OpenReportByDefault)

    and

    crReport.Load(myReport, OpenReportMethod.OpenReportByTempCopy)

    Both methods have the same result

    Thanks,
    Kevin

    Tuesday, April 19, 2011 6:02 AM

Answers

  • Hi Kevin,

    I talked to a resource here for .NET and he said this was actually an issue and was fixed in Fix Pack 2.4 and above. The fix is we cache the location and name before we open/load the report from the \temp folder. So now I'm thinking possibly your patch install was not updated correctly. I had this happen to me pre SP 2 where CR was not DEP aware on Windows XP, DEP was blocking the updates from happening and it never reported any errors on the install. As of SP we now use the VS 2005 compiler so it's DEP aware now.

    Go into \windows\assemblies folder and find the CR files and check the version of CrystalDecisions.CrystalReports.Engine.dll. It should be at least 12.2.x.x or even better get to SP 3 and FP 3.5, same as me which is version 12.3.2004.895

    FP 3.5 is here: https://smpdl.sap-ag.de/~sapidp/012002523100006341722011E/cr2008fp35.exe

    Full SP 3, requires and uninstall so make sure you have your keycode available is: https://smpdl.sap-ag.de/~sapidp/012002523100009989492010E/cr2008_sp3_fullbuild.zip

    Or Incremental, upgrade from SP 2: https://smpdl.sap-ag.de/~sapidp/012002523100007123572010E/cr2008_sp3.exe

    Then test again, may need a re-boot first.

    If for some reason this still is not working can you post this on the SAP .NET forum for me: http://forums.sdn.sap.com/forum.jspa?forumID=313? I'm a moderator on that forum and I can get your e-mail address and I'll contact you directly.

    Thanks again

    Don


    Don Williams
    • Marked as answer by Syn01 Friday, May 13, 2011 11:01 AM
    Wednesday, May 11, 2011 3:58 PM

All replies

  • Hello,

    What is the name of the parameter you are using? In CR for VS 2008 there is a Special field called "File Name and Path" and it uses the original name and not the temp copy name. TO be able to use that field though you may have to manually update each report, CR Basic does not have the ability to use RCAPI ( Report Creation ) you need to use RAS ( Report Application Server ) to be able to modify/add report objects. You may be able to replace your existing object, or parameter I assume, with the new Special function value.

    Please continue to use the OpenReportByTempCopy method or you may have issue if more than one user tries to use the same report.

    Or....

    You can use something like this ( C# ):

    String ReportName = myReport.Name.ToString();

    Should return the original location and not the temp report name and location.

    Thank you

    Don


    Don Williams
    Tuesday, April 19, 2011 1:34 PM
  • Hi Don,

    Thanks for the quick reply. The reports have been created in Crystal Reports Developer Edition (versions 8.5 through to 2008) and the Special Field "File Path and Name" was used. The path that is displayed in the report when it is run through my application is the temp file path. I do not need to be concerned about multiple people accessing the report as I have written an automated process and it is not possible for that situation to occur.

    Your second suggestion will give me the path within the application I am writing. That will still mean I have to pass the path to my report as a parameter. As I said I have about 500 reports and I really do not want to edit each one. The system is currently working OK under VB6 with no problems but I need to add extra functionality to the application so thought it would be good to upgrade to VB.Net.

    So given that there is no problem for me with multiple access to reports is it possible for VS 2008 to open the report in its original location. The boss will go nuts if I tell him all of the reports need to be modified...

    Thanks for your help,
    Kevin

    Tuesday, April 19, 2011 2:48 PM
  • Hi Kevin,

    Can you paste in your code how you are open and getting the report name and location? How are you populating "myReport", common file dialog box or hard coded?

    No, it's not possible, CR by default will make a local copy to the temp folder. One of the properties should load the original location

    And which assemblies are you using?

    Thank you

    Don


    Don Williams
    Tuesday, April 19, 2011 3:06 PM
  • Hi Don,

    Below is the piece of code I use to create the output file. Users select what report they want from an AS/400. The AS/400 creates a control file "notcry.txt" that is read by the application which automatically prints/email/archive the selected crystal report(s). There is no viewing option for the users. The output file is just automatically generated.

    I fail to see how the report will know where the original location is. If VB.Net creates a temp copy of the report and then loads the data from the temp report how can the temp report know about the original file location.

    I am not sure what you mean about: "And which assemblies are you using?"

     

    Thanks,
    Kevin

     

    Dim ReportExportType As ExportFormatType
    Dim crExportOptions As ExportOptions
    Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions
    Dim crReport As New ReportDocument
    Dim fleCrystalReportLcl as String

    'Construct report name
    fleCrystalReportLcl = MyData.LocalDir & "\reports\" & oNotcry.Report

    'Set the export type
     Select Case oNotcry.ReportExportType.ToUpper
          Case "CSV"
              ReportExportType = ExportFormatType.CharacterSeparatedValues
              FileExtension = ".CSV"
          Case "XL2"
              ReportExportType = ExportFormatType.ExcelRecord
              FileExtension = ".XLS"
          Case "XLS"
              ReportExportType = ExportFormatType.Excel
              FileExtension = ".XLS"
          Case "DOC"
              ReportExportType = ExportFormatType.WordForWindows
              FileExtension = ".DOC"
         Case "TXT"
              ReportExportType = ExportFormatType.Text
              FileExtension = ".TXT"
         Case "RTF"
              ReportExportType = ExportFormatType.RichText
              FileExtension = ".RTF"
         Case Else
              ReportExportType = ExportFormatType.PortableDocFormat
              FileExtension = ".PDF"
    End Select

    'Load the report
    crReport.Load(fleCrystalReportLcl, OpenReportMethod.OpenReportByTempCopy)

    'Refresh Data
    crReport.Refresh()

    'Set output file destination
    crDiskFileDestinationOptions.DiskFileName = MyData.LocalDir & "\Temp\" & oNotcry.Filename & FileExtension

    'Set the export options               
    crExportOptions = crReport.ExportOptions
                  
    With crExportOptions
        .ExportDestinationOptions = crDiskFileDestinationOptions
        .ExportDestinationType = ExportDestinationType.DiskFile
        .ExportFormatType = ReportExportType
    End With

    crReport.Export()


    Wednesday, April 20, 2011 12:31 AM
  • Hi Kevin,

    When you specify the report to open the engine creates a temp file so the original is not locked. Internally it then references the temp copy but the original file name is used internally as well. I always use the full version so I have RAS available and I discovered when using the Report.Engine the report name is always empty for the main report. Subreports do have names and the name can be retrieved from the Subreport object.

    Your oNotcry.Report should be the name of the original report name so the export method should also be using that name as specified in your export method.

     

    If it doesn't then the following can be used:

    'Load the report
    crReport.Load(fleCrystalReportLcl, OpenReportMethod.OpenReportByTempCopy)

    Add this line:

    crReport.FileName.ToString()

    should return the full name including the path where it was loaded from. Using string functions you can strip off the path to get the name.

    Using RAS you can get the name this way but RAS is not available in CR Basic, requires you to upgrade to full CR 2008.

    crReport.ReportClientDocument.DisplayName.ToString()

    Thank you

    Don


    Don Williams
    Wednesday, April 20, 2011 2:30 PM
  • Hi Don,

    I have the CR 2008 Developer Edition installed on the same computer as the VS 2008 where I am writing the application. RAS is available but I have not addded any references to it as I am not using those functions.

    I included the line: Dim fred as string = crReport.FileName.ToString as you suggested after the load and received the correct report name and path:
    rassdk://C:\Notice\reports\DEBITN001.rpt

    When I use the Special Field "File Path and Name" within a report I get:
    C:\DOCUME~1\Temp\LOCALS~1\Temp\DEBITN001 {D25DAF64-AF15-4D45-AF7B-48D88F2744A6}.rpt

    hmmm... To eliminate the possibility of problems with the reports. I created a new report (mytest.rpt) with CR 2008 on my local computer and only placed the "File Path and Name" field in the footer. Nothing else was added to the report. This is what printed:
    C:\DOCUME~1\Temp\LOCALS~1\Temp\mytest {32AECB2C-46E5-4C66-AB7E-DCE137A20A8B}.rpt

    I have access to the filename within my application but it is not available within the report. Am I missing something in my code? This should be a regularly used feature in CR. I find it hard to imagine it is not supported when automated using VB.Net

    Thanks,
    Kevin

    Thursday, April 21, 2011 12:04 AM
  • Hi Kevin,

    I see why now... You are an either an OEM Partner and using Crystal Reports Server Embedded or you are using Business Objects Enterprise using it's RAS Server to process unmanaged report.

    This line: rassdk:// tells the RAS Server to open the report on your local PC which it does from the temp folder. One option that may fix this is to copy all of your reports to the RAS Server PC under the location specified in the Report Location in the CCM. Which can be changed from the default.

    Log a case in Service Market Place on SAP site and a Rep can work through this with you. Be sure to select the DEV_NET queue.

    If you are an OEM Partner then please log a case, if you are using BOE and you don't have a Support Contract then please log your issue in the BOE SDK Forum.

    Thank you

    Don

     


    Don Williams
    Thursday, April 21, 2011 3:47 AM
  • Hi Don,

    We are neither an OEM partner or using Crystal Reports Server Embedded or using Business Objects Enterprise. As I said previously "I have the CR 2008 Developer Edition installed on the same computer as the VS 2008 where I am writing the application."

    The import lines on my application include:
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared

    The crReport variable is created by:
    Dim crReport As New ReportDocument

    Do you have any other suggestions?

    Happy Easter :o)

     

    Thanks,
    Kevin

    Friday, April 22, 2011 11:51 PM
  • Hi Kevin,

    OK that is very strange. The line:

    "I included the line: Dim fred as string = crReport.FileName.ToString as you suggested after the load and received the correct report name and path:
    rassdk://C:\Notice\reports\DEBITN001.rpt"

    rassdk:// is the open command you use when using a RAS Server and not the inProc RAS that comes with full versions of CR.

    Using the Engine after the report is open I use:

    rpt.ReportClientDocument.DisplayName.ToString();

    and in debug mode I see:

    "C:\\Reports\\en\\Reports\\General Business\\World Sales Report.rpt"

    What is defined in your control text file as the report name "notcry.txt"?

    Is it possible for you to share your test app, report and text file project so I can test and see what is happening?

    Very strange....

    Don


    Don Williams
    Saturday, April 23, 2011 5:38 AM
  • Hi Syn01, any progress with SAPDon's suggestions?
    I temporarily mark his last reply as answer, you can unmark if you doesn't think it to be.
    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 25, 2011 8:02 AM
    Moderator
  • Hi Don,

    Sorry for the late reply I got caught up in the Easter break. :)

    I have constructed an extract of my application that can be used to test my problem. Just create a new project with a textbox and button control. I also created a simple Crystal Report with just the "Special Field" "File Path and Name" inserted into the footer.

    You also need to add the Crystal reports references Engine and Shared to the project.

    Once the program is running, type the path and filename of the simple Crystal Report you created into the textbox. Click the button and a pdf version of the report will be created in the same directory as the crystal report.

    In the Crystal Report application the footer displays the correct path and filename. After the VB.Net program runs the pdf output file has the temp path and filename.

    My program...

    Option Strict On
    Imports System.IO
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared

    Public Class Form1

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim crReportOrientation As PaperOrientation
            Dim crReportExportType As ExportFormatType
            Dim crExportOptions As ExportOptions
            Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

            Dim FileExtension As String
            Dim fleTempOutput As String

            Dim crReport As New ReportDocument

            'Check if Crystal Report
            If Not TextBox1.Text.ToUpper.EndsWith(".RPT") Then
                MsgBox("Error - File needs to be a crystal report")
            Else
                  'Check if Report exists
                If Not File.Exists(TextBox1.Text) Then
                    MsgBox("Report does not exist: " & TextBox1.Text)
                    Exit Sub
                End If


                'Set the export type
                crReportExportType = ExportFormatType.PortableDocFormat
                FileExtension = ".PDF"

                crReportOrientation = PaperOrientation.Portrait

                'Load Report
                Try
                    crReport.Load(TextBox1.Text, OpenReportMethod.OpenReportByTempCopy)

                Catch ex As Exception
                    MsgBox("Error loading Crystal Report" & vbNewLine & ex.Message.ToString)
                    Exit Sub
                End Try

                crReport.Refresh()

                fleTempOutput = TextBox1.Text.Substring(0, TextBox1.TextLength - 4) & FileExtension
                crReport.PrintOptions.PaperOrientation = crReportOrientation

                crDiskFileDestinationOptions.DiskFileName = fleTempOutput
                crExportOptions = crReport.ExportOptions

                With crExportOptions
                    .ExportDestinationOptions = crDiskFileDestinationOptions
                    .ExportDestinationType = ExportDestinationType.DiskFile
                    .ExportFormatType = crReportExportType
                End With

                Try
                    crReport.Export()
                    MsgBox("Exported report to: " & fleTempOutput)
                Catch ex As Exception
                    MsgBox("Error exporting Report")
                    MsgBox(ex.Message.ToString)
                End Try
            End If

        End Sub
    End Class

    Monday, May 02, 2011 6:55 AM
  • Hi Syn01,

    Very strange. I still get the original location: C:\Reports\World Sales Report.rpt ( copied from the PDF output file )

    What OS is this app running on?

    I'm using Windows 7 64 bit.

    Thanks

    Don


    Don Williams
    Monday, May 02, 2011 3:20 PM
  • Hi Don,

    I am using Windows XP.

    Did you generate the PDF output file from the sample code I supplied?

    From within Crystal Reports 2008 and PDF's exported from within Crystal the file location\name is OK. The problem occurs when the PDF is generated by my application.

    Thanks,
    Kevin

    Tuesday, May 03, 2011 4:53 AM
  • Hi Kevin,

    From your code, I just changed the report location and export destination to c:\reports where I also load the sample report World Sales Report from which I also modified to include the Path and Name Special function.

    Only other thing I can think of is the Assembly versions you are using, mine are:

    C:\Program Files (x86)\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.CrystalReports.Engine.dll

    C:\Program Files (x86)\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.Shared.dll

    C:\Program Files (x86)\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.Windows.Forms.dll

    All versions are 12.0.2000.0 ( CR 2008 SP 3 FP 3.4 )

    Target Framework is 3.5 and x86 CPU....

    Thank you

    Don


    Don Williams
    Tuesday, May 03, 2011 2:12 PM
  • Hi Don,

    Still no luck. Though I almost had a melt down. My application was using different assemblies to you. I deleted the old references and added the same as you but then my application kept failing when I tried to export or print (Error was Failure to log into the database). All is better now I had to do a reboot. I was feeling very anxious for a while...

    However my initial problem still persists, I am now using the same assemblies with the exception of CrystalDecxisions.Windoes.Forms.Dll which I do not use. I am using ver 12.0.2000.0 Framework is 3.5

     

    I am stumped...

    Thanks,

    Kevin

    Wednesday, May 11, 2011 6:08 AM
  • Hi Kevin,

    I talked to a resource here for .NET and he said this was actually an issue and was fixed in Fix Pack 2.4 and above. The fix is we cache the location and name before we open/load the report from the \temp folder. So now I'm thinking possibly your patch install was not updated correctly. I had this happen to me pre SP 2 where CR was not DEP aware on Windows XP, DEP was blocking the updates from happening and it never reported any errors on the install. As of SP we now use the VS 2005 compiler so it's DEP aware now.

    Go into \windows\assemblies folder and find the CR files and check the version of CrystalDecisions.CrystalReports.Engine.dll. It should be at least 12.2.x.x or even better get to SP 3 and FP 3.5, same as me which is version 12.3.2004.895

    FP 3.5 is here: https://smpdl.sap-ag.de/~sapidp/012002523100006341722011E/cr2008fp35.exe

    Full SP 3, requires and uninstall so make sure you have your keycode available is: https://smpdl.sap-ag.de/~sapidp/012002523100009989492010E/cr2008_sp3_fullbuild.zip

    Or Incremental, upgrade from SP 2: https://smpdl.sap-ag.de/~sapidp/012002523100007123572010E/cr2008_sp3.exe

    Then test again, may need a re-boot first.

    If for some reason this still is not working can you post this on the SAP .NET forum for me: http://forums.sdn.sap.com/forum.jspa?forumID=313? I'm a moderator on that forum and I can get your e-mail address and I'll contact you directly.

    Thanks again

    Don


    Don Williams
    • Marked as answer by Syn01 Friday, May 13, 2011 11:01 AM
    Wednesday, May 11, 2011 3:58 PM
  • Hi Don,

    I have looked at the assemblies and I have 3 versions of CrystalDecisions.CrystalReports.Engine.dll
    10.5.3700.0
    12.0.1100.0
    12.0.2000.0

    What is the best way to manage this. I have multiple versions of most of the CR assemblies. :(

    I have started the download of the files you have suggested but they are very large and will take a long time to download.

    Is the best approach to uninstall CR2008 and install from the file cr2008_sp3_fullbuild.zip

    If I uninstall CR2008 will the assemblies be removed as well or do they need to be manually uninstalled.

    Does cr2008fp35.exe need to be installed after the r2008_sp3_fullbuild.zip installation.

    Thanks for your help
    Kevin

    Thursday, May 12, 2011 7:21 AM
  • Hi Kevin,

    10.5 is the version installed with VS 2008, 12.0.1100 is framework 1.1, 12,0,2000 is framework 2 and installed with CR 2008. what I need to know is the actual version of the dll's not the GAC version. Those version never change, easier for updating CR runtime.

    So I still don't know what is the easiest path for you to upgrade but it is best to uninstall CR completely and then instal a full build and then FP 3.5. Make sure you keep your keycode handy, I won't be able to get a new one for you nor will the Customer Services people at SAP.

    Thanks

    Don


    Don Williams
    • Marked as answer by Syn01 Friday, May 13, 2011 11:00 AM
    • Unmarked as answer by Syn01 Friday, May 13, 2011 11:01 AM
    Thursday, May 12, 2011 1:24 PM
  • Hi Don,

    Great news, it worked. Thanks for your patience and help. There is an issue downloading the files however. It took about 3-4 attempts to download each of the files. But it worked....   :o)

    Warm Regards,
    Kevin

    Friday, May 13, 2011 11:06 AM