5.2. Trunking

Many customers who are not aware of the Crystal Reports history and limitations are often perplexed about the trunking method described in the manual. It is worth the time to reiterate the rationale behind the “trunking” thing.

Crystal Reports has a long development history tracing back more than a decade ago. At that time, people in the Crystal Reports seemed to believe that a string won't exceed 254 characters in length. The later versions, for a variety of reasons, keep this legacy. As a result, a formula field can not store more than 254 characters. Extra characters are truncated if you pass a string longer than the limit. Even worse, this limit applies not only to formula fields, but virtually to all fields.

Obviously this limit became impractical as time went by. Crystal Reports reacted by making improvements little by little. First a text field (sometimes referred as memo field) which holds up to 64K characters was added. The Database fields can also hold more characters. Unfortunately, until version 9.0, all string variables still have a such limit, and even at version 9, all formula fields still have the limit. As you may know, there are large number of Crystal Reports 8.5 deployment existing today.

We created the “trunking” solution to get around the limitation. We should admit that this is not an elegant solution. At the first glance it looks more like a hack. However we are not able to use string variable to store the result piece by piece, can we simply assign the encoder to a formula variable. For the maximum compatibility, the encoder result (barcode string) must be divided into individual chunks (trunks), and put into a text object (memo field) at the latter time. A trunk is simply a container holding a chunk of encoding results. Each trunk holds up to 200 characters.

Before we go into the full details, you need to understand that the DataMatrix encoder must encode the input as a whole. You can not encode input piece by piece and concatenate the results together. It does not work that way. For example, suppose you need to encode customer's contact information into a single DataMatrix barcode. The contact information are retrieved from multiple database fields such as address, city, postal code and country. You can not simply write formulate fields like the one below:

barcode_trunk1 = MoroviaDataMatrixEncode($(address))
barcode_turnk2 = MoroviaDataMatrixEncode($(city))
...

The trunk fields are used to divide encoding results into chunks that within the Crystal Reports length limit. They are not intended to divide the input.