cancel
Showing results for 
Search instead for 
Did you mean: 

Determine Element maxLenght in User-Defined Function

Former Member
0 Kudos

Hi,

I have the problem, that I have to fill up several fields with leading 0. I wrote a User-Defined Function for this. But the function doesn't know how long this element is, so I have to give the function the length of the element.

Is it possible to determine the length of the current element in an extended User-Defined Function

Yours

Thomas

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Thomas,

Of course you have to provide the metadata for the length of the field. But this has to be done anyway. How should the system know the length of the field?

Unfortunately it's not possible in message mapping to get the metadata from the message type definition.

Best regards

Joachim

stefan_grube
Active Contributor
0 Kudos

Hi Thomas,

I think an easy solution for this is, just have a simple function with two arguments. The first is the element, the second is a constant, where you put the length.

It is not possible to access the length of the field from the xsd.

Regards

Stefan

Former Member
0 Kudos

Hi,

>use a simple user defined function with the desired

>source element as input and give the following code...

>int k = a.length();

>String len = Integer.toString(k);

>return len;

That function will only give me the actual lenght of the input element, what I need is the max lenght of the target element...

>You can also use the built-in FormatNumber function to

>insert leading 0s.

How can I use this function to add leading zeros?

"'000'#" ? But there I have to do this for every element

>I think an easy solution for this is, just have a

>simple function with two arguments. The first is the

>element, the second is a constant, where you put the

>length.

Well I have this function. But I am looking for way to the safe the second argument ;o)

Thank you all for your help

Thomas

Former Member
0 Kudos

Hello Thomas,

> How can I use this function to add leading zeros?

> "'000'#" ? But there I have to do this for every

> element

Simply add the number of "0" you want to add. So if you e.g. 123 -> FormatNum(00000) -> 00123. This is the easiest and savest way to resolve this kind og problems.

Best regards

Joachim

Former Member
0 Kudos

Hello Joachim,

this will only works, if the numbers have always the same amount of digits. I can't use for line numbers, for example.

Yours,

Thomas

Former Member
0 Kudos

Hello Thomas,

You can also use the built-in FormatNumber function to insert leading 0s.

Best regards

Joachim