Blogs

Jamie Wiseman

Displaying Text File Contents from a File Directory in Crystal Reports
Jamie Wiseman SAP Employee Active Contributor Gold: 1,500-2,499 points
Business Card
Company: SAP - Business Objects
Posted on Nov. 25, 2009 12:07 PM in Business Intelligence (BusinessObjects)

Subscribe.Subscribe
Print. Print
Permalink Permalink
Share

If you have a directory structure containing text files, then you can display the directory information and the text file contents in Crystal Reports.

 

 

Here's how:

 

1) first, download (and then install) the Wire Protocol (Data Direct) drivers for crystal reports from here. they are free for crystal reports customers and they are apparently faster than odbc and ole. they also have a great .txt driver that we will be using in this example.

 

2) create a new report off of the desired file structure folder using the File System Data connector in crystal reports.

 

3) in the Report > Selection Formulas > Record filter, create a selection formula similar to the syntax below.

 

 {yourdirectoryfoldername.Extension} = "txt"

 

drag any file / structure information onto this new report that you need.

 

4) outside of crystal, in your ODBC Data Source Administrator, create a new System DSN off of the CR Text ODBC Driver 5.3...this driver would be installed with the above-mentioned Data Direct drivers. the new system dsn would point to the same directory structure as the report created in step #2.  do not check "Column Names in First Line"

 

5) create another new report using the new ODBC connection created in step #4. for the data, press the Add Command and create a command with one string parameter with syntax similar to the syntax below.

 

select * from {?filename}

 

{?filename} is a new command string type parameter you create with a default value of any of the .txt files in your directory structure.

 

6) drag the field created by the command onto your report. save this report onto your desktop. 

 

7) go back to your original file structure report and go to Insert > Subreport. insert the new command based report (created in step #5) into the Details section.

 

8) for the Subreport Links, link the main report {yourdirectoryfoldername.File Name} field to the {?filename} prompt in the command based subreport.

 

9) preview the report.

 

You should now see all of the .txt file contents in the subreport where the .txt file corresponds to the file name in the main report.

Jamie Wiseman  Active Contributor Gold: 1,500-2,499 points is a Crystal Reports demo creator for SAP - Business Objects


Comment on this article
Comment on this weblog
Showing messages 1 through 3 of 3.

Titles Only Main Topics Oldest First

  • DataDirect ODBC Drivers
    2009-12-17 13:19:19 Dave Williams Business Card [Reply]

    This says it is for Crystal Reports 2008. Is a driver available for this that supports Crystal Reports v10?
    • DataDirect ODBC Drivers
      2009-12-17 13:31:46 Jamie Wiseman SAP Employee Business Card [Reply]

      hey Dave,
      there are datadirect drivers for v10 of cr available at
      https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/bobj_download/main.htm


      choose crystal reports, crystal reports 10, and "other" as the software type.


      there are different versions of these drivers for different versions of cr. not 100% sure, but i think that these started in v9 of crystal???


      please note that this process outlined in the blog was only tested in cr 2008, so it may or may not work in other versions.


Showing messages 1 through 3 of 3.