Skip to Content
avatar image
Former Member

Mapping issue..

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Feb 19, 2010 at 12:46 PM

    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));

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 19, 2010 at 12:52 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 19, 2010 at 01:03 PM

    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

    Add comment
    10|10000 characters needed characters exceeded