Solved

Crystal Reports - trimming Strings - Need to produce a fixed length file

Posted on 2011-03-17
4
528 Views
Last Modified: 2012-05-11
Hi,

I have a fairly simple job but not sure of the syntax
I am building up a report that will produce a fixed length csv style file
so I have 17 numbered formula fields and then I put them all into an 18th formula
which goes onto the report

so the final string looks like

{@01 - User}+""+{@02 - Site}+"  "+{@03 - PONumber}+"   "+{@04 - FromLocation}+"                "+{@05 - PalletNumber}+""+{@06 - PartNumber}+""+{@07 - EANCode}+""+{@08 - Quantity}+""+{@09 - ToLocation}+""+{@10 - AOD}+"   "+{@11 - Site2}+""+{@12 - Job}+""+{@13 - InOutIndicator}+""+{@14 - Whole}+""+{@15 - Date1}+""+{@16 - Time1}+" "+{@15 - Date1}+""+{@16 - Time1}+""+{@17 - MrIddd}+"                              "


Some of the fields have a static value, some are dynamic from the database

I need to do 2 things.

1. for 08-Quantity field I need to pad the number with zeroes - ie if the qty is 25 I want it to show 00025 or if it 175 it should say 00175
2. All the fields have a minimum/maximum length so 03-PO Number could come from the database as a six digit number or a 10 character description, i need it to be always 5 characters wide

If someone could point me towards the Stringy functions I need to use

Thanks

Seb
0
Comment
Question by:sebadlington
  • 2
  • 2
4 Comments
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
Totext is the main function needed for formatting numbers.

Totext({@08 - Quantity}, "00000")

I don't understand what you want to do with your other field.

I don't see how it can be either a number or a text field. It sounds like it must be text field.
But how do you decide which bit to include and which bit to leave out?
0
 

Author Comment

by:sebadlington
Comment Utility
Thanks peter that has sorted the qty out

For the other field I basically need to trim it - it doesn't matter if i chop the end off as it's always the first 5 digits of the field that I need but it is possible that I will sometimes only get a 3 digit number through in which case I'll need to padd it out with space
so if I get  123456789 I want it to read "12345"
if I get 123  i want it to read "123  "  so 3 numbers with 2 added whitespace characters?

Basically I'm squirting this back to a customer who has a COBOL system and they cant' accept a virable length file.
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
Comment Utility
left({@03 - PONumber}+ "     ", 5)  

there are5 spaces between the  "     "
0
 

Author Closing Comment

by:sebadlington
Comment Utility
You're a legend! Thanks Peter - got the files all looking hunkdory now

Cheers

Seb
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now