Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
JWiseman
Active Contributor
0 Kudos

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.

 

😎 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.

3 Comments