<?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 &amp;&amp; operator adding trailing space in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546743#M20563</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; I have used the below chaining operator to prevent the truncation of trailing space while concatenating two variables. It worked for the first part that is it didn't truncate the trailing space after 'Sun ' in the below code snippet as expected but for the second output where there was no trailing space after 'Sun' it actually added a space in the final output which was not expected.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Can you please suggest , how to resolve this? &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; Data : lv_str1 type string,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; lv_str2 type string.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;lv_str1 = 'The Sun '. " Space after Sun&lt;BR /&gt; lv_str2 = 'is shining'.&lt;BR /&gt; WRITE:/ |{ lv_str1 } | &amp;amp;&amp;amp; |{ lv_str2 }|.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; lv_str1 = 'The Sun'. " No space after Sun&lt;BR /&gt; lv_str2 = 'is shining'.&lt;BR /&gt; WRITE:/ |{ lv_str1 } | &amp;amp;&amp;amp; |{ lv_str2 }|.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; Output : &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;The Sun is shining&lt;BR /&gt;The Sun is shining&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2017 09:21:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2017-08-11T09:21:27Z</dc:date>
    <item>
      <title>&amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546743#M20563</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; I have used the below chaining operator to prevent the truncation of trailing space while concatenating two variables. It worked for the first part that is it didn't truncate the trailing space after 'Sun ' in the below code snippet as expected but for the second output where there was no trailing space after 'Sun' it actually added a space in the final output which was not expected.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Can you please suggest , how to resolve this? &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; Data : lv_str1 type string,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; lv_str2 type string.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;lv_str1 = 'The Sun '. " Space after Sun&lt;BR /&gt; lv_str2 = 'is shining'.&lt;BR /&gt; WRITE:/ |{ lv_str1 } | &amp;amp;&amp;amp; |{ lv_str2 }|.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; lv_str1 = 'The Sun'. " No space after Sun&lt;BR /&gt; lv_str2 = 'is shining'.&lt;BR /&gt; WRITE:/ |{ lv_str1 } | &amp;amp;&amp;amp; |{ lv_str2 }|.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; Output : &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;The Sun is shining&lt;BR /&gt;The Sun is shining&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:21:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546743#M20563</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-08-11T09:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546744#M20564</link>
      <description>&lt;P&gt;WRITE:/ |{ lv_str1 } | &amp;amp;&amp;amp; |{ lv_str2 }|.&lt;/P&gt;
  &lt;P&gt;There is a literal blank character between } and |.&lt;/P&gt;
  &lt;P&gt;This is leading to the space in both cases, not the &amp;amp;&amp;amp; !!!&lt;/P&gt;
  &lt;P&gt;Trailing spaces are preserved in string fields and string literals ` ` and in string templates | | and they are cut in text fields and text field literals ' '.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:57:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546744#M20564</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-08-11T09:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546745#M20565</link>
      <description>&lt;P&gt;Ugh... you're mixing techniques and data types in a way that's asking for trouble. &lt;/P&gt;
  &lt;P&gt;CONCATENATE or the &amp;amp;&amp;amp; operator will remove spaces from CHAR-types but not from strings. String templates return strings. &lt;/P&gt;
  &lt;P&gt;Your example puts a char into a string and combines them using a char-type operator. The space you see is the one from your string template (it's easier to see if you post using code formatting!).&lt;/P&gt;
  &lt;P&gt;Either: Use string templates throughout: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;write: / |{ str1 } {str2}|.  "Space&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Or do concatenation: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;write: / str1 &amp;amp;&amp;amp; str2.   "No space here&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;or use strings as your data type:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;data(str1) = `The sun `.
data(str2) = `is shining`.
write: / str1 &amp;amp;&amp;amp; str2.  "Space
write: / |{ str1 } { str2 }|.  "Two spaces
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Aug 2017 10:01:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546745#M20565</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-08-11T10:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546746#M20566</link>
      <description>&lt;P&gt;Sorry I added a literal blank between } and |.That explains the space added between the string.&lt;/P&gt;
  &lt;P&gt;But How do I use `` with variables? The texts that I'm dealing with are dynamic , so I cannot do something like &lt;/P&gt;
  &lt;P&gt; lv_str1 = `The Sun is `. lv_str for me has texts which are dynamic. How do I handle it ?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 18:45:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546746#M20566</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-08-11T18:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546747#M20567</link>
      <description>&lt;P&gt;&lt;/P&gt;
  &lt;P&gt; How do I use `` with variables? The texts that I'm dealing with are dynamic , so I cannot do something like &lt;/P&gt;
  &lt;P&gt; lv_str1 = `The Sun is `. lv_str for me has texts which are dynamic. How do I handle it ?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 18:45:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546747#M20567</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-08-11T18:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546748#M20568</link>
      <description>&lt;P&gt;You handle it the same way as we have been doing with other data type conversions (numc &amp;lt;-&amp;gt; i, dec &amp;lt;-&amp;gt; float, etc.): Just be aware of what data types you're using and their behaviour and limitations. &lt;/P&gt;
  &lt;P&gt;A string has a content length, C doesn't. Therefore during conversion, the length of a C is determined by the last non-blank character. Use/declare appropriate data types. Convert if you have to, using the conv operator. String templates convert everything to strings before performing their operations, CONCATENATE to char.&lt;/P&gt;
  &lt;P&gt;Sorry I don't know what else to add unless you can give me a concrete example.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2017 07:23:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546748#M20568</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-08-12T07:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;&amp; operator adding trailing space</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546749#M20569</link>
      <description>&lt;P&gt;"But How do I use `` with variables?"&lt;/P&gt;
  &lt;P&gt;This question makes no sense.&lt;/P&gt;
  &lt;P&gt;Please make yourself knowledgeable about the concept of literals and variables, about data types in ABAP, and about character processing in ABAP first.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 09:44:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operator-adding-trailing-space/m-p/546749#M20569</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-08-15T09:44:06Z</dc:date>
    </item>
  </channel>
</rss>

