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

How to convert hexadecimal value to string

Former Member
0 Likes
14,834

Hi ABAP Gurus...

i wanted to convert hexadecimal value in to string.

Is there any finction module to convert hexadecimal value to string.

Thanks in advance.

Chintan

Hi ABAP Gurus...

i wanted to convert hexadecimal value in to string.

Is there any finction module to convert hexadecimal value to string.

Thanks in advance.

Chintan

5 REPLIES 5
Read only

Former Member
0 Likes
4,722
Try this code.

data: char(3) type c,
hex(4) type x.

field-symbols <fs> type any.

hex = '414243'.
assign hex to <fs> casting type c.

char = <fs>.
write:/ char.
Read only

Former Member
0 Likes
4,722

Hi Chintan

If you are looking for characters like Tab or Linefeed. We can use CL_ABAP_CHAR_UTILITIES.

data: tab(1) type c value cl_abap_char_utilities=>horizontal_tab.

Alternatively,

data: tab(1) type X value '09',
      str type string.

move tab to str.
write:/ str.

Kind Regards

Eswar

Read only

Former Member
0 Likes
4,722

try using Fm -

STPU1_HEX_TO_CHAR

Read only

Former Member
0 Likes
4,722

make use of Field-symbols.

field-symbols : <n> type x.
field-symbols : <pn> type c.
field-symbols : <dn1> type x.
data : rn type i.
data : rn1(4) type c.
data : n type c.

describe field P_I_UPLOAD type _c.
if _c eq 'u'.
_l = strlen( P_I_UPLOAD ).
_i = _l div 2.

do _l times.
a = sy-index - 1.
a1 = P_I_UPLOAD+a(1).
assign a1 to <n> casting.
move <n> to rn.
if rn = 32.
continue.
endif.
*For Prod rn1 should be 3(1) and for QAS rn1 Shld be 0(1)
*rn = rn - key.
*rn = rn - 12  .
rn = rn - ( P_DATE+4(2) + P_DATE+6(2) ).
assign rn to <pn> casting.
move <pn> to rn1.
*if rn1+0(1) EQ '#'.
n = rn1+3(1).
*a1 = n.
*ELSE.
*N = RN1+0(1).
A1 = n.
*ENDIF."PRABHU ON 4.1.2005
*REPLACE ALL OCCURRENCES OF '#' IN rn1 WITH ' '.
P_I_UPLOAD+a(1) = A1.

enddo.
endif.

regards

prabhu

Read only

Former Member
0 Likes
4,722

Hi Chintan,

Please refer the below links,

Also check with the FM NLS_STRING_CONVERT_TO_SYS.

Regards,

Hema.

    • Reward points if it is useful.