cancel
Showing results for 
Search instead for 
Did you mean: 

sap translates \n\r wrong

Former Member
0 Kudos

Dear Experts,

the problem what I am having is

that an input which is entered on the WebDynpro side within

a TextEdit Field like

aaaa

bbbb

ccccc

internally as "Ltxt"= "aaaa\r\nbbbb\r\nccccc\r\n"

will be translated on the SAP

Side as -> aaaa##bbbb##ccccc##.

This is what I am seing inside the field on the Sap side

What is wrong here ?

Regards

erdem

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Erdem,

Try like this:

StringBuffer buffer = new StringBuffer(wdContext.currentContextElement().get<TextEditAttrib>());

for (int i = 0,index=buffer.indexOf("\n"); i < buffer.length(); i++) {

if(i==index){

buffer.replace(i-1, i+1,"\r\n");

index = buffer.indexOf("\n");

if (index == -1)

break;

}

}

wdContext.currentContextElement().set<attribName>(buffer.toString());

Now attribName value is "aaaa\r\nbbbb\r\nccccc\r\n"

regards,

Siva

Answers (2)

Answers (2)

Former Member
0 Kudos

is that a common sap problem or not.

Why this bahaivour ? What is the reason for ?

Regards

sas

Former Member
0 Kudos

Hi,

I dont think that its a problem, you have entered value in multiple rows and textedit maintains this using \n\r.

Regards

Ayyapparaj

Former Member
0 Kudos

how can I avoid displaying # and inserting real line feeds on the sap side.

Regards

sas

Former Member
0 Kudos

Hi,

Easiest option is reverse this when the data is displayed , what i mean is replace # with \n\r

Regards

Ayyapparaj

Former Member
0 Kudos

how can I achieve that ? what is line feed on the sap side ?

bye

sas

Former Member
0 Kudos

Hi,

If you want to remove this, use the following code align this with your context attribute instead of hard coded strings



Example :
String str = "aaaa\r\nbbbb\r\nccccc\r\n";
str = str.replace("\r\n", ""); // will replace all "\r\n" with ""

Regards

Ayyapparaj