10-21-2009 3:35 PM
How can I turn a number into a letter?
For example if I have i = 65 that it one turns into one 'A'.
I have tried to look for something in the forum but I have not found anything that works.
Thanks!
10-23-2009 2:00 AM
Take a look at class CL_ABAP_CONV_IN_CE - method UCCP will take hex 0041 as input and return A as output, method UCCPI will take decimal 65 and return A. Other methods provide the functionality for more complicated scenarios.
There is also class CL_ABAP_CONV_OUT_CE - method UCCPI takes A as input and returns 65.
These are documented online under ABAP keyword documentation (the little blue i button in SE38) under ABAP - by Theme,
ABAP System Classes and Interfaces, Classes for Converting Character Sets and Number Formats.
Andrew
10-21-2009 3:53 PM
Well, they're not the same thing and basically incompatible. Could you please give more information?
Rob
10-21-2009 4:00 PM
I have seen this code that it should write 'A' but it does not work.
data : i type i value 65.
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.
10-21-2009 4:11 PM
It worked for me when I tried it (after adding):
DATA: c(1).
at the top.
Rob
10-21-2009 4:13 PM
returns sintax error;
The length of "X" in bytes must be a multiple of the size of a Unicode
character (regardless of the size of the Unicode character).
This is the code I use;
DATA: c(1).
data : i type i value 65.
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.
10-21-2009 4:22 PM
I see - for some reason, the "Unicode code checks" was clicked off in my test program.
Rob
10-22-2009 12:30 PM
DATA: c(2) type c.
data : i type i value 65.
data : x type x.
field-symbols : <fc> type x.
move i to x.
assign x to <fc> CASTING.
move <fc> to c.
write c.
you can write ur code like this.
10-22-2009 12:40 PM
10-22-2009 5:10 PM
The FM URL_ASCII_CODE_GET does the opposite, you put an 'A' as input and returns '41' (65 in hex)
But, how do the opposite?
10-23-2009 2:00 AM
Take a look at class CL_ABAP_CONV_IN_CE - method UCCP will take hex 0041 as input and return A as output, method UCCPI will take decimal 65 and return A. Other methods provide the functionality for more complicated scenarios.
There is also class CL_ABAP_CONV_OUT_CE - method UCCPI takes A as input and returns 65.
These are documented online under ABAP keyword documentation (the little blue i button in SE38) under ABAP - by Theme,
ABAP System Classes and Interfaces, Classes for Converting Character Sets and Number Formats.
Andrew
10-23-2009 8:57 AM
Thanks Andrew !
This is the solution;
DATA: num(4) TYPE c VALUE '0041'.
DATA: c TYPE C.
c = CL_ABAP_CONV_IN_CE=>uccp( num ).
WRITE c.
10-23-2009 3:26 AM
Hi,
<li>Here is the sample program which Converts Letter to ASCII and ASCII to Letter.
Thanks
Venkat.O
REPORT ztest.
"Going from A to 65
DATA : c TYPE c VALUE 'A'.
DATA : rn TYPE i.
FIELD-SYMBOLS : <n> TYPE x.
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.
04-16-2013 9:55 AM
This will print A..Z in Unicode as well
DATA: c(4) TYPE c.
DATA : i TYPE i VALUE 65.
DATA : x(4) TYPE x.
FIELD-SYMBOLS : <fc> TYPE c.
DO.
MOVE i TO x.
ASSIGN x TO <fc> CASTING.
MOVE <fc> TO c.
WRITE: c+3(1), ' '.
ADD 1 TO i.
IF i > 90.
EXIT.
ENDIF.
ENDDO.