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

Export Numeric Field to Text file

Status
Not open for further replies.

kpeak

IS-IT--Management
Mar 10, 2004
12
US
I am trying to export a concatenated record with 2 numeric fields at the end to a text file using the following format. The first field is 15 positions...4 decimal places and I want to display the decimal and have leading spaces to fill the field. The 2nd field is 10 positions....2 decimal places and should have leading spaces to fill the field.

{@empno_4}+" "+"1"+" "+{@ecode_subscript}+" "+ReplicateString (" ",11 - Len(ToText({prearn.curhours},0,"")))+ToText(Truncate({prearn.curhours}),0,"") +Right(ToText({prearn.curhours},4,""),4)
+" "+ReplicateString (" ",8 - Len(ToText({prearn.curamount},0,""))) + ToText(Truncate({prearn.curamount}),0,"") +Right(ToText({prearn.curamount},2,""),2)


Here is what my record looks like when exported. Note that the 2nd numeric field is not appearing at all and the first has no decimal point.

0017 1 01 40000
 
What's in {@empno_4} and {@ecode_subscript}?

Since those are the fields that you're asking about, I doubt that anyone can tell you why unless you share what's in them.

The second numeric is appearing, it's the 1.

Try describing your environment as in:

Crystal version
Database used
example data
expected output

Formulas in use:
{@empno_4} = <formula>
{@ecode_subscript} = <formula>
Display formula = <formula>

Note that if @empno_4 is a string converted from a numeric, you'll have to make sure that it has 4 decimal places, as in:

totext({table.field},4,"")

-k
 
I wasn't very clear in my first post. I am using Version 8.5, with an OLE DB supplied by my payroll software.
Here is the formula for the 2 fields I am trying to export. Both are numeric fields with 2 decimal places. curhours is a 15 pos. field and needs to export as 4 decimal places and curamount is a 10 position field with 2 decimal places.

ReplicateString (" ",11- Len(ToText({prearn.curhours},0,"")))+ToText(Truncate({prearn.curhours}),0,"") +Right(ToText({prearn.curhours},4,""),4)
+" "+ReplicateString (" ",8 - Len(ToText({prearn.curamount},0,""))) + ToText(Truncate({prearn.curamount}),0,"") +Right(ToText({prearn.curamount},2,""),2)


Here is what my record looks like when exported.
40000

Note that only curhours displays. I would like it to display with the leading spaces and show as 40.0000. Curamount should display with leading spaces and appear as 169.00 and is not appearing at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top