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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting fixed-length fields?

Status
Not open for further replies.

mperera

Technical User
Sep 7, 2001
20
0
0
US
Hi,

I am a new Crystal Reports user. I need to generate a report and export the the report so that the fields are fixed length, ie, the length of each field matches its length in the database view it is being pulled from. The resulting text file will be used as a data source file for an upload program, which is why the fields need to be fixed length, with no delimiters. The columns of fields should line up (so, they can be padded with space), and not wrap, if possible. I'm not sure which export type to choose. I've been able to export the fields as tab-delimited without wrapping, but so far, not as fixed-length fields with no wrapping. Is there a way to do this?

Thanks.
 
Hi;

I think this will work....you don't say what format your data is in but I'll suggest a couple of formula's for string and numeric

First of all I don't think you can determine the max number of characters of each datafield in the database using Crystal....but you shud know them and they can be hardcoded into each field formula, as shown below using db_fld_size.

so for string fields you would simply use:

**************** start here *************************

WhilePrintingRecords;

spaces( db_fld_size - length({strField})) + {strField}

**************** end here *************************

for numeric fields a similar formula would be used

**************** start here *************************

WhilePrintingRecords;

spaces( db_fld_size - length(totext({strField},decimal))) + totext({strField},decimal)

**************** end here *************************
where decimal = number of decimal places you want in the number.

NOTE: if the formula field is not being used in a
summary function or in a group but rather just displayed...I ALWAYS add WhilePrintingRecords to the formula... I like telling Crystal when to do things :)

now you have a bunch of text fields (if the data is Date type a similar formula could be created). Line them up on the detail line in the order that you want them.

Run the report.....

now export to "Character-separated values" "Disk file"
on the next dialog box enter a single blank space for the separator and make the delimitor "null" by removing the " from the text box.

continue...enter the name/path for your file and save the export.

VERY IMPORTANT: make sure that all headers and footers are suppressed...you ONLY want the detail line.

I think this will work

regards Jim

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top