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

Convert xstring to itab

Former Member
0 Likes
2,792

Hello exprts,

can you please tell me a fm which converts a xstring into an itab? I´ve found some, but no one is working in CRM.

In best case, I get a itab with the structure: row and value from the fm!

In row is the row number and in value the cell value.

Thanks in advance!!

Best regdards

Anna

5 REPLIES 5
Read only

Former Member
0 Likes
2,343

perhaps FM: ISM_TRANSFORM_XSTRING_TO_TAB ?

Read only

0 Likes
2,343

Thank you for quick reply, but this fm does not exists in crm...

regards

Anna

Read only

Former Member
0 Likes
2,343

Hi,

Please check these FMs,

ENH_XSTRING_TO_TAB

LXE_COMMON_XSTRING_TO_TABLE

ENH_VERS_MANAGEMNT_XSTRING2TAB

Read only

jitendra_it
Active Contributor
0 Likes
2,343

Hi ,

Use FM SMUM_XML_PARSE.

Please see below code snippet.


DATA :  W_RESULT TYPE STRING,
       BUFFER TYPE XSTRING,
       IT_XML_TABLE  TYPE TABLE OF SMUM_XMLTB,
       wa_XML_TABLE  TYPE  SMUM_XMLTB,
       RETURN  TYPE TABLE OF BAPIRET2.

w_result = '<XmlSetResult><Message>0c2557aa-d37e-44e2-a59e-0e018bede434</Message></XmlSetResult>'.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
 EXPORTING
   text           = w_result
IMPORTING
  buffer          = buffer
EXCEPTIONS
  failed          = 1
  OTHERS          = 2.

IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'SMUM_XML_PARSE'
 EXPORTING
   xml_input = buffer
 TABLES
   xml_table = it_xml_table
   return    = return.


Read only

former_member214857
Contributor
0 Likes
2,343

Hi Anna

You can create your own function and include code below to parse the code

ex_leng = xstrlen( im_xstring ).
l_rest  = ex_leng.

WHILE l_off < ex_leng.

   IF l_rest <= 255.
      l_tl = l_rest.
   ELSE.
      l_tl = 255.
   ENDIF.

   l_hex = im_xstring+l_off(l_tl).
   APPEND l_hex TO ex_data.

   l_act = xstrlen( l_hex ).

   l_rest = l_rest - l_act.
   l_off  = l_off  + l_act.

ENDWHILE.

Best regards