<?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: String comparison in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413042#M1548372</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;string comparison means I think:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If both string have same lenght compare content&lt;/P&gt;&lt;P&gt;2. if not, longer string is "bigger"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so:&lt;/P&gt;&lt;P&gt;       P123 &amp;lt; P0001  - because of lenght&lt;/P&gt;&lt;P&gt;     P0002 &amp;gt; P0001  - because of content&lt;/P&gt;&lt;P&gt;     A0001 &amp;lt; P0002  - because of content&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for reply&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Nov 2010 10:50:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-11-05T10:50:32Z</dc:date>
    <item>
      <title>String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413038#M1548368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to compare two character variables of type CHAR20 in "string  mode" in if condition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;v1 has value P123&lt;/P&gt;&lt;P&gt;v2 has value P00001.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if v1 &amp;gt; v2. &lt;/P&gt;&lt;P&gt; do something.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case if condition should be false. But its true.. How to solve?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for answers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 10:05:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413038#M1548368</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T10:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413039#M1548369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure what you mean with 'string mode'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But.. looking at your example: no way is that ever going to be false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're comparing character values and not numerical values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Maen Anachronos on Nov 5, 2010 11:11 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 10:10:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413039#M1548369</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T10:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413040#M1548370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why should this be false? Do you want to compare the string &lt;EM&gt;length&lt;/EM&gt; ?&lt;/P&gt;&lt;P&gt;If yes, this is very basic, please search for available information.&lt;/P&gt;&lt;P&gt;If not, what do you want, please explain the underlying logic.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 10:11:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413040#M1548370</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-11-05T10:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413041#M1548371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to compare the contents of the two chararcter variables i would suggest moving them to numberic fields and doing a comparison there where relational operators can work with ease.  However if the contents of the character fields contains non-numeric data as well and you know the space occupied by this then you can pass only the numeric data for comparison.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: v1 type char20 value 'P123',
         v2 type char20 value 'P000001',
         val1 type p decimals 2,
         val2 type p decimals 2.

move: v1+1(19) to val1,
           v2+1(19) to val2.
if val1 &amp;gt; val2.
*go to the moon
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Please note you have to have a numeric field which can cater for 19 characters to avoid an over flow&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isaac Prince&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: prince isaac on Nov 5, 2010 12:49 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 10:49:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413041#M1548371</guid>
      <dc:creator>prince_isaac</dc:creator>
      <dc:date>2010-11-05T10:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413042#M1548372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;string comparison means I think:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. If both string have same lenght compare content&lt;/P&gt;&lt;P&gt;2. if not, longer string is "bigger"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so:&lt;/P&gt;&lt;P&gt;       P123 &amp;lt; P0001  - because of lenght&lt;/P&gt;&lt;P&gt;     P0002 &amp;gt; P0001  - because of content&lt;/P&gt;&lt;P&gt;     A0001 &amp;lt; P0002  - because of content&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for reply&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 10:50:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413042#M1548372</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T10:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413043#M1548373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Length comparion: you can solve that pretty easy yourself (hint: STRLEN).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the content comparison: since they are only characters and not numbers my first intention would be to put the two values into an internal table and then sort the internal table ascending (or descending if you choose).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the sort the first entry in your internal table will hold the 'lowest' value and the second enrty will hold the 'highest'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 11:41:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413043#M1548373</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T11:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413044#M1548374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maen,&lt;/P&gt;&lt;P&gt;thanks for reply, but I hope there must be a better solution in ABAP...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 11:53:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413044#M1548374</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T11:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413045#M1548375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is. Convert the values to XSTRING and then your IF comparison will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: gv1 type xstring,
      gv2 type xstring,
      gv3(10) type c,
      gv4(10) type c.

      gv3 = 'P0002'.
      gv4 = 'P0001'.


      CONVERT TEXT gv3 INTO SORTABLE CODE gv1.
      CONVERT TEXT gv4 INTO SORTABLE CODE gv2.

      if gv1 &amp;gt; gv2.
        write: /'GV1 &amp;gt; GV2'.
      elseif gv1 &amp;lt; gv2.
        write: /'GV1 &amp;lt; GV2'.
      else.
        write: /'GV1 = GV2'.
      endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: mind you, this only works if the 2 values have the same length!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Maen Anachronos on Nov 5, 2010 2:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 12:49:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413045#M1548375</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T12:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413046#M1548376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; 1. If both string have same lenght compare content&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just use the comparison operators &amp;lt; (lower than) and &amp;gt; (greater than)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; 2. if not, longer string is "bigger"&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;Length comparion: you can solve that pretty easy yourself (hint: STRLEN).&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/abapdocu_70/en/ABENLOGEXP_ANY_OPERAND.htm" target="test_blank"&gt;http://help.sap.com/abapdocu_70/en/ABENLOGEXP_ANY_OPERAND.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Paulo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 12:52:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413046#M1548376</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T12:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413047#M1548377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; it compares string by position from left:&lt;/P&gt;&lt;P&gt;P123&lt;/P&gt;&lt;P&gt;P00001&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1/First postion V1 = P&lt;/P&gt;&lt;P&gt;                        V2 = P&lt;/P&gt;&lt;P&gt;it is same&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2/Second position: V1 = 1&lt;/P&gt;&lt;P&gt;                               V2 = 0&lt;/P&gt;&lt;P&gt;       V1 &amp;gt; V2 is true for this position&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you would like to compare numbers 123 and 1.&lt;/P&gt;&lt;P&gt;Get rid of characters from you string 'P'&lt;/P&gt;&lt;P&gt;create two integer variables&lt;/P&gt;&lt;P&gt;I1 = v1.&lt;/P&gt;&lt;P&gt;I2 = v2&lt;/P&gt;&lt;P&gt;I1 = 123&lt;/P&gt;&lt;P&gt;I2 = 1&lt;/P&gt;&lt;P&gt;And now when  you compare I1&amp;gt; I2 condition will be false for your example.&lt;/P&gt;&lt;P&gt;Bye Jan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 15:08:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413047#M1548377</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T15:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: String comparison</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413048#M1548378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why don't you give my example a try? You'll see how surprisingly easy it is without all the offsets and other stuff (what if the first char is not a P? what if the string holds P101P101? What if....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I myself was very surprised to find this functionality in ABAP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Nov 2010 15:12:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-comparison/m-p/7413048#M1548378</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-05T15:12:41Z</dc:date>
    </item>
  </channel>
</rss>

