<?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: 'SWA_STRING_SPLIT' splitting problem. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666761#M2016057</link>
    <description>&lt;P&gt;I don't know the goal of the function module SWA_STRING_SPLIT so I can't answer for it.&lt;/P&gt;&lt;P&gt;If you want to split at exactly 128 characters without any other rule, you may use SWA_STRING_TO_TABLE (among probably many others), .&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data itab2 type table of text128.
data(xml_out) = `jfjk  fkf  ...`.
CALL FUNCTION 'SWA_STRING_TO_TABLE'
     EXPORTING
          CHARACTER_STRING = XML_OUT
     IMPORTING
          CHARACTER_TABLE  = ITAB2.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Jan 2023 21:38:00 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-01-04T21:38:00Z</dc:date>
    <item>
      <title>'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666760#M2016056</link>
      <description>&lt;P&gt;I'm using the FM 'SWA_STRING_SPLIT' to split a string of 255.&lt;BR /&gt;While debugging I noticed that it doesn't split at the maximum of length that I gave, but instead like in the screenshot I attached.&lt;BR /&gt;What I'm trying to do is to split the first part when reach length 128 (the limit length of ALV) and insert it into field HEADER1, and the rest of the string into field HEADER1_SPLIT.&lt;BR /&gt;&lt;BR /&gt;I can actually add another field to show the rest of the string, but I prefer to keep just 2. &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2123001-image.png" /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;LOOP AT gt_out.&lt;BR /&gt;    CALL FUNCTION 'SWA_STRING_SPLIT'&lt;BR /&gt;      EXPORTING&lt;BR /&gt;        input_string                 = lv_testo1&lt;BR /&gt;        max_component_length         = 128&lt;BR /&gt;*       TERMINATING_SEPARATORS       =&lt;BR /&gt;*       OPENING_SEPARATORS           =&lt;BR /&gt;      TABLES&lt;BR /&gt;        string_components            = it_split1&lt;BR /&gt;      EXCEPTIONS&lt;BR /&gt;        max_component_length_invalid = 1&lt;BR /&gt;        OTHERS                       = 2.&lt;BR /&gt;    IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;*   Implement suitable error handling here&lt;BR /&gt;    ENDIF.&lt;BR /&gt;&lt;BR /&gt;    LOOP AT it_split1.&lt;BR /&gt;      READ TABLE it_split1 INDEX 1.&lt;BR /&gt;      IF sy-subrc IS INITIAL.&lt;BR /&gt;        gt_out-header1 = it_split1-str.&lt;BR /&gt;      ENDIF.&lt;BR /&gt;&lt;BR /&gt;      READ TABLE it_split1 INDEX 2.&lt;BR /&gt;      IF sy-subrc IS INITIAL.&lt;BR /&gt;        gt_out-header1_split = it_split1-str.&lt;BR /&gt;      ENDIF.&lt;BR /&gt;&lt;BR /&gt;    ENDLOOP.&lt;BR /&gt;*&lt;BR /&gt;    MODIFY gt_out.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 18:33:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666760#M2016056</guid>
      <dc:creator>zhlish</dc:creator>
      <dc:date>2023-01-04T18:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: 'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666761#M2016057</link>
      <description>&lt;P&gt;I don't know the goal of the function module SWA_STRING_SPLIT so I can't answer for it.&lt;/P&gt;&lt;P&gt;If you want to split at exactly 128 characters without any other rule, you may use SWA_STRING_TO_TABLE (among probably many others), .&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data itab2 type table of text128.
data(xml_out) = `jfjk  fkf  ...`.
CALL FUNCTION 'SWA_STRING_TO_TABLE'
     EXPORTING
          CHARACTER_STRING = XML_OUT
     IMPORTING
          CHARACTER_TABLE  = ITAB2.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Jan 2023 21:38:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666761#M2016057</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-01-04T21:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: 'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666762#M2016058</link>
      <description>&lt;P&gt;Hi Sandra, &lt;BR /&gt;this fm will just cut at exatly 128 characters, but I still need the remaining of the string, so instead of cut I need to split in 2 parts that don't exceed 128 characters each&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 07:59:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666762#M2016058</guid>
      <dc:creator>zhlish</dc:creator>
      <dc:date>2023-01-05T07:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: 'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666763#M2016059</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;DATA long TYPE c LENGTH 255.
DATA first_128 TYPE c LENGTH 128.&amp;lt;br&amp;gt;DATA rest TYPE c LENGTH 127.
first_128 = long.
rest = long+128.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why use a FM?&lt;/P&gt;&lt;P&gt;Or if they're all strings.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA long TYPE string.
DATA first_128 TYPE string.
DATA rest TYPE string.
first_128 = long(128).
rest = long+128.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or you can use string functions&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA long TYPE string.
DATA first_128 TYPE string.
DATA rest TYPE string.
first_128 = substring( val = long len = 128 ).
rest = substring( val = long off = 128 ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Of course you must do additional work to cater for &lt;STRONG&gt;long&lt;/STRONG&gt; being less than or equal 128 characters long. You can use &lt;STRONG&gt;strlen &lt;/STRONG&gt;for this.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 08:35:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666763#M2016059</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2023-01-05T08:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: 'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666764#M2016060</link>
      <description>&lt;P&gt;sorry, I mean "split", not "cut". It will split into one or many lines.&lt;/P&gt;&lt;P&gt;Answer edited.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 08:47:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666764#M2016060</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-01-05T08:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: 'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666765#M2016061</link>
      <description>&lt;P&gt;What a simple solution, I had focused  so much on this FM and the reason why it doesn't work that I completely forgot about the offset.. &lt;BR /&gt;&lt;BR /&gt;Now  the problem is resolved, but I still don't understand why this FM doesn't fill the maximum component I gave and then split, but instead cut off before it reach that length.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 09:40:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666765#M2016061</guid>
      <dc:creator>zhlish</dc:creator>
      <dc:date>2023-01-05T09:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: 'SWA_STRING_SPLIT' splitting problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666766#M2016062</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;zhlish&lt;/SPAN&gt; That's the problem to use unreleased and undocumented function modules, you don't know what they do, and there is the risk that they are changed or removed in any release.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 10:08:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/swa-string-split-splitting-problem/m-p/12666766#M2016062</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-01-05T10:08:24Z</dc:date>
    </item>
  </channel>
</rss>

