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: 

Convert type x to C

Former Member
0 Kudos
267

I have the following code with unicode error: -

CONSTANTS: C_LEFT_HEX(1) TYPE X VALUE 'AB'.

CONSTANTS: C_RIGHT_HEX(1) TYPE X VALUE 'BB'.

DATA: W_LONGCHAR(9).

CONSTANTS: C_UNKNOWN(7) VALUE 'Unknown'.

CONCATENATE C_LEFT_HEX C_UNKNOWN C_RIGHT_HEX INTO W_LONGCHAR.

How do I fix the error?

Thanks,

Edited by: Prakash Bhatia on Jan 14, 2008 12:19 PM

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos
69

Hi,

Check this code



report  zars no standard page heading
        line-size 170
        line-count 65(4).

data: content    type string ,
      xcontent   type xstring.

data: w_longchar(20).
constants: c_unknown(7) value 'Unknown'.

xcontent = 'AB'.
data: conv   type ref to cl_abap_conv_in_ce.
conv = cl_abap_conv_in_ce=>create( input = xcontent ).
conv->read( importing data = content ).
concatenate w_longchar content into w_longchar separated by space.

concatenate w_longchar c_unknown into w_longchar separated by space.


xcontent = 'BB'.
conv = cl_abap_conv_in_ce=>create( input = xcontent ).
conv->read( importing data = content ).
concatenate w_longchar content into w_longchar separated by space.

write : w_longchar.
break-point.

2 REPLIES 2

Former Member
0 Kudos
69

Hi Prakash,

CONCATENATE statement requires all components to be of type C. I think you need to change your 2 constants from type X to type C.

I assumed that you are getting syntax error on CONCATENATE statment as you didn't mention any details of the error message.

Hope this helps.

Thanks

Sanjeev

former_member194669
Active Contributor
0 Kudos
70

Hi,

Check this code



report  zars no standard page heading
        line-size 170
        line-count 65(4).

data: content    type string ,
      xcontent   type xstring.

data: w_longchar(20).
constants: c_unknown(7) value 'Unknown'.

xcontent = 'AB'.
data: conv   type ref to cl_abap_conv_in_ce.
conv = cl_abap_conv_in_ce=>create( input = xcontent ).
conv->read( importing data = content ).
concatenate w_longchar content into w_longchar separated by space.

concatenate w_longchar c_unknown into w_longchar separated by space.


xcontent = 'BB'.
conv = cl_abap_conv_in_ce=>create( input = xcontent ).
conv->read( importing data = content ).
concatenate w_longchar content into w_longchar separated by space.

write : w_longchar.
break-point.