Skip to Content
avatar image
Former Member

Concat 4 source fields in new line to a single field in IDoc segment-field?

HI,

My requirement is below: Need to concar 4 sources fields in a file and map them to a single target field (In IDoc) with each source field in new line.

Lets say if I have a source file with

f1, f2, f3, f4

I need to send to single target field as follow:

f1

f2

f3

f4

It is basically concat in newline. Can I use any delimiter string in std concat funtion or help me to provide sample code for UDF.

Regards,

N@vIn

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 29, 2010 at 09:47 PM

    Sample UDF for your case.

    public String concatStrings(String var1, String var2, String var3, String var4, Container container) throws StreamTransformationException{

    String newLine = System.getProperty("line.separator");

    //String newLine="\r\n";

    String concatString =var1 + newLine + var2 + newLine + var3 + newLine +var4;

    return concatString;

    }

    Note: Use System.getProperty that would take care for all Operating systems when deploy this code.

    you might not able to test in test mapping tool

    If you run in eclipse or nwds you will see output as follows

    var1 value

    var2 value

    var3 value

    var3 value

    Hope this helps. Let me know further.

    Add comment
    10|10000 characters needed characters exceeded