<?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: Silly question: Compare String with Integer in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676985#M2016699</link>
    <description>&lt;P&gt;Thanks for answer. I didnt see any trailing space in the debugger... but it seems that there are one space ... &lt;/P&gt;&lt;P&gt;Why is added this space ??&lt;BR /&gt;&lt;BR /&gt;with condense no-gaps is working fine now.&lt;BR /&gt;I cannot use your solution because in my real program the string2 not always contain a number... I can use CS '01234... by the moment i can continue with this, thaks&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2023 14:34:14 GMT</pubDate>
    <dc:creator>oliver_am</dc:creator>
    <dc:date>2023-01-11T14:34:14Z</dc:date>
    <item>
      <title>Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676979#M2016693</link>
      <description>&lt;P&gt;Hello, Ok, I know this is a really newbie question but I cannot find a solution...&lt;BR /&gt;&lt;BR /&gt;Why this code is returning false?&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;REPORT ztest.

DATA:
  string1 TYPE string,
  string2 TYPE string,
  integer TYPE int4 VALUE '15'.

string1 = '15'.
string2 = integer.

IF string1 = string2. "integer
  WRITE: 'True'.
ELSE.
  WRITE: 'False'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I need to compare a value in a string with the same value in an integer... &lt;BR /&gt;&lt;BR /&gt;SAP_ABAP 701 cannot use any new features of abap syntaxis... (conv,etc...)&lt;BR /&gt;&lt;BR /&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 12:09:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676979#M2016693</guid>
      <dc:creator>oliver_am</dc:creator>
      <dc:date>2023-01-11T12:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676980#M2016694</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;oliver.am&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;What is the value in the variable "string2" at runtime?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 12:34:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676980#M2016694</guid>
      <dc:creator>AndyBoolean</dc:creator>
      <dc:date>2023-01-11T12:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676981#M2016695</link>
      <description>&lt;P&gt;This values&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2125491-imagen.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 12:38:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676981#M2016695</guid>
      <dc:creator>oliver_am</dc:creator>
      <dc:date>2023-01-11T12:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676982#M2016696</link>
      <description>&lt;P&gt;Hello &lt;SPAN class="mention-scrubbed"&gt;oliver.am&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Check the report under debugger and examine the values of STRING1 and STRING2 variables. It's evident why the comparison yields FALSE:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2127486-image.png" /&gt;&lt;/P&gt;&lt;P&gt;STRING2 is 3 chars long and differs from STRING1 by the trailing SPACE.&lt;/P&gt;&lt;P&gt;Why don't you compare integers instead of strings, e.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
  string TYPE string,
  integer1 TYPE int4 VALUE '15',
  integer2 type int4.

string = '15'.
CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 1.
  integer2 = string.
ENDCATCH.

IF integer1 = integer2 and sy-subrc &amp;lt;&amp;gt; 1. "integer
  WRITE: 'True'.
ELSE.
  WRITE: 'False'.
ENDIF.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Dominik Tylczynski&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 12:38:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676982#M2016696</guid>
      <dc:creator>Dominik_Tylczynski</dc:creator>
      <dc:date>2023-01-11T12:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676983#M2016697</link>
      <description>&lt;P&gt;Strings containing numbers may be formatted different. ABAP puts the sign of an integer as additional character at the end of the text when converting integers to text. A string will keep this space character so you are comparing '15' and '15 ' which is not the same.&lt;/P&gt;&lt;P&gt;I would always use a number conversion when treating strings as integers such as&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;try.
  if conv i( string1 ) = conv i( string2 ).

(...)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2023 13:20:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676983#M2016697</guid>
      <dc:creator>jrgkraus</dc:creator>
      <dc:date>2023-01-11T13:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676984#M2016698</link>
      <description>&lt;P&gt;Two variables can be compared directly. This code returns 'True':&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF string1 = integer.
  WRITE: 'True'.
ELSE.
  WRITE: 'False'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you need to compare two strings, you could add CONDENSE to trim a trailing space.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CONDENSE string2.
IF string1 = string2. "integer
  WRITE: 'True'.
ELSE.
  WRITE: 'False'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;An assignment integer values to stings always uses the commercial notation. That is why an to assign and compare is not the same as to compare with an implicit conversion:&lt;/P&gt;... "The value of the integer is formatted in commercial notation and passed, without gaps and without decimal separators, to the target field. The character "-" is set in the last place for a negative value and a blank is set for a positive value. The resulting length of the target field is determined by the number of digits plus the place for the sign." ...</description>
      <pubDate>Wed, 11 Jan 2023 13:27:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676984#M2016698</guid>
      <dc:creator>touzik_itc</dc:creator>
      <dc:date>2023-01-11T13:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676985#M2016699</link>
      <description>&lt;P&gt;Thanks for answer. I didnt see any trailing space in the debugger... but it seems that there are one space ... &lt;/P&gt;&lt;P&gt;Why is added this space ??&lt;BR /&gt;&lt;BR /&gt;with condense no-gaps is working fine now.&lt;BR /&gt;I cannot use your solution because in my real program the string2 not always contain a number... I can use CS '01234... by the moment i can continue with this, thaks&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 14:34:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676985#M2016699</guid>
      <dc:creator>oliver_am</dc:creator>
      <dc:date>2023-01-11T14:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676986#M2016700</link>
      <description>&lt;P&gt;You can find the conversion rule in the Abap online documentation, here: numeric to character type fields: &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenconversion_type_ibs.htm#@@ITOC@@ABENCONVERSION_TYPE_IBS_2"&gt;Character-Like Target Fields&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 16:54:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676986#M2016700</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2023-01-11T16:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Silly question: Compare String with Integer</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676987#M2016701</link>
      <description>&lt;P&gt;Next to converting into integer you might convert into correct string:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;string1 = '15'.&lt;BR /&gt;string2 = condense( string1 ).&lt;BR /&gt;IF string1 = string2. "integer&lt;BR /&gt;  WRITE: 'True'.&lt;BR /&gt;ELSE.&lt;BR /&gt;  WRITE: 'False'.&lt;BR /&gt;ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 04:58:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/silly-question-compare-string-with-integer/m-p/12676987#M2016701</guid>
      <dc:creator>JackGraus</dc:creator>
      <dc:date>2023-02-07T04:58:06Z</dc:date>
    </item>
  </channel>
</rss>

