cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

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.

Answers (0)