12-18-2007 8:14 AM
Hi, experts.
Now I want to convert ASCII to CHAR, can you give me some methods? And I also want to know what's my ABAP Version.
Thanks in advance!
12-18-2007 8:39 AM
*going from A to 65
data : c value 'A'.
field-symbols : <n> type x.
data : rn type i.
assign c to <n> casting.
move <n> to rn.
write rn.
*going from 66 to B
data : i type i value 66.
data : x type x.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c.
Tom Demuyt
12-18-2007 8:19 AM
And I have tried this method:
data : i type i value 66.
data : x type x.
data : c type c.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c.
But the compiler give me this error:The length of 'X' in bytes must be a multiple of the a Unicode character(regardless of the size of the Unicode character).
Regards,
feng.
12-18-2007 9:13 AM
Hi, all.
I didn't check Parminder's method, but I think that FM wouldn't help me, because FM CONVERT_ASCII_TO_ITF's short text is 'Text Conversion ASCII to ITF (SAPscript Format)'. And the other ansers I have already checked, and the compiler will give an error which I have written in the second reply.
Maybe the version of ABAP cause this problem. Can you tell me how to know the version?
Regards,
feng.
12-18-2007 8:19 AM
12-18-2007 8:23 AM
Hi, Vishnu.
Thanks for your answer. But I want to convert ASCII to CHAR.
Regards,
feng.
12-18-2007 8:29 AM
Hi Feng,
Check this thread..
https://www.sdn.sap.com/irj/sdn/thread?threadID=621689&messageID=4382555#4382555
12-18-2007 8:56 AM
plaese check the below forum which have solutions to your question
https://www.sdn.sap.com/irj/sdn/thread?messageID=2763087�
and especially the code by Swapnil Swami
12-18-2007 8:29 AM
Hi,
Try this FMs
CONVERT_ASCII_TO_ITF
CONVERT_ITF_TO_ASCII
Regards,
Prashant
12-18-2007 8:51 AM
12-18-2007 8:39 AM
*going from A to 65
data : c value 'A'.
field-symbols : <n> type x.
data : rn type i.
assign c to <n> casting.
move <n> to rn.
write rn.
*going from 66 to B
data : i type i value 66.
data : x type x.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c.
Tom Demuyt
02-09-2012 5:39 PM
*After look so bad code that no work i did my own code, a gift for all you:*
FORM CHARACTER_ASCII using p_letra
changing p_nro type i.
field-symbols: <n> type x.
assign p_letra to <n> casting.
move <n> to p_nro.
ENDFORM.
*----
FORM ASCII_CHARACTER using p_nro type i
changing p_letra.
DATA: c TYPE c,
x(4) TYPE x.
FIELD-SYMBOLS: <fc> TYPE c.
x = p_nro.
ASSIGN x to <fc> CASTING TYPE c.
MOVE <fc>+1(1) to p_letra.
ENDFORM.