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: 

Unicode conversion problem

Former Member
0 Kudos

Hi All,

I have got the below piece of code within an ABAP program:

FORM remove_chars_from_string CHANGING w_string.

DATA: c_dropfs(10),

fs TYPE x VALUE 13.

CONCATENATE fs ' , ' INTO c_dropfs.

TRANSLATE w_string USING c_dropfs.

ENDFORM. "remove_chars_from_string

When i select the 'Unicode checks active' checkbox the CONCATENATE statement does not syntax check as var 'fs' of type x value 13. Does anyone know what the value 13 does and how i would re-created this statement in a unicode compliant way?

Thanks in advance

Regards

Mart

11 REPLIES 11

Former Member
0 Kudos

Hi Mart,

In unicode envmnt u can use only c,n,d,t, type of data in concatenate statament.

You cannot use a hecadecimal stmnt (i.e of type X ).

what u have to do is replace X with eqivalent C,N, Type.

regards,

Navneeth.K

Former Member
0 Kudos

if u check Unicode check active, then u need to use only C or N type of data while concatenating.

For ur requirement u need to change the field type either to C or N and then use concatenate statement.

Former Member
0 Kudos

hi Mart,,

change the code to

DATA: c_dropfs(10),

fs TYPE c VALUE '#'.

hope it solves your query

regards,

Navneeth.K.

0 Kudos

hi,

in additon to my earlier post the equivalent of

fs TYPE X VALUE 13 is

fs TYPE C VALUE '#'

hope it solves your problem

regards,

Navneeth.K

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I guess first we need to figure out what the hex 13 is for. Then you could use one of the attributes of the class CL_ABAP_CHAR_UTITLIES instead of the hex field. You can concatenate the attribute like so.

data: str type string.

concatenate cl_abap_char_utilites=>horizontial_tab ',' into str.

Yes, the above example doesn't make much sence, a tab and then a comma, but you get the idea of how to concatenate a non-printable character.

The attributes of this class can be used in a concatenate statement and pass unicode checks, because they are character typed, the kernal will then translate in to the hex value behind the scenes.

Regards,

RIch Heilman

0 Kudos

So, i've looked up hex value 13, and it appears to be CR_LF. So we can do this.

data: str type string.
 
concatenate cl_abap_char_utilites=>CR_LF  ',' into str.

Regards,

RIch Heilman

0 Kudos

And no, the hex value 13 does not translate to #, you will see this # in debug when fewing a string, which contains non-printable characters, this # could actually be any non-printable characters, so if you were to search the string for "#", it would not find it, because it is not #, it is the non-printable character.

Regards,

RIch Heilman

0 Kudos

Thanks for all the responses, but yes I appreciate that within a unicode program you can't use hex characters and ideally I would like to replace it with an attribute from CL_ABAP_CHAR_UTITLIES, but it is which one to replace it with that I need to know. Also replacing it with ‘#’ for the reasons Rich Heilman pointed out will not work. Also i am not sure 13 is carriage return as the hex value for this is ‘D’ or ‘0D’ (it is the ASCII value that is 13 for cr). The hex value 13 is in fact device controller 3 (DC3) but I have no idea what this means!!!! Anyone got any further ideas as to how this can be solved or what DC3 menas?

Regards

Mart

0 Kudos

Oh, yes, you are right, I was looking in the wrong column in the chart that I found. SOrry.

Regards,

RIch Heilman

0 Kudos

just checked the chart again, i have no idea what that is and I'm pretty sure that it is not included in the class above.. Not sure how to move foward from here.

REgards,

RIch Heilman

0 Kudos

No problems Rich, thanks for your time and efforts on this matter.

Regards

Mart