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!

CR10 - Character Field Lengths

Status
Not open for further replies.

forgothow

MIS
Apr 19, 2005
3
US
Any help would be greatly appreciated in assisting me with CR10 - character field lengths.

After pulling the data from the oracle database I am unable to format the database fields correctly in CR10 to export it to a .txt file.

Example: Characters 1-9 need to be a social security number, characters 10-25 last name, 26-41 first name, etc...

Thanks!
 
Hi,
What size are the fields in the Database?

Depending on that, you can create a formula to concatenate the 3 fields into 1
@exportname
{ssn}+{lastname}+{firstname}

You may ( and probably will) need to either trim or pad each field to insure the specific length.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
The simplest means is to use the replicatestringfunctoin, and of course converting all non-strings to strings.

An example might be:

whileprintingrecords;

numbervar MyField1 := 123456789; //use a numeric ssn field here
stringvar MyField2 := "Smith";
Stringvar Output:="";
Output:=replicatestring(" ",9-len(totext(MyField1,0,"")))&totext(MyField1,0,"");
// string field example:
Output:=Output+replicatestring(" ",16-len(trim(MyField2)))& trim(MyField2);
Output

Note that we are building a single string with the proper length as determined by the length required minus the actual length as sspecified in the replicatestring function.

-k
 
Hello and Thanks -

I will give this a try. However, between several fields I need to insert static text objects.

Is Turkbear from Scrubs?

Thanks!
 
If you need static objects, just add them to the Output:=Output+"My static text";

Then continue building out the entire string.

-k
 
Dear forgothow,

Don't forget to check for nulls ....

The result of a concatenation if there are any nulls in any field being concatenated will return null for the entire formula.

You may think, ah but there can't be any nulls in my data. Just after thinking along those lines ... you will deliver your report and the user will contact you because there are blank strings and "they know it has data".

I try to design my reports with proactive error trapping. In other words, I don't want to ever have to modify a report after it has been delivered for something I could have coded to catch in the first place. :)

Regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top