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

Crystal 8.5 fixed length text file export problem

Status
Not open for further replies.

rradelet

IS-IT--Management
Oct 28, 2003
35
CA
I have a string formula to create a fixed length export .txt
file, but the last field in the record is a variable length field. If the last field length is less than the maximum for that field the result produces a record that is less than the required record length.

I have allowed for the varying field length with the following string formula:

if
length ({db.field}) <14
Then left ({db.field},length ({db.field}))& space (14- length ({db.field}))
else
Left ({db.field},14 )

but the additional spaces don't come through in the end result txt file.

I have also tried adding a chr(13)at the end of the string.

if
length ({db.field}) <14
Then left ({db.field},length ({db.field}))& space (14- length ({db.field})) & chr(13)
else
Left ({db.field},14 ) & chr(13)


The result solves the problem of the length of the last field, but also adds the ascii character "?"at the end of the record so that the record length of the final product is now one character longer than required. This txt file is being imported into a client's accounting system, so a file with an extra character at the end of the record won't work.

Does anyone know how to get around this?
What I need to produce is a 14 character string (with following spaces if the field is less than 14):

BRIDGEWAY ST

instead of this result
BRIDGEWAY ST ?



 
Please note: my attempt to reproduce the ascii character 13
ended up being displayed as a question mark "?" when my post was displayed on this web site. Instead of the question mark, this character should be a musical note symbol.
 
Try this:

if Length({db.field}) <14 then left({db.field},length ({db.field}))&ReplicateString(" ",14-length ({db.field})) else Left ({db.field},14 )

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
dgillz:

Thanks for the reply. I tried you suggestion of adding
ReplicateString to the formula, but no luck. I still get
the same result with the record length being too short where
the length of the final field is less that 14.

Any other ideas on how to get around this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top