Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export crystal report to fixed length format 3

Status
Not open for further replies.

tatochka

Programmer
May 3, 2001
49
0
0
US
I need to export crystal report to fixed length format. None of the suggested formats in Crystal exporting is doing it. Does anybody have an idea?
 
In order to export in a fixed width format, you need to ensure that every field has the exact same number of characters. You can control this through the use of the Replicate String function.

For a specific field, create a formula similar to the following (sample pulled from BOBJ KB Article c2005609):
Code:
// Start Formula 
// Specify the desired length of the field in characters (this example uses 20) 
numbervar requiredlength:= 20; 

// Get the current length of the database field. 
numbervar currentlength:= length({Customer.Customer Name}); 

// Check the length of the database field compared to the required length 
if requiredlength < currentlength then 
// truncate fields which are longer than the required length 
{Customer.Customer Name}[1 to requiredlength] 
else 
// pad the field length with underscore characters (_) 
// for readibility and testing, any added spaces are denoted using underscore characters (_) 
{Customer.Customer Name} + replicatestring("_", requiredlength-currentlength) 

// End Formula
When you're done with your testing, simply replace the underscore in the formula with a space. Also, I'd recommend that you use a fixed width font, such as Courier 10 or Lucide Console 10 for your entire report. When you export to text, I'd recommend 12 characters per inch, if you are prompted. Lastly, depending on how many fields are in your report and the length of those fields, it may be a good idea to simply concatenate all of the fields into a single formula. Barring that, make sure that you don't have any spaces between the separate fields. Using a fixed width font will allow you to size the fields exactly so that you can place them precisely on the page.


~Kurt
 
you need to ensure that every field has the exact same number of characters
I realized that this could be misinterpreted when I read it again. What I mean to say is that you need to establish a fixed number of characters for each individual field.


In order to establish the fixed number of characters within a field, you either need to truncate or pad the field.


~Kurt
 
Thank you very much Kurt. I got it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top