Skip to Content
avatar image
Former Member

sap translates \n\r wrong

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 18, 2008 at 02:54 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 18, 2008 at 05:38 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 18, 2008 at 08:04 AM

    is that a common sap problem or not.

    Why this bahaivour ? What is the reason for ?

    Regards

    sas

    Add comment
    10|10000 characters needed characters exceeded