Archived discussions are read-only. Learn more about SAP Q&A

HEX TO CHAR CONVERSION

Gentlemen,

I had a prior post in which I converted a string to HEX (in order to pass it as a literal to my subroutine [where one of the characters wasn't recognized within the literal]).

NOW I need to reconvert the HEX string back to regular characters. I've tried several variations of my code and checked all the help documentation. Please give me some advice. FOR NOW, I JUST WANT TO RUN THE RECONVERSION IN A TEST PROGRAM AND THEN TRANSFER THE WORKING CODE TO THE SUBROUTINE.

My code is below: (arc_buffer-segment contains a segment returned by my FM)

DATA: HEXSTRINGER(10000).
DATA: STR1(1) VALUE 'C'.
DATA: STR2(2) VALUE '7C'.
DATA: LEN TYPE I VALUE 1.
DATA: STRINGH(10000) TYPE C.
FIELD-SYMBOLS: <fsHex>, <H>.
assign ARC_BUFFER-segment to <fsHEX> type 'X'.
           write <fsHEX> to HEXSTRINGER.

           REPLACE STR1 WITH STR2 INTO HEXSTRINGER length LEN.
            if sy-subrc eq '0'.
               write:/ 'replaced'.
            endif.
* CONVERTS TO HEX
* ATTEMPTS TO CONVERT HEX BACK TO NORMAL CHAR STRING
ASSIGN HEXSTRINGER to <H> TYPE 'C'.
          write <h> to stringh.

Tags:
replied

Hi bate,

try this exp if anyinfo plz buzz me .

data:

_c type c,

_i type i,

_l type i,

a type I,

_o type i,

t1_ type c,

a1 type c.

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( PI_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.

move <pn> to rn1.

*if rn1+0(1) EQ '#'.

n = rn1+3(1).

A1 = n.

P_I_UPLOAD+a(1) = A1.

enddo.

endif.

regards

Prabhu

nethranp@hotmail.com

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question