Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with FM READ_TEXT and special characters

Former Member
0 Kudos

Hi everyone,

I have a problem with some long texts. When they were created someone put some special characters in it (e.g. currency codes, formatting signs, etc.). Now I'm reading these texts using FM READ_TEXT but the mentioned special characters are displayed as # in the result table. The GUI text edit (as it seems class CL_GUI_TEXTEDIT) gets the same result from FM READ_TEXT but is able to display the right special characters. I wasn't able yet to find out how this is done. And I can't use the GUI text edit as I need the texts in an RFC call. Does anyone know how the text formatting is done so that every special character is displayed correctly?

Any help is appreciated.

Thanks in advance,

Robert

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos

Hi Mirko,

sap prints anything that it cannot display as # only.

But internally it will be holding the original character only.

What will the rfc do with the text passed to it?

Regards,

ravi

5 REPLIES 5

Former Member
0 Kudos

Hai Mirko Heger

Check the following Code

DATA: BEGIN OF XTHEAD.

INCLUDE STRUCTURE THEAD.

DATA: END OF XTHEAD.

DATA: BEGIN OF ZZTLINE OCCURS 10.

INCLUDE STRUCTURE TLINE.

DATA: END OF ZZTLINE.

XTHEAD-TDID = 'ZPPM'. "TEXT-ID

XTHEAD-TDSPRAS = SY-LANGU. "Language

XTHEAD-TDNAME = 'ZTKF'. "identification

CONCATENATE SY-TCODE(5) ITAB0300POS-AUFNR

INTO XTHEAD-TDNAME.

XTHEAD-TDOBJECT = 'TEXT'. "Object type top/position

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = XTHEAD-TDID

LANGUAGE = XTHEAD-TDSPRAS

NAME = XTHEAD-TDNAME

OBJECT = XTHEAD-TDOBJECT

IMPORTING

HEADER = XTHEAD

TABLES

LINES = ZZTLINE

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

IF SY-SUBRC = 0.

REFRESH ZZTLINE.

ZZTLINE-TDLINE = ITAB0300POS-BEM.

APPEND ZZTLINE.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

HEADER = XTHEAD

IMPORTING

FUNCTION = ZFUNCTION

NEWHEADER = XTHEAD

TABLES

LINES = ZZTLINE

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5.

ELSE.

XTHEAD-TDID = 'ZPPM'. "TEXT-ID

XTHEAD-TDSPRAS = SY-LANGU. "Language

XTHEAD-TDNAME = 'ZTKF'. "identification

CONCATENATE SY-TCODE(5) ITAB0300POS-AUFNR

INTO XTHEAD-TDNAME.

XTHEAD-TDOBJECT = 'TEXT'. "Object type top/position

REFRESH ZZTLINE.

ZZTLINE-TDLINE = ITAB0300POS-BEM.

APPEND ZZTLINE.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = XTHEAD-TDID

FLANGUAGE = XTHEAD-TDSPRAS

FNAME = XTHEAD-TDNAME

FOBJECT = XTHEAD-TDOBJECT

TABLES

FLINES = ZZTLINE

EXCEPTIONS

NO_INIT = 01

NO_SAVE = 02.

ENDIF.

Thanks & regards

Sreeni

former_member181962
Active Contributor
0 Kudos

Hi Mirko,

sap prints anything that it cannot display as # only.

But internally it will be holding the original character only.

What will the rfc do with the text passed to it?

Regards,

ravi

0 Kudos

Hi Ravi,

the texts are stored and displayed in an external system. So I need the texts including the special characters within the RFC. I'm not yet sure if the text really has a # in it or if it is the special character which only can't be displayed wherever I look at it. Type conversions didn't help by now. Any ideas?

Regards.

0 Kudos

Hi Mirko,

Just in debug mode see the # character's hex value. it will be something different from the hex value of the real #.

Regards,

ravi

0 Kudos

I have the same problem. I am picking up some characters (includes special characters too) from a custom table. When these characters are displayed, few of the special characters are displayed as #. This is for a Turkish language. I tried with the FM SCP_REPLACE_STRANGE_CHARS, but it only converts those characters to english. Whereas my requirement is that the ouput should display whatever is there in the table, including the special characters, as it is. Can anyone please let me know if there is any FM for that????

Thanks,

Aruna