on 02-19-2010 12:24 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.