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 can Convert TYPE X to TYPE C with module CL_ABAP_CHAR_UTILITIES

0 Kudos

HI EXPERTS.

I recently face some trouble ..

I have to convert TYPE X to TYPE C with module name of CL_ABAP_CHAR_UTILITIES,

but don't know every method of this module.. I just know few methods like this

ex) aaa TYPE X VALUE '09' -> aaa TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

I still have stuffs that should convert like TYPE X VALUE '81', '9F', 'E0' etc..

Please teach me where can i refer all method of CL_ABAP_CHAR_UTILITIES for converting TYPE X to TYPE C

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB is not a method but a class attribute of the class (constant).

  • Could you reformulate your question, explain the initial requirement
  • Did you look at other similar constants defined in the class such as VERTICAL_TAB, NEWLINE, CR_LF, FORM_FEED or BACKSPACE (with SE24 or SE80)

Would you require a class to do the job of hex to char conversion, look at this small sample

DATA conv Type Ref To CL_ABAP_CONV_IN_CE.
TRY.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
      EXPORTING
        ENCODING                      = 'UTF-8' 
        INPUT                         = xseq
      RECEIVING
        CONV                          = conv.
    CALL METHOD conv->READ
      EXPORTING
        N                             = 1
      IMPORTING
        DATA                          = char.
 CATCH: CX_SY_CONVERSION_CODEPAGE,
        CX_SY_CODEPAGE_CONVERTER_INIT,
        CX_PARAMETER_INVALID_TYPE;
        CX_PARAMETER_INVALID_RANGE.
ENDTRY.
5 REPLIES 5

Ryan-Crosby
Active Contributor
0 Kudos

Hi Minjae,

I think what you are looking for is something like FM 'SCMS_XSTRING_TO_STRING' or class 'CL_BCS_CONVERT'.

Regards,

Ryan Crosby

0 Kudos

HI Ryan,

thank you for your comment but the FM only be allowed is CL_ABAP_CHAR_UTILITIES..

regards.

0 Kudos

Then you will be stuck with type X for your output.

raymond_giuseppi
Active Contributor

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB is not a method but a class attribute of the class (constant).

  • Could you reformulate your question, explain the initial requirement
  • Did you look at other similar constants defined in the class such as VERTICAL_TAB, NEWLINE, CR_LF, FORM_FEED or BACKSPACE (with SE24 or SE80)

Would you require a class to do the job of hex to char conversion, look at this small sample

DATA conv Type Ref To CL_ABAP_CONV_IN_CE.
TRY.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
      EXPORTING
        ENCODING                      = 'UTF-8' 
        INPUT                         = xseq
      RECEIVING
        CONV                          = conv.
    CALL METHOD conv->READ
      EXPORTING
        N                             = 1
      IMPORTING
        DATA                          = char.
 CATCH: CX_SY_CONVERSION_CODEPAGE,
        CX_SY_CODEPAGE_CONVERTER_INIT,
        CX_PARAMETER_INVALID_TYPE;
        CX_PARAMETER_INVALID_RANGE.
ENDTRY.

0 Kudos

Hi, Raymond.

Thank you very much showing the class with sample!

It is working and if i can't solve with class CL_ABAP_CHAR_UTILITIES, i would try with class you teached to me instead of CL_ABAP_CHAR_UTILITIES.

thank you very much!