Solved

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

Posted on 2011-03-17
4
529 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
ID: 35155671
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
ID: 35156302
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
ID: 35157309
left({@03 - PONumber}+ "     ", 5)  

there are5 spaces between the  "     "
0
 

Author Closing Comment

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

Cheers

Seb
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

867 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

12 Experts available now in Live!

Get 1:1 Help Now