Application Development and Automation 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: 
Read only

Move XSTRING to RAW under Unicode

mathias_lange3
Explorer
0 Likes
709

Hi all,

under Unicode I want to move a field type xstring to a field type raw. With move it is not possible.

DATA: buffer3 type xstring.

DATA: z_field type solix.

solix is from type SO_RAW255.

How can I move buffer3 to z_field???

For your better understanding what I want to do in my program:

I have a text field of type c and a field of type solix:

DATA: z_text(255) type c.

DATA: z_field type solix.

Move z_text to z_field doesn't work under Unicode, so I tried using a classmethod:

CALL METHOD cl_abap_container_utilities=>read_container_c

EXPORTING

im_container = z_text

IMPORTING

ex_value = z_field

EXCEPTIONS

illegal_parameter_type = 1

OTHERS = 2.

Ok, it works but another problem:

When z_text = 'a' its HEX-Value is '6100' in a Unicode-System. In a Non-UC it is only '61'.

And this is my problem. In my further program the 00 cause some problems.

To delete the '00' I use class cl_abap_conv_out_ce.

DATA: buffer3 TYPE xstring.

conv TYPE REF TO cl_abap_conv_out_ce.

conv = cl_abap_conv_out_ce=>create(

encoding = 'UTF-8'

endian = 'L' ).

conv->convert( EXPORTING data = z_text

IMPORTING buffer = buffer3 ).

The value of buffer3 is now '61', exactly what I want. But there is still the challange to move buffer3 to z_field. Under Unicode it is not possible with move.

The methods used before doesn't work.

How can I move xstring to so_raw255 field?

Or does anybody knows another way to delete the '00' from HEX????

I hope you can understand what I mean!

Thanks in advance,

Mathias

1 REPLY 1
Read only

mathias_lange3
Explorer
0 Likes
467

Hi,

I solved the Problem:

field-symbols: <x_wrk_line> type so_raw255,

<x_struc> type xstring.

assign buffer3 to <x_struc> casting.

assign z_line to <x_wrk_line> casting.

conv = cl_abap_conv_out_ce=>create(

encoding = 'UTF-8'

endian = 'L' ).

This method converts my textfield z_text into an xstring deleting the '00' I do not want:

conv->convert( exporting data = z_text

importing buffer = buffer3 ).

The challange was to move the field of type xstring to an raw-field. I used field-symbols. That was the solution.

<x_wrk_line> = <x_struc>.