<?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: Concatenating strings within REDUCE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705469#M32309</link>
    <description>&lt;P&gt;Like Home says : Ouch !!&lt;BR /&gt;You know the copy paste syndrome... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By now you have already guessed it, but what about:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NEXT lv_where_clause = lv_where_clause &amp;amp;&amp;amp; ',' &amp;amp;&amp;amp; ls_werks-low &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;J.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Nov 2018 15:28:05 GMT</pubDate>
    <dc:creator>Jean_Sagi</dc:creator>
    <dc:date>2018-11-27T15:28:05Z</dc:date>
    <item>
      <title>Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705466#M32306</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I'm trying to use new syntax provided by 7.4 and later versions&lt;/P&gt;
  &lt;P&gt;My requirement is to concatenate the fields of one internal table into a string.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA(lv_text) = REDUCE string( INIT lv_where_clause TYPE string
                           FOR ls_werks  IN lt_werks
                           NEXT lv_where_clause = lv_where_clause &amp;amp;&amp;amp; ls_werks-low &amp;amp;&amp;amp; ',' ).&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This will replace the loop on the internal table with concatenation at each step.&lt;/P&gt;
  &lt;P&gt;My problem with reduce is how to get rid of the last comma?&lt;/P&gt;
  &lt;P&gt;Many Thanks.&lt;/P&gt;
  &lt;P&gt;Moez.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 14:17:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705466#M32306</guid>
      <dc:creator>BTP_Architect</dc:creator>
      <dc:date>2018-11-27T14:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705467#M32307</link>
      <description>&lt;P&gt;What about:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NEXT lv_where_clause =  ',' &amp;amp;&amp;amp; lv_where_clause &amp;amp;&amp;amp; ls_werks-low &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That way you'll end with a first comma instead of a last comma. So get rid of the first character instead of the last one.&lt;/P&gt;&lt;P&gt;Last but not least the lv_where_clause will be a string of the form 1000,2000,3000... (Assuming your logistic centers are 1000,2000,3000, etc...) this seems to me not a proper way to a where clause. Shouldn't it be something like "1000","2000","3000",... ?&lt;/P&gt;&lt;P&gt;J.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 15:01:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705467#M32307</guid>
      <dc:creator>Jean_Sagi</dc:creator>
      <dc:date>2018-11-27T15:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705468#M32308</link>
      <description>&lt;P&gt;Thanks Jesus for your feedback&lt;/P&gt;&lt;P&gt;Your proposal will give something like: ,,,100020003000 (all comma in the beginning)&lt;/P&gt;&lt;P&gt;They should be separated by comma.&lt;/P&gt;&lt;P&gt;For the lv_where_clause, yes I need it without double quotation marks for further processing...&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 15:15:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705468#M32308</guid>
      <dc:creator>BTP_Architect</dc:creator>
      <dc:date>2018-11-27T15:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705469#M32309</link>
      <description>&lt;P&gt;Like Home says : Ouch !!&lt;BR /&gt;You know the copy paste syndrome... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By now you have already guessed it, but what about:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NEXT lv_where_clause = lv_where_clause &amp;amp;&amp;amp; ',' &amp;amp;&amp;amp; ls_werks-low &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;J.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 15:28:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705469#M32309</guid>
      <dc:creator>Jean_Sagi</dc:creator>
      <dc:date>2018-11-27T15:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705470#M32310</link>
      <description>&lt;P&gt;Yes you are right, by this way I will have the comma as first character and remove it using the shift&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SHIFT lv_text BY 1 PLACES LEFT.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In my first coding it was also possible to remove the last comma using SHIFT.&lt;/P&gt;&lt;P&gt;But my question was more about the REDUCE and if there is a way to manage such concatenation within REDUCE (without adding any other instruction like SHIFT).&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 15:50:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705470#M32310</guid>
      <dc:creator>BTP_Architect</dc:creator>
      <dc:date>2018-11-27T15:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705471#M32311</link>
      <description>&lt;P&gt;Yep. That's though !.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 15:59:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705471#M32311</guid>
      <dc:creator>Jean_Sagi</dc:creator>
      <dc:date>2018-11-27T15:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705472#M32312</link>
      <description>&lt;P&gt;i suggest using condition to check if its last record, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lv_text) = REDUCE string( INIT lv_where_clause TYPE string&lt;BR /&gt;  FOR i = 1 UNTIL i = lines( lt_werks )&lt;BR /&gt;  NEXT lv_where_clause = COND #( WHEN i &amp;lt; lines( lt_werks ) THEN lv_where_clause &amp;amp;&amp;amp; lt_werks[ i ]-low &amp;amp;&amp;amp; ',' &lt;BR /&gt;  ELSE lv_where_clause &amp;amp;&amp;amp; lt_werks[ i ]-low ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Nov 2018 02:39:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705472#M32312</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2018-11-28T02:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705473#M32313</link>
      <description>&lt;P&gt;When I needed to do this, I used the example in the documentation. &lt;A href="https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenreduce_text_abexa.htm" target="test_blank"&gt;https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenreduce_text_abexa.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;The simplest thing is to use an extra variable. Excuse the renaming of your variable, but I detest prefexing to indicate variable type.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(text) = REDUCE string( INIT where_clause = '' sep = ''
                           FOR werk_range_line IN werk_selection
                           NEXT where_clause = where_clause &amp;amp;&amp;amp; sep &amp;amp;&amp;amp; werk_range-low
                                sep = ',' ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Nov 2018 09:43:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705473#M32313</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-11-28T09:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705474#M32314</link>
      <description>&lt;P&gt;Thanks Matthew&lt;/P&gt;&lt;P&gt;This is what I was searching for&lt;/P&gt;&lt;P&gt;I just changed the initialization of the where_clause (I exchanged where_clause = ' ' by where_clause type string)&lt;/P&gt;&lt;P&gt;Otherwise the text will be on one character...&lt;/P&gt;&lt;P&gt;Final solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(text) = REDUCE string( INIT where_clause TYPE string sep = ''
                           FOR werk_range_line IN werk_selection
                           NEXT where_clause = where_clause &amp;amp;&amp;amp; sep &amp;amp;&amp;amp; werk_range-low
                                sep = ',' ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Nov 2018 12:50:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705474#M32314</guid>
      <dc:creator>BTP_Architect</dc:creator>
      <dc:date>2018-11-28T12:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating strings within REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705475#M32315</link>
      <description>&lt;P&gt;Try using | as in the SAP example.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 02:30:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-strings-within-reduce/m-p/705475#M32315</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-11-29T02:30:13Z</dc:date>
    </item>
  </channel>
</rss>

