Application Development 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: 

How to convert ASCII to CHAR?

Former Member
0 Kudos

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!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

*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

10 REPLIES 10

Former Member
0 Kudos

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.

0 Kudos

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.

0 Kudos

Hi, Vishnu.

Thanks for your answer. But I want to convert ASCII to CHAR.

Regards,

feng.

0 Kudos

plaese check the below forum which have solutions to your question

https://www.sdn.sap.com/irj/sdn/thread?messageID=2763087&#2763087

and especially the code by Swapnil Swami

former_member386202
Active Contributor
0 Kudos

Hi,

Try this FMs

CONVERT_ASCII_TO_ITF

CONVERT_ITF_TO_ASCII

Regards,

Prashant

0 Kudos

Hi, Prashant.

Can you give me an example?

Regards,

feng.

Former Member
0 Kudos

*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

Former Member

*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.