cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping

Former Member
0 Kudos

Hi

I need to build a logic in mapping as below.

When a string of length 20 comes I got to pick first 19. When it comes of 15 i got to pick all 15. Can we do thorugh standard node functions ?? or we got to write UDF for this ??

Thanks

Kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey

just write a simple UDF for this,are u dealing with only two types of field lengths(i.e 20 or 15) or you can get other lengths too?

Thanx

Aamir

Former Member
0 Kudos

Aamir,

Only I am dealing with 2 types of field lenghts. i.e 15 and 20

thanks

kumar

Former Member
0 Kudos

then just write a UDF in which you will check the length of string(use .length function) ,now if this length is 20 then use substring function and pick up the first 19 characters else if length is 15,then simply return it as it is.

Thanx

Aamir

Former Member
0 Kudos

Hi try this

id -length \ id -substring (0--20)

greater -- if -


Target field

Constant 20 ID

Try this and let me know. Graphical mapping

Regards

Ramidi

Former Member
0 Kudos

Id mapped it to Length then choose Greater function choose constant value 20 connect to the greater function. then result connect to If on top choose ID and add substring function choose (0--20). then below choose ID. then result connect to target field.

result should be. 20 or greater it will be display only 20 char. if value 15 also it will be 15 length filed value.

Try this

Regards

Ramidi

Answers (1)

Answers (1)

Former Member
0 Kudos

Have you tried the substring function?

Former Member
0 Kudos

Yes ! I have tried. By using that when string lenght comes to be 20 I am able to pick 19. But it fails when string length comes to be 15. I want to implement both the logics on one field !

Former Member
0 Kudos

Hello,

Check the string length and then accordingly apply the substring operation.

Regards,

Former Member
0 Kudos

I created a UDF called Substring without length.

Try something like....

int i = Integer.parseInt(a);
String c = b.substring(2,i);
return c;

You would add the input field - length function into A and the Field into B - C is output!