‎2008 Feb 08 6:59 AM
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. Im not very good with character formats etc. I tried reading the SAP Help but thats 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 Im 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 Im 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
‎2008 Feb 08 7:45 AM
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?
‎2008 Feb 08 7:45 AM
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?
‎2008 Feb 08 8:27 AM
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
‎2008 Feb 08 11:24 AM
Just had a quich look, translate is not allowed in unicode programs. You need use one of cl_abap_conv* classes instead.
‎2008 Feb 11 6:35 AM
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
‎2008 Feb 11 9:25 AM
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,