Usage of LenDP function

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
vinodlakshmanan
Participant
Posts: 82
Joined: Wed Jul 14, 2004 7:21 am
Location: India

Usage of LenDP function

Post by vinodlakshmanan »

Hi,
I need to use the LenDP function on one of my input fields.
1. What is the meaning of "length in display positions"
2. The function accepts only integer values for mapname. How do I get to know which integer value maps to which NLS Map?

Thanks,
Vinod
Integrity is what you do when no one is watching
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Hello Vinod,

let's say that you have a UTF-16 NLS enabled and you have a string with a single Japanese Kanji (let's just assume that it's the symbol for Chikara [which is my favorite Kanji]), if you were to do a LEN(KanjiString) you would get 2 (because it is 2 bytes long), if you were to do a LENDP(KanjiString) you would get 1, because it is only one character and occupies only 1 display position.

The LENDP() is the NLS equivalent of the LEN() function, it ignores the number of bytes used to store a character string and just computes the number of distinct characters used - in single-byte non-nls these two values are always identical, i.e. a string of 12 bytes will have exactly 12 characters. In variable-length encodings you will never know how many characters are in a string until you parse them.

The [Mapname] is optional and should only be used if the string you are looking at is in another NLS encoding than the process is using.
vinodlakshmanan
Participant
Posts: 82
Joined: Wed Jul 14, 2004 7:21 am
Location: India

Post by vinodlakshmanan »

Now if I want to specify the mapname as UTF8, what would be the value out there.
Basically, DataStage is expecting an integer value in mapname and is giving a compilation error if I do not supply this field or give a character value; only numeric values are being compiled correctly. DS version is 7.0.0.
Integrity is what you do when no one is watching
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Vinod,

the 2nd argument is optional as documented. At V7.5 I wrote a dummy routine which consisted of 1 line - Ans = LENDP(Arg1) and it compiles correctly also displays a length of 2 when I enter (through cut-and-paste) the 4 bytes/2 Characters that make up the name "Tokyo".
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A small clarification to Arnd's first post.

LEN(TheString) returns the number of characters in TheString.
BYTELEN(TheString) returns the number of bytes in TheString.
LENDP(TheString) returns the number of display postions required for TheString.

For example, consider a string comprising two single-width characters and one double-width character.
  • LEN(TheString) returns 3.

    BYTELEN(TheString) returns however many bytes are needed to store these characters, which theoretically can be as many as four per character under UV-UTF8 encoding. If two bytes per character, this function would return 6.

    LENDP(TheString) returns 4.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply