<?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: Problem with if checking in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004950#M1165280</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the SYNTAX-CHECK command. I have constructed this from the ABAP online help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: itab TYPE TABLE OF string,
      mess TYPE string,
      lin  TYPE i,
      wrd  TYPE string,
      dir  TYPE trdir.

APPEND 'PROGRAM dummy.'               TO itab.
APPEND 'DATA a type c.'               TO itab.
APPEND 'DATA b type c.'               TO itab.
APPEND 'IF a GHE b.'                  TO itab.                "example, change as desired
APPEND 'ENDIF.'                       TO itab.

SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd
                 DIRECTORY ENTRY dir.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check SY-SUBRC and the contents of "mess" to find out if your operator is supported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Jan 2009 14:04:00 GMT</pubDate>
    <dc:creator>ThomasZloch</dc:creator>
    <dc:date>2009-01-16T14:04:00Z</dc:date>
    <item>
      <title>Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004944#M1165274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am encountering with a strange problem. I am checking for a relational operator after a 'IF' field. for eg&lt;/P&gt;&lt;P&gt;if a correct.&lt;/P&gt;&lt;P&gt;a jh b -&lt;/P&gt;&lt;HR originaltext="---" /&gt;&lt;P&gt;&amp;gt; incorrect ( because jh is not a relational operator)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is&lt;/P&gt;&lt;P&gt;if not itab-line CA '=,,&amp;lt;,&amp;gt;,&amp;lt;=,&amp;gt;=,eq,ne,lt,gt,le,ge,co,cn,ca,na,cs,ns,cp,np,between,is,in,not'.&lt;/P&gt;&lt;P&gt;RAISE INVALID_IF.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;This code was working fine (raising exception) when I test it with special characters ( !,@,# etc ) but as soon as I tested it with characters it is passing all the test without raising exception for eg&lt;/P&gt;&lt;P&gt;a gth b, c ytl 100 --&amp;gt; it should ideally raise exception as gth,ytl are not relational operator....but still it is passing all the test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What should I use instead of CA??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: priya singh on Jan 16, 2009 1:08 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 12:07:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004944#M1165274</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-16T12:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004945#M1165275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi priya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use contanis pattren 'CP'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it may solve u r pblm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 12:10:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004945#M1165275</guid>
      <dc:creator>tarangini_katta</dc:creator>
      <dc:date>2009-01-16T12:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004946#M1165276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why dont you use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not itab-line CN '=,,&amp;lt;,&amp;gt;,&amp;lt;=,&amp;gt;=,eq,ne,lt,gt,le,ge,co,cn,ca,na,cs,ns,cp,np,between,is,in,not'.&lt;/P&gt;&lt;P&gt;RAISE INVALID_IF.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not itab-line CA '=,,&amp;lt;,&amp;gt;,&amp;lt;=,&amp;gt;=,eq,ne,lt,gt,le,ge,co,cn,ca,na,cs,ns,cp,np,between,is,in,not'.&lt;/P&gt;&lt;P&gt;RAISE INVALID_IF.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madan Mohan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 12:12:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004946#M1165276</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-16T12:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004947#M1165277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Priya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These !,@,#  relational operator is Exception in SAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can simply check this by writing a program for validation, your program will never work for these.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Infact I was searching its answer since long time but did not get any result and conclusion. if you get then please update this thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a Nice Day,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sujeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 13:02:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004947#M1165277</guid>
      <dc:creator>SujeetMishra</dc:creator>
      <dc:date>2009-01-16T13:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004948#M1165278</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;The comparison operators takes into account evn the leading and triling blank values when comparision.&lt;/P&gt;&lt;P&gt;Contains Any: True, if operand1 contains at least one character from operand2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer the below link and choose a suitable operator:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Radhika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 13:19:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004948#M1165278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-16T13:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004949#M1165279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;CA '=,,&amp;lt;,&amp;gt;,&amp;lt;=,&amp;gt;=,eq,ne,lt,gt,le,ge,co,cn,ca,na,cs,ns,cp,np,between,is,in,not'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're making the mistake to assume each operator in '=,,&amp;lt;,&amp;gt;,&amp;lt;=,&amp;gt;=,eq,ne,lt,gt,le,ge,co,cn,ca,na,cs,ns,cp,np,between,is,in,not' is validated, but it's not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, each separate character in that string is checked&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if your string would contain a single character from '=,,&amp;lt;,&amp;gt;,&amp;lt;=,&amp;gt;=,eq,ne,lt,gt,le,ge,co,cn,ca,na,cs,ns,cp,np,between,is,in,not'  the check will pass your test as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can test it out yourself:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: lv_test1 type string,
      lv_test2 type string.


lv_test1 = '&amp;gt;&amp;gt;'.
lv_test2 = 'gtttt'.

if lv_test1 ca '&amp;gt;,gt'.
  write:/ 'contains operator'.
else.
  write:/ 'does not contain operator'.
endif.


if lv_test2 ca '&amp;gt;,gt'.
  write:/ 'contains operator'.
else.
  write:/ 'does not contain operator'.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i don't think you will be able to do your check with CO CP CS and such.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A possible solution might be to create an internal table with each operator in an entry.;And then to check if you string holds one of the entries in your internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just an example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of ty_operators,
          value type string,
       end of ty_operators,

       begin of ty_split,
         value(30) type c,
       end of ty_split.

data: gv_text1(30) type c,
      gv_text2(30) type c,
      it_operators type table of ty_operators,
      wa_operators type ty_operators,
      it_split     type table of ty_split,
      wa_split     type ty_split.


clear: it_operators[].

wa_operators-value = '='.  append wa_operators to it_operators.
wa_operators-value = '&amp;lt;'.  append wa_operators to it_operators.
wa_operators-value = '&amp;gt;'.  append wa_operators to it_operators.
wa_operators-value = '&amp;lt;='. append wa_operators to it_operators.
wa_operators-value = '&amp;gt;='. append wa_operators to it_operators.
wa_operators-value = 'eq'. append wa_operators to it_operators.
* and so on for all your operators


gv_text1 = 'IF &amp;gt;&amp;gt;bla eq blabla'.
split gv_text1 at space into table it_split.

loop at it_split into wa_split.

  read table it_operators into wa_operators with key value = wa_split-value.
  if sy-subrc eq 0.
     write: / gv_text1, 'contains operator', wa_operators-value.
  endif.

endloop.



gv_text2 = 'IF bla eqeq blabla'.
split gv_text2 at space into table it_split.

loop at it_split into wa_split.

  read table it_operators into wa_operators with key value = wa_split-value.
  if sy-subrc eq 0.
     write: / gv_text2, 'contains operator', wa_operators-value.
  endif.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe there are other solutions, but you just have to try harder to find them. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 13:48:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004949#M1165279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-16T13:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004950#M1165280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the SYNTAX-CHECK command. I have constructed this from the ABAP online help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: itab TYPE TABLE OF string,
      mess TYPE string,
      lin  TYPE i,
      wrd  TYPE string,
      dir  TYPE trdir.

APPEND 'PROGRAM dummy.'               TO itab.
APPEND 'DATA a type c.'               TO itab.
APPEND 'DATA b type c.'               TO itab.
APPEND 'IF a GHE b.'                  TO itab.                "example, change as desired
APPEND 'ENDIF.'                       TO itab.

SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd
                 DIRECTORY ENTRY dir.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check SY-SUBRC and the contents of "mess" to find out if your operator is supported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 14:04:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004950#M1165280</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-01-16T14:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with if checking</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004951#M1165281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice one!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2009 14:06:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-if-checking/m-p/5004951#M1165281</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-16T14:06:50Z</dc:date>
    </item>
  </channel>
</rss>

