cancel
Showing results for 
Search instead for 
Did you mean: 

Report field fixed widths?

Former Member
0 Kudos

My company has purchased Crystal Reports 2008 and I'm in the process of determining if the product will do everything we need and not become a maintenance nitemare.

We would like to setup some standard report headings to be used in all reports. I've setup on already as a SUBREPORT and it works fine. We pass optional parameters that may be blank.

We have several questions:

1) ...

2) ...

3) ...

4) Standard Report... Creating the report is difficult with guessing the width to define to the field. Is there a way that the report can know and display the exact size of the field being used? A fixed field defininiton of some sort would make it MUCH easier in the layout of the report.

5) ...

6) ...

This is question 4 from a larger post to make it easier for responses.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Tim,

Fixed length fields can be created using Crystal Formula fields.

You can use this formula to create a fixed width field.

You will need to substitute {Customer.Customer Name} with the name of your database field:

// Start Formula

// specify the desired length of the field in characters (this example uses 20)

numbervar requiredlength:= 20; // You can calculate the maximum length of the field {Customer.Customer Name} and place it in requiredlength.

// Get the current length of the database field.

numbervar currentlength:= length({Customer.Customer Name});

// Check the length of the database field compared to the required length

if requiredlength < currentlength then

// truncate fields which are longer than the required length. Put " 1 to requiredlength " in a square bracket.

{Customer.Customer Name} [1 to requiredlength]

else

// pad the field length with underscore characters (_)

// for readibility and testing, any added spaces are denoted using underscore characters (_)

{Customer.Customer Name} + replicatestring("_", requiredlength-currentlength)

// End Formula

Insert the above formula on the report instead of the database field.

For readability, any added spaces are denoted using underscore characters (_). If you wish to use blank spaces instead, replace the last line of code in the formula with the following:

{Customer.Customer Name} + replicatestring(" ", requiredlength-currentlength)

NOTE:

If the database field length is greater than the required fixed length, then the resulting field will be truncated. For example, if the required fixed length is 5, then the string 'Crystal' will be returned as 'Cryst'

In this scenario, you can calculate the maximum length of the field {Customer.Customer Name} and place it in requiredlength

Hope this helps!!

Regards,

Alpana

Former Member
0 Kudos

I'm new to this....but is this just to ensure that the data in the file has a fixed lenght?

Maybe I was not clear...but I was interested in the process of adding fields to the report. It seems to add the field and not be the size of the defined field. Many times in placing the fields on the report and then running it....the fields seem to overlap. It would be nice if adding several 5 char fields that they all displayed as 5 char wide so that placement could be precise.

If your process takes care of both of these issues then that is great.

Thanks,

Tim

Former Member
0 Kudos

Tim,

I think it's more about how the field is defined in the db,

than the display value. If it's defined as 30 chr, but only

contains "abc", then you'll probably get a 30 chr wide field.

On the other hand, if a field is 250 chr long, it's not going to be anywhere near that wide

when dragged onto the report.

Hope this helps,

The Panda

Former Member
0 Kudos

Wow, that's definitely doing things the haard way.

left({table.field}+space(20),20) will give you a fixed length 20 character field.

I've set this up as a function so I just pass it the field and the length.

Former Member
0 Kudos

pandabear,

This is what I don't like. I'd like to see it placed on the report as the actual size and then allow me to make it smaller. Although a 250 char field would be nice to be smaller, but maybe let me know that. I'd like to see the fields in their size so that I don't have to go back and forth reformatting the report so the data can fit. This wastes too much time.

Thanks,

Tim

Former Member
0 Kudos

Charliy Nash,

I assume this is done after the fields are already on the report? If so, this would be an excellent option to atleast make sure the data does not extend past a point (which it has done in some testing), but would not assist in the placement or alignment of the fields on the report.

Thanks,

Tim

Former Member
0 Kudos

My method is for creating a field that is exactly a set length, you then append it to other fields. This is for applications where you have to create a fixed-length text file to upload to some other system. I wasn't quite sure if that was what your intent was.

You can do them all in one big formula, but for clarity, I prefer to do the pieces in individual formulas, then have one formula for the detail line that just concatenates all the other peices in the right ordr.

Answers (0)