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

string to xstring

Former Member
0 Likes
2,459

Hello,

I will convert a xstring into a string. But I receive a runtime error (CX_SY_DYN_CALL_ILLEGAL_TYPE).

What did I wrong?


REPORT  Z_TEST.

  DATA:
    STRING(255) TYPE C,
    XSTRING TYPE XSTRING.

    MOVE '1abd19bb' TO XSTRING.

CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
  EXPORTING
*   FROM_CODEPAGE       = '8500'
    IN_XSTRING          = XSTRING
*   OUT_LEN             =
  IMPORTING
    OUT_STRING          = STRING.

WRITE: / ' STRING: ', STRING.

8 REPLIES 8
Read only

Former Member
0 Likes
1,824

i think...

problem is the function module is expecting an internal table as parameter and you are sending it a variable.

Read only

anversha_s
Active Contributor
0 Likes
1,824

hi,

chk this.

DATA:

<b> out_STRING TYPE STRING,

in_STRING TYPE XSTRING.</b>

MOVE '1abd19bb' TO IN_STRING.

CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'

EXPORTING

  • FROM_CODEPAGE = '8500'

IN_XSTRING = IN_STRING

  • OUT_LEN =

IMPORTING

OUT_STRING = OUT_STRING.

WRITE: / ' STRING: ', OUT_STRING.

rgds

anver

Read only

Former Member
0 Likes
1,824

check ot the declarations for XSTRING and STRING in the fumction module and declate the same in program

Read only

0 Likes
1,824

Now I have a internal table, but the same error...

What can I do? I only will convert a xstring in a string...


REPORT  Z_TEST.

  DATA:
    BEGIN OF OUTPUT OCCURS 0,
      OUT_STRING(255) TYPE C,
      IN_STRING TYPE XSTRING,
    END OF OUTPUT.

    MOVE '1abd19bb' TO OUTPUT-IN_STRING.

CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
  EXPORTING
*   FROM_CODEPAGE       = '8500'
    IN_XSTRING          = OUTPUT-IN_STRING
*   OUT_LEN             =
  IMPORTING
    OUT_STRING          = OUTPUT-OUT_STRING.

WRITE: / ' STRING: ', OUTPUT-OUT_STRING.

Read only

0 Likes
1,824

try this one

data: xl_content type xstring .
DATA: binary_content TYPE solix_tab.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = xl_content
TABLES
binary_tab = binary_content.

Read only

Former Member
0 Likes
1,824

Hi

See the below declaration. It should work.

DATA: STRING TYPE string,

Regards

Srikanth M

Read only

0 Likes
1,824

you can use the following code to convert Xstring to String.

DATA: content TYPE STRING,

Xcontent TYPE XSTRING .

DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.

conv = CL_ABAP_CONV_IN_CE=>CREATE( input = Xcontent ).

conv->READ( importing data = content ).

Regards

Raja

Read only

robinthakral
Participant
0 Likes
1,824
You can refer to below class-method set to convert instead of using unreleased FMs.
*&---------------------------------------------------------------------*
*&    " Convert XString to String
*&---------------------------------------------------------------------*
DATA: lv_string TYPE string,
      lv_xstring TYPE xstring.

DATA: lo_conv_in TYPE REF TO CL_ABAP_CONV_IN_CE.

lo_conv_in = CL_ABAP_CONV_IN_CE=>CREATE( input = lv_xstring ).
lo_conv_in->READ( IMPORTING data = lv_string ).
*&---------------------------------------------------------------------*
*&    " Convert String to XString
*&---------------------------------------------------------------------*
DATA: lo_conv TYPE REF TO cl_abap_conv_out_ce.

lo_conv = cl_abap_conv_out_ce=>create( encoding = '4110' ).
lo_conv->convert( EXPORTING data   = lv_string
                  IMPORTING buffer = lv_xstring ).
*&---------------------------------------------------------------------*
*&    " Convert XString to Binary
*&---------------------------------------------------------------------*
 data: lt_binary_tab     TYPE solix_tab. " table of solix

      CLEAR: lt_binary_tab.
      lt_binary_tab = cl_document_bcs=>xstring_to_solix(
                      ip_xstring = lv_xstring ).
Follow at:
https://www.linkedin.com/in/robinthakral/