<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to split string to itab without remove character in string. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341391#M1992147</link>
    <description>&lt;P&gt;Since I discovered that ST transformations were much faster than ABAP (of course, we can see the difference only with high volume), I always use them:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : response_json TYPE string VALUE '[{"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"},{"success":"true","msg":" valid","matnr":"PH X 15","matkl":"123433"}]'.
TYPES : BEGIN OF ty_response_line,
          success TYPE string,
          msg     TYPE string,
          matnr   TYPE string,
          matkl   TYPE string,
        END OF ty_response_line,
        ty_response TYPE STANDARD TABLE OF ty_response_line WITH EMPTY KEY.
DATA response TYPE ty_response.
CALL TRANSFORMATION zst SOURCE XML response_json RESULT abapitab = response.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ZST transfo:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ABAPITAB"/&amp;gt;
  &amp;lt;tt:template extensible="deep-dynamic"&amp;gt;
    &amp;lt;array&amp;gt;
      &amp;lt;tt:loop ref="ABAPITAB"&amp;gt;
        &amp;lt;object&amp;gt;
          &amp;lt;tt:group&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="success" tt:value-ref="SUCCESS"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="msg" tt:value-ref="MSG"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="matnr" tt:value-ref="MATNR"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="matkl" tt:value-ref="MATKL"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
          &amp;lt;/tt:group&amp;gt;
        &amp;lt;/object&amp;gt;
      &amp;lt;/tt:loop&amp;gt;
    &amp;lt;/array&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Feb 2021 12:27:34 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2021-02-04T12:27:34Z</dc:date>
    <item>
      <title>How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341388#M1992144</link>
      <description>&lt;P&gt;Hi Expert,&lt;/P&gt;
  &lt;P&gt;Please let me know if it possible split string to itab without removing character in string ?&lt;/P&gt;
  &lt;P&gt;i have variable like this,&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;DATA : response     TYPE string VALUE '{"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"},{"success":"true","msg":" valid","matnr":"PH X 15","matkl":"123433"}',&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;and then i do split,&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt; SPLIT response AT '},' INTO TABLE DATA(lv_line).

    LOOP AT lv_line INTO ls_line.
      CALL METHOD cl_fdt_json=&amp;gt;json_to_data
        EXPORTING
          iv_json = ls_line
        CHANGING
          ca_data = ls_data_json.

      APPEND ls_data_json TO lt_data_json.
    ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;when i using cl_fdt_json , field matkl at first row is initial.&lt;BR /&gt;because the value string as be : {"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489".&lt;/P&gt;
  &lt;P&gt;but i need value as be : {"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"} &amp;lt;--&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 08:37:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341388#M1992144</guid>
      <dc:creator>jandrivay</dc:creator>
      <dc:date>2021-02-04T08:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341389#M1992145</link>
      <description>&lt;P&gt;Hello  &lt;SPAN class="mention-scrubbed"&gt;jandrivay&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;The separator is ignored in the results. Since you're using the } as a part of the separator it is removed. You could append it to the end of the line before parsing the JSON.&lt;/P&gt;Kind regards,&lt;BR /&gt;Mateusz</description>
      <pubDate>Thu, 04 Feb 2021 08:47:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341389#M1992145</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2021-02-04T08:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341390#M1992146</link>
      <description>&lt;P&gt;You could just replace the "},{"-part(s) of the [response]-string by "}#{", and then SPLIT .. AT '#'.. &lt;/P&gt;&lt;P&gt;That way the only character that gets removed by the SPLIT keyword is the character you don't want.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 09:12:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341390#M1992146</guid>
      <dc:creator>Patrick_vN</dc:creator>
      <dc:date>2021-02-04T09:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341391#M1992147</link>
      <description>&lt;P&gt;Since I discovered that ST transformations were much faster than ABAP (of course, we can see the difference only with high volume), I always use them:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : response_json TYPE string VALUE '[{"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"},{"success":"true","msg":" valid","matnr":"PH X 15","matkl":"123433"}]'.
TYPES : BEGIN OF ty_response_line,
          success TYPE string,
          msg     TYPE string,
          matnr   TYPE string,
          matkl   TYPE string,
        END OF ty_response_line,
        ty_response TYPE STANDARD TABLE OF ty_response_line WITH EMPTY KEY.
DATA response TYPE ty_response.
CALL TRANSFORMATION zst SOURCE XML response_json RESULT abapitab = response.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ZST transfo:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform xmlns:tt="http://www.sap.com/transformation-templates"&amp;gt;
  &amp;lt;tt:root name="ABAPITAB"/&amp;gt;
  &amp;lt;tt:template extensible="deep-dynamic"&amp;gt;
    &amp;lt;array&amp;gt;
      &amp;lt;tt:loop ref="ABAPITAB"&amp;gt;
        &amp;lt;object&amp;gt;
          &amp;lt;tt:group&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="success" tt:value-ref="SUCCESS"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="msg" tt:value-ref="MSG"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="matnr" tt:value-ref="MATNR"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
            &amp;lt;tt:cond frq="?"&amp;gt;
              &amp;lt;str name="matkl" tt:value-ref="MATKL"/&amp;gt;
            &amp;lt;/tt:cond&amp;gt;
          &amp;lt;/tt:group&amp;gt;
        &amp;lt;/object&amp;gt;
      &amp;lt;/tt:loop&amp;gt;
    &amp;lt;/array&amp;gt;
  &amp;lt;/tt:template&amp;gt;
&amp;lt;/tt:transform&amp;gt;&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Feb 2021 12:27:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341391#M1992147</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-02-04T12:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341392#M1992148</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; TYPES : BEGIN OF ty_data,
            success TYPE    string,
            msg     TYPE    string,
            matnr   TYPE    matnr,
            matkl   TYPE    matkl,
          END OF ty_data.

DATA : ls_data TYPE ty_data.
lt_data TYPE STANDARD TABLE OF ty_data.

DATA : lv_response     TYPE string VALUE '[{"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"},{"success":"true","msg":" valid","matnr":"PH X 15","matkl":"123433"}]',
  /ui2/cl_json=&amp;gt;deserialize( EXPORTING json = lv_response
                                       pretty_name = /ui2/cl_json=&amp;gt;pretty_mode-camel_case
CHANGING  data = lt_data ).
             &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;your string data is is json data so you can use json deserialize method.&lt;/P&gt;&lt;P&gt;After the deserialize your internal table wil be like this.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1880723-exportdata.png" /&gt;        &lt;/P&gt;&lt;P&gt;If you need json data you can use serialize method&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DELETE lt_data2 INDEX 1.

/ui2/cl_json=&amp;gt;serialize( EXPORTING data = lt_data RECEIVING r_json = DATA(r_json) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:23:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341392#M1992148</guid>
      <dc:creator>former_member532216</dc:creator>
      <dc:date>2021-02-04T14:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341393#M1992149</link>
      <description>&lt;P&gt;I like that there are so many solutions here... I'll add another based on FIND and REGEX, just for fun.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA response TYPE string.
DATA json_table TYPE STANDARD TABLE OF string WITH EMPTY KEY.
response = '{"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"},{"success":"true","msg":" valid","matnr":"PH X 15","matkl":"123433"}'.

FIND ALL OCCURRENCES OF REGEX '(\{[^\}]*\})' IN response RESULTS DATA(result_table).
LOOP AT result_table ASSIGNING FIELD-SYMBOL(&amp;lt;result_line&amp;gt;).
  INSERT
    substring( val = response off = &amp;lt;result_line&amp;gt;-submatches[ 1 ]-offset len = &amp;lt;result_line&amp;gt;-submatches[ 1 ]-length )
  INTO TABLE json_table.
ENDLOOP.
out-&amp;gt;write( json_table ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Remember, you can almost always use regular expression to make things a bit harder to read. This thing works, but the other solutions are better... Son't use this one if you want readable code. (But if you do, catch the CX_SY_ITAB_LINE_NOT_FOUND exception for good measure... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 15:02:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341393#M1992149</guid>
      <dc:creator>joltdx</dc:creator>
      <dc:date>2021-02-04T15:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341394#M1992150</link>
      <description>&lt;P&gt;NEVER use "regular expressions" and "fun" in the same sentence unless "not" is in there somewhere! hahaha&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 15:38:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341394#M1992150</guid>
      <dc:creator>ChrisSolomon</dc:creator>
      <dc:date>2021-02-04T15:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341395#M1992151</link>
      <description>&lt;P&gt;Too funny.....and timely! Literally using this this morning for another need. haha &lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 15:39:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341395#M1992151</guid>
      <dc:creator>ChrisSolomon</dc:creator>
      <dc:date>2021-02-04T15:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341396#M1992152</link>
      <description>&lt;P&gt;Hahaha ¯\_(ツ)_/¯&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 16:40:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341396#M1992152</guid>
      <dc:creator>joltdx</dc:creator>
      <dc:date>2021-02-04T16:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to split string to itab without remove character in string.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341397#M1992153</link>
      <description>&lt;P&gt;Hi, Hasan.&lt;BR /&gt;&lt;BR /&gt;Thanks for your comment, my problem solved. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 02:44:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-split-string-to-itab-without-remove-character-in-string/m-p/12341397#M1992153</guid>
      <dc:creator>jandrivay</dc:creator>
      <dc:date>2021-02-05T02:44:42Z</dc:date>
    </item>
  </channel>
</rss>

