cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove carriage returns in message mapping

former_member182412
Active Contributor
0 Kudos

Hi Experts,

I am getting carriage returns in one of the source field, i need to remove those carriage returns and i need to pass it to target field, can anyone suggest me how can i achieve this.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Have you tried with REPLACE function, replacing carriage return character with NULL?

former_member182412
Active Contributor
0 Kudos

Yes i tried with REPLACE function no luck, when i use the indexOf function to search for \n it is returning -1, when i search in the notepad++ i could able to find for \n and \r, but indexOf function couldn't find carriage returns.

former_member182412
Active Contributor
0 Kudos

I solved this problem with UDF.

String var2 = var1.replaceAll("[\n\r]", "");

return var2;

Former Member
0 Kudos

Great!

Before UDF, you tried with replaceString function right?

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Praveen,

String var2 = var1.replaceAll("\n\r", ""); 
return var2;

This UDF has two problems:

1. In windows it is \r\n (carriage return and line fed). It is not \n\r.

2. Better to use new line system property rather than hard coding new line characters.

Please use this UDF.

public String replaceNewLine(String inputVar, Container container) throws StreamTransformationException{
String newLine = System.getProperty("line.separator");
return inputVar.replaceAll(newLine, ""); 
}

Regards,

Raghu_Vamsee

Answers (1)

Answers (1)

diego_gabriel
Participant
0 Kudos

Hello,

Are you getting only CR or CR+LF (line feed) ?

In this case - CRLF - you can use content conversion in your sender adapter:

<recordset_structure>.fieldSeparator = 'nl'

So in your receiver adapter you can replace any special char by 'nl' again.

Check these links.

http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm

http://help.sap.com/saphelp_nwpi711/helpdata/en/44/686e687f2a6d12e10000000a1553f6/content.htm

Regards,

Diego Estanguini Gabriel