cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue..

Former Member
0 Kudos

Hi every one..

I had issue in File to File scenario at Mapping..

For eg : From sender side am getting a name = ' Ram Manohar joshi'..At target side this name has to be divided as

'Ram' for First name,

'Manohar' for Secong Name,

'Joshi' for Last name..

How should i have to procedd..Is ther any way to go by using node functions..

This might be a repeated question..but i didnt find the answer ..so atlast i raised a query.

Please had the solution..

Thanks in Advance..

Mark

Accepted Solutions (0)

Answers (3)

Answers (3)

sunilchandra007
Active Contributor
0 Kudos

Hi Mark,

It can be done easily with combination of node functions like substring, indexOf, lastIndexOf and length.

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm

For firstname, use substring(name ,0 ,indexOf(name, " ") )

For secondname , use substring(name , indexof(name, " ") , lastIndexOf(name, " ") )

For last name , use substring(name , lastIndexOf(name, " ") , length(name))

If you want to write udf, write 3 udf as shown below -

public String getFirstNamel(String name, Container container)

{

String arr[] = name.split(" ");

return arr[0];

}

public String getSecondNamel(String name, Container container)

{

String arr[] = name.split(" ");

return arr[1];

}

public String getLastNamel(String name, Container container)

{

String arr[] = name.split(" ");

return arr[2];

}

Regards,

Sunil Chandra

Former Member
0 Kudos

Hi Mark,

u have to Use String Function "SUBSTRING".

EX:

Returns the substring from the start position to the specified length. Index of the first character is 1. If length is omitted it returns the substring from the start position to the end

Example: substring('Beatles',1,4)

Result: 'Beat'

Example: substring('Beatles',2)

Result: 'eatles'

Thanks

Ravi

former_member208856
Active Contributor
0 Kudos

You have to write UDF for this :

Take help from below code for First Name :

int i = 0;

String temp = a[0].toString();

i = temp.indexOf(' ');

result.addValue(temp.substring(0,i));

Take help from code For Last name :

int i = 0;

String temp = a[0].toString();

int l = temp.length();

i = temp.indexOf(' ');

result.addValue(temp.substring(i,l-1));