cancel
Showing results for 
Search instead for 
Did you mean: 

ECATT_CONV_XSTRING_TO_STRING

Former Member
0 Kudos

Hello Friend,

I need to convert xString to String and I am planning to use ECATT_CONV_XSTRING_TO_STRING but the output for the functional module is of type string with 255 as a length.

what would happen if my input is longer than 255?

I have tested for couple of cases and found that my input got truncated to 255 chars.

Does anyone had any idea on this or any other alternative

Accepted Solutions (0)

Answers (1)

Answers (1)

udo_martens
Active Contributor
0 Kudos

Hi Pranav,

i dont think so. Just the test field has 255.

check out this report:

data:
int type i,
chr type string,
str type string,
xstr type xstring.

do 300 times.
  int = int + 1.
  chr = int.
  concatenate
    chr
    str
  into
    str.
enddo.

CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
  EXPORTING
    im_xstring        = xstr
   IM_ENCODING       = 'UTF-8'
 IMPORTING
   EX_STRING         = str
          .
  write str+300(10)  

It must dump if str is less than 255.

Regards,

Udo

Former Member
0 Kudos

Hi Udo,

I believe in your code xstr and str has been swapped because you are filling the value in str and hence str should be there with the exporting parameter.

Correct me if I am going wrong .

When I changed the call as follows :

<b>CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'

EXPORTING

im_xstring = str

IM_ENCODING = 'UTF-8'

IMPORTING

EX_STRING = xstr</b>

I got a program dump with an error as follows CALL_FUNCTION_CONFLICT_TYPE.

Thanks

Former Member
0 Kudos

HI Udo,

The most weird behavior I see while debugging the code the ECATT_CONV_XSTRING_TO_STRING is

The return<b> "ex_string"</b> has following vales

<u>technical type </u>= CString and the<u> value </u>contains the 255 char string

<u> technical type</u> = CString and the<u> value</u> contains the 255 char string

<u> technical type</u> = CString and the <u>value</u> contains the 255 char string

Why does the technical size doesn't affect the value string length ?

Seems that I have wrong understanding of the functional module.

Can anyone uncover the hidden portion of the functional module?

<b></b>

udo_martens
Active Contributor
0 Kudos

Hi PD,

no, fm imports xstring and export string. You see it at the dump.

Regards,

Udo

udo_martens
Active Contributor
0 Kudos

Hi PD,

why do you debug SAP fms? They are encapsulated, a common principle in software development. Just use them. It can convert XSTRING to STRING, both can be as long as you like. No restrictions to 255.

Regards,

Udo

Former Member
0 Kudos

thanks Udo for your response.

I was not debugging the standard FM but I was debugging my code wherein I have used the ECATT_CONV_XSTRING_TO_STRING functional module.

Well the fm takes XSTRING and returns STRING.

In the given example you have added values to the variable String str and xstr is empty when you are calling the functional module.

I think we need to fill the xstr and the fm would return the values in the str...

Correct me, if I am going in the wrong direction.

udo_martens
Active Contributor
0 Kudos

Hi PD,

had to change the code:

data:
int type i,
chr type string,
str type string,
xstr type ETXML_LINE_STR.

*create a long string
do 300 times.
  int = int + 1.
  chr = int.
  concatenate
    chr
    str
  into
    str.
enddo.

*convert to Xstring
CALL FUNCTION 'ECATT_CONV_STRING_TO_XSTRING'
  EXPORTING
    im_string         = str
   IM_ENCODING       = 'UTF-8'
 IMPORTING
   EX_XSTRING        = xstr.

*convert to string
CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
  EXPORTING
    im_xstring        = xstr
   IM_ENCODING       = 'UTF-8'
 IMPORTING
   EX_STRING         = str.

*offsett of 300 would dump if output only 255
write: sy-subrc, str+300(10).

Everything should be clear. XSTRING is created and longer as 255, as well the STRING. Program would dump in case of string less than 255.

Regards,

Udo