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

Convert character to ASCII code

Former Member
0 Likes
555

Hello,

I am using the below code snippet to get the ASCII code for a character. This code works for all systems where the OS is AIX but for systems where the OS is LINUX I am getting a junk value. Please let me know if there is any solution to the problem.

DATA: l_f_off TYPE sy-fdpos,

l_f_len TYPE i,

l_f_ascii TYPE i.

FIELD-SYMBOLS: <fs> TYPE x.

l_f_len = STRLEN( i_f_text ).

l_f_len = l_f_len - 1.

WHILE l_f_off <= l_f_len.

ASSIGN i_f_text+l_f_off(1) TO <fs> CASTING.

l_f_ascii = <fs>.

IF l_f_ascii < 32 OR l_f_ascii > 126.

e_f_flag = 'X'.

ENDIF.

l_f_off = l_f_off + 1.

ENDWHILE.

Hello,

I am using the below code snippet to get the ASCII code for a character. This code works for all systems where the OS is AIX but for systems where the OS is LINUX I am getting a junk value. Please let me know if there is any solution to the problem.

DATA: l_f_off TYPE sy-fdpos,

l_f_len TYPE i,

l_f_ascii TYPE i.

FIELD-SYMBOLS: <fs> TYPE x.

l_f_len = STRLEN( i_f_text ).

l_f_len = l_f_len - 1.

WHILE l_f_off <= l_f_len.

ASSIGN i_f_text+l_f_off(1) TO <fs> CASTING.

l_f_ascii = <fs>.

IF l_f_ascii < 32 OR l_f_ascii > 126.

e_f_flag = 'X'.

ENDIF.

l_f_off = l_f_off + 1.

ENDWHILE.

1 REPLY 1
Read only

Former Member
0 Likes
477

I have found the solution to the problem. The problem is happening since the Linux OS is little endian and the hex value has a different byte ordering than the value in the AIX OS.