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
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"
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.
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