Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9236

Re: How to convert string to hexadecimal in ABAP

$
0
0

Hi Bhupinder!

Try to refer to the code below:

 

REPORT ztest.

 

DATA:

  l_text        TYPEstringVALUE'Some text ┐ some text',

  l_letter      TYPEstringVALUE'┐',

  l_xspace      TYPExstring,

  l_xletter     TYPExstring,

  l_xstring     TYPExstring,

  lv_bin_outlen TYPE i,

  gt_bin        TYPESTANDARDTABLEOF sdokcntbin.

 

 

write: / 'Before:', l_text.

 

CALLFUNCTION'SCMS_STRING_TO_XSTRING'

  EXPORTING

   text = space

  IMPORTING

   buffer = l_xspace.

 

CALLFUNCTION'SCMS_STRING_TO_XSTRING'

  EXPORTING

   text = l_letter

  IMPORTING

   buffer = l_xletter.

 

CALLFUNCTION'SCMS_STRING_TO_XSTRING'

  EXPORTING

    text  = l_text

  IMPORTING

    buffer =l_xstring.

 

REPLACEALLOCCURRENCESOF l_xletter IN l_xstring WITH l_xspace INBYTEMODE.

 

CALLFUNCTION'SCMS_XSTRING_TO_BINARY'

  EXPORTING

    buffer      = l_xstring

  IMPORTING

    output_length = lv_bin_outlen

  TABLES

    binary_tab   = gt_bin.

 

CALLFUNCTION'SCMS_BINARY_TO_STRING'

  EXPORTING

    input_length = lv_bin_outlen

  IMPORTING

    text_buffer = l_text

  TABLES

    binary_tab  = gt_bin.

 

write: / 'After:', l_text.

 

Code colored by ABAP code lighter for SCN.sap.com.

 

Result:

1.png

 

Best regards,

George Shlyahov


Viewing all articles
Browse latest Browse all 9236

Trending Articles