UniVerse display length vs. character length

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
msigal
Participant
Posts: 31
Joined: Tue Nov 26, 2002 3:19 pm
Location: Denver Metro

UniVerse display length vs. character length

Post by msigal »

Can someone explain to me the difference of display length vs. character length in universe? When I query a dictionary file and the output display states 20T, what does that mean? I've searched universe docs and most information points to the FMT function. T for text justification, but what's the 20? FMT states n[m] with n=decimal places and m the scale. But this doesn't apply to text. And addtional poking around only tells me that character length isn't equal to display length. I understand character length to be the actual len of the string. Len("this") = 4.

Thanks,
Myles
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Myles

I assume you are talking about dictionary items. The 20T is the same in the FMT command. It is a text format. It will try to split a column into 2 lines when it goes over 20 characters but it will try to split on a word.

Code: Select all


Col1   Col2
Line1  12345 78901234 678 
          01234

I hope this makes sense. Normally it takes the 21 character and puts it on line2 of that row.
Mamu Kim
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,

20 stands for length of the output string.
e.g
Ans =Len(FMT("1234567", "20T")) will give a value of 20

Below is from HELP in DataStage
Syntax
Fmt (string, format)

string is the string to be formatted. If string is a null value, null is returned.

format is an expression that defines how the string is to be formatted. If format is null, the Fmt function fails. For detailed syntax, see The Format Expression.

Remarks
The format expression provides a pattern for formatting the string. You can specify:

The length of the output field

A fill character to pad the field

Whether the field is right-justified or left-justified

A numerical, monetary or date format

A mask to act as a template for the field

The Format Expression
The syntax of the format expression is:

[length] [fill] justification [edit] [mask ]

Output Length
You specify the number of character positions in the output field using the length parameter. You must specify length unless you specify mask. (You can specify length and mask.)

If string is smaller than length, it is padded with fill characters.

If string is larger than length, the string is divided into fields by a text mark, CHAR(251), inserted every length characters. Each field is padded with fill characters to length.

Fill Character
You specify the fill parameter to define the fill character used to pad the output field to the size specified by length. The default fill character is a space. If you want to use a numeric character or the letters L, R, T, or Q as a fill character, you must enclose it in single quotation marks.

Justification
You specify the justification of the output using the justification parameter, which must be one of the following codes:

L Left justify and break at end of field.

R Right justify and break at end of field.

T Left justify and break on space (suitable for text fields).



----------------
Ketfos
msigal
Participant
Posts: 31
Joined: Tue Nov 26, 2002 3:19 pm
Location: Denver Metro

Post by msigal »

Kim, yes I'm talking about a dictionary file. I'm curious as to the max length of a job name in DataStage. So I issued LIST.DICT DS_JOB and see that the output format on NAME is 20T. Now, we all know that you can name a job more than 20. In some universe documentation I dug up, v9.6 BASIC guide, I often see the statement, "Calculations are based on display length rather than character length." and vice versa for the LEN() function. So, what's the max length of a job name and what's the difference between character and display length?

From what you've said Kim, it sounds like text just has some arbitrary varchar format in universe and it just specifies the split point.

Myles
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I am not sure there is a max length. In doc_tool.mdb it is set to 64 but I am sure I have seen longer. Sometimes I wish there was.

You are correct the length in DS_JOBS is arbitrary. It does not enforce the 20 character limit. It is only the column width on a report.
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Display length can be different from character length in character sets like Chinese, where there are double width characters. Thus, for example, it needs ten display positions to display five double-width characters, even though the "character length" of the string is 5.

And, indeed, there's a third possibility, the "byte length", which is the number of bytes needed to store the string. When one or more bytes per characters is required, this might also be different. If three of those five double width characters need two bytes each and the other two need three bytes each, then the "byte length" of the string is 12.

UniVerse (and therefore DataStage) is able to handle all three.
  • LEN(string) returns the number of characters in the string.

    LENDP(string) returns the number of display positions needed for the string (it is this that is used in dictionaries).

    BYTELEN(string) returns the number of bytes needed to store the string.
Dictionary formats can specify anything that the FMTDP function supports but, as you note, scale is not relevant to character strings except those that contain decimal numbers. The format specification allows for some combination of:

Code: Select all

[width][backrgound]justification[conversion][mask]
Most folks simply specify width and justification, for example "10R" or "20T" ("T" means "text justification", which is the same as "L" but breaking on whole words as much as possible).

Just as an example, the format for the @ID field for RT_LOGnnn is "R%8" which displays the event number right justified on a mask of eight zeroes; the result is a right-justified, zero-filled number.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
gherbert
Participant
Posts: 9
Joined: Mon Mar 29, 2004 7:58 am
Location: Westboro, MA

Post by gherbert »

msigal wrote: So, what's the max length of a job name and what's the difference between character and display length?
As a default, the DataStage server repository is shipped allowing a maximum key size of 768 characters; this is defined by the MAXKEYSIZE tunable. As the job name is used to create keys for other ancilliary files/tables in a job, i.e. jobname*otherstuff, it would be wise to limit the length of jobname to well below this 768 character limit. Most people tend to keep their job names much shorter for sanity.

It is not advisable to change this from its current shipped value.
Post Reply