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

Unicode - TRANSLATE... TO CODE PAGE

Former Member
0 Likes
1,964

Hello Everyone,

I am working on a Unicode Upgrade Project from 4.6C to ECC 6.0

Has any one of you worked with the TRANSLATE statement using the TO CODE PAGE variant? First of all, I am not clear on its utility. I’m not very good with character formats etc. I tried reading the SAP Help… but that’s not very clear. Please help me with this. The sample code that I have with me goes like this:

* ABC is a structure with fields of mixed data types.
TRANSLATE ABC TO CODE PAGE '0100'.

Secondly, my actual requirement is to replace this coding style and make it Unicode compatible. For this I found that I’m supposed to use the methods of either of the classes: CL_ABAP_CONV_IN_CE or CL_ABAP_CONV_OUT_CE. I am not able to decide on which method to pick because I’m not clear with the basic functionality of the obsolete code i.e. TRANSLATE… TO CODE PAGE

I need to resolve this issue at the earliest. Any help would be much appreciated!!

Regards,

Priya

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
1,208

Mixed structures cant be handled in such a way under unicode. You have to do the work whatever is needed component ba component.

Without unicode you can determine where characters are in the structure by knwoing strating psition and length.

In Unicode you cant to that anymore because depending on the content the starting position my vary now. Without unicode a character is always one byte. In Unicode a character might be one, two, three or even four bytes long depending on the representing character.

So using translate a mixed structure to a code page makes not really sense.

What do you really want to achieve?

5 REPLIES 5
Read only

rainer_hbenthal
Active Contributor
0 Likes
1,209

Mixed structures cant be handled in such a way under unicode. You have to do the work whatever is needed component ba component.

Without unicode you can determine where characters are in the structure by knwoing strating psition and length.

In Unicode you cant to that anymore because depending on the content the starting position my vary now. Without unicode a character is always one byte. In Unicode a character might be one, two, three or even four bytes long depending on the representing character.

So using translate a mixed structure to a code page makes not really sense.

What do you really want to achieve?

Read only

0 Likes
1,208

Thanks for the prompt response and clearing certain points about usage of TRANSLATE.

I am working on a Unicode upgrade task where I have to find all statements that are not Unicode compatible and replace them with corresponding Unicode compatible statements.

The TRANSLATE... TO CODE PAGE statement is used on a structure in one of my programs. I need to find out a Unicode way of doing what the obsolete variant of TRANSLATE was doing.

I hope my query is clear now. Please do revert with your comments on it.

Thanks in advance.

Regards,

Priya

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,208

Just had a quich look, translate is not allowed in unicode programs. You need use one of cl_abap_conv* classes instead.

Read only

0 Likes
1,208

Thanks Rainer.

I have already tried using the cl_abap_conv* conversion classes.

The classes/ methods that I tried using so far works fine, but it gives me an error in my particular program because the structure being converted has variables of varied data types.

The methods I tried are giving the C_OBJECTS_NOT_CONVERTIBL error. This is related to type conversion related errors.

I am still working on this. Please update me if you get any specific example on this issue.

Regards,

Priya

Read only

0 Likes
1,208

Did you try

CL_ABAP_CONV_OUT_CE, Method convert_struc?

This method is not throwing an exception like you posted and this looks suitable,