cancel
Showing results for 
Search instead for 
Did you mean: 

Map help

Former Member
0 Kudos

Hi Everyone,

I want some help with mapping requirement,

the easiest way to explain the requirement to provide examples. The simple explanation is to extract everything except the last five characters from source feild and map to target feild. See below.

if the source feild = 7TW7003-USP1, THEN i only want 7TW7003

if the feild = 7TW7005-USP1, THEN MAP 7TW7005

If the feild = S5079826-1-USP1, THEN MAP S5079826-1

Please help me with the above requirement.

Regards

Swetha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

that is simple by using below udf:

public String calculate1(String Output, Container container) throws StreamTransformationException{

int len = Output.length()-5;

return (Output.substring(0,len));

for ex:

Message was edited by: S Sankar

Former Member
0 Kudos

Thanks for the help sankar

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

Hi swetha,

At first you could calculate the length of string with the function length, next you substract four to that value and finally use this UDF:

public String dynamicSubstring(int begin, int end,String c,Container container){

   return (c.substring(begin,end));

}

Also you could do all in one UDF, but if you do a generic UDF you can reuse it in other map.

Regards.

Message was edited by: Iñaki Vila