Skip to Content

Personas - webRFC - Special characters

Hey,

Anyone got experience how to handle a situation where using special characters like "ÆØÅøæåÜÖ" when using a webRFC call from Personas.

If the JSON string returned from the webRFC having 1 or more of those special characters, the call is failing in personas.

I tried to URL encode the values returned in the JSON string. This worked well, however the result inserted into a field in personas will show the URL encoding.

At the moment it shows like this:

JSON string (only a part of it) : {"key": "address", "value": "Dampf%C3%A6rgevej+17,2100"}

When pasting the result into a field in personas it shows like this:

"Dampf%C3%A6rgevej+17,2100"


Wanted result:


"Damfærgevej+17,2100"


Is it possible to have the webrfc to deliver these special characters ?


Regards

Henrik

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jan 28, 2015 at 10:25 PM

    You'll have to use JSON encoding for the special characters.

    Take a look at this: ABAP Keyword Documentation and look for the Rules for JSON section.

    In your particular scenario, the string you need to return is "Dampf\u00E6rgevej+17,2100"


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 30, 2015 at 06:44 PM

    Thank you both for the feedback and the suggestion regarding the wrong handling of blanks.

    In the meantime I figured the code can be made simpler to avoid some unnecessary type conversions, so the corrected code looks like this:

    DATA: txt_in TYPE string VALUE 'Dampfærgevej+17,2100 ABÉÁCÖŐ',
    chr TYPE char1,
    strlength TYPE i,
    offset TYPE i,
    hcode TYPE syhex02,
    ccode TYPE char4,
    result TYPE string,
    gr_error TYPE REF TO cx_root.

    strlength = strlen( txt_in ).

    DO strlength TIMES.

    offset = sy-index - 1.
    chr = substring( val = txt_in off = offset len = 1 ).

    TRY.
    hcode = cl_abap_conv_out_ce=>uccp( chr ).
    CATCH cx_root INTO gr_error.
    hcode = '0020'.
    ENDTRY.

    IF hcode < '0020' OR hcode > '007E'.
    ccode = hcode.
    CONCATENATE result '\u' ccode INTO result.
    ELSE.
    CONCATENATE result chr INTO result RESPECTING BLANKS.
    ENDIF.

    ENDDO.

    WRITE / result.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 30, 2015 at 08:39 AM

    Hey Tamas,

    Thanks a bunch 😊 this really did the trick, however as Björn as well figured out, some minor issues with blanks.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.