<?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: Dynamic logic expression in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819092#M1588846</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marcin Pciak, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your anwser, and that was my problem... boolean expressions....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My condition it didnt make sense, like you said...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway i solved by inserting the logic operador in the string argument , and checking the operador in the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"Macro definition
DEFINE checkif_cond.
  case &amp;amp;2.
    when 'EQ'.
      if &amp;amp;1 eq &amp;amp;3.
        &amp;amp;4 = 'X'.
      endif.
    when 'NE'.
      if &amp;amp;1 ne &amp;amp;3.
        &amp;amp;4 = 'X'.
      endif.
  endcase.
END-OF-DEFINITION.

.....


ASSIGN (str_1) TO &amp;lt;fs_value1&amp;gt;.
"Now condition goes like this:
"&amp;lt;fs_value&amp;gt;  -  value.. X or space
"str_2  - operator EQ or NE
"str_3 - valor to compare X or space 
      checkif_cond &amp;lt;fs_value1&amp;gt; str_2 str_3 lv_result.
      IF lv_result IS INITIAL.
        EXIT.
      ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;João Martins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 May 2011 17:50:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-05-24T17:50:45Z</dc:date>
    <item>
      <title>Dynamic logic expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819090#M1588844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iu2019m trying to build a routine with dynamic logical expressions but it's now working...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically Iu2019m building a string with the expression, a and after the string it's completed Iu2019m calling a macro that consist in a if.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if expression eq true &lt;/P&gt;&lt;P&gt;return true value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but the value returned by the macro it's always false, even when the logical expression it's true...&lt;/P&gt;&lt;P&gt; i already tried the logical function BOOLC but apparently my version, ECC 6, doesnu2019t recognize it....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below goes the code, if anyone could help me Iu2019ll be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


"Macro definition
DEFINE check_condition.
IF &amp;amp;1 EQ ABAP_TRUE.
    move 'X' to &amp;amp;2.
  endif.
END-OF-DEFINITION.


LOOP AT tab_regras."Rules 
    CLEAR: str_cond, lv_result.
    LOOP AT dfies_tab WHERE fieldname CS 'ARGUMENTO'.

      CLEAR: lw_string, str_1, str_2, str_3.
      ASSIGN COMPONENT dfies_tab-fieldname OF STRUCTURE tab_regras TO &amp;lt;fs_field&amp;gt;.
      CHECK &amp;lt;fs_field&amp;gt; IS NOT INITIAL.
      SPLIT &amp;lt;fs_field&amp;gt; AT '/' INTO  str_1 str_2 str_3.
      ASSIGN (str_1) TO &amp;lt;fs_value1&amp;gt;.
"     ASSIGN (str_2) TO &amp;lt;fs_value2&amp;gt;.
"      ASSIGN (str_3) TO &amp;lt;fs_value3&amp;gt;.

      IF str_cond IS INITIAL..
        CONCATENATE &amp;lt;fs_value1&amp;gt; str_2 str_3 INTO str_cond SEPARATED BY space.
        CONTINUE.
      ENDIF.

      CONCATENATE str_cond 'and' &amp;lt;fs_value1&amp;gt; str_2 str_3 INTO str_cond SEPARATED BY space."string condition

    ENDLOOP.
    check_condition str_cond lv_result.
    CHECK lv_result EQ 'X'.



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance, &lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;João Martins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 13:19:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819090#M1588844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-24T13:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic logic expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819091#M1588845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would be helpful if you show us what is the example content of &lt;EM&gt;str_cond&lt;/EM&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyhow your check looks like you want to compare some condition with value X which &lt;EM&gt;abap_true&lt;/EM&gt; denotes i.e.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
if field_1 = 10 and field_2 = 20 EQ 'X'.  
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;This doesn't make sense for me or maybe I am missing something which is hidden behid this &lt;EM&gt;str_cond&lt;/EM&gt; . Your left hand side expression value must however be equal to right hand side value. So the conditon will only be true if&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
if 'X' = 'X'.
...
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;PS: please note that in ABAP there is no real &lt;EM&gt;boolean&lt;/EM&gt; value, so you can't have condition like in JAVA or C&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
if (true_condition)
{
 //do something
}
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;you always have to compare two values (here &lt;EM&gt;abap_true&lt;/EM&gt; which is X if fact).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marcin Pciak on May 24, 2011 3:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 13:46:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819091#M1588845</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-05-24T13:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic logic expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819092#M1588846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marcin Pciak, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your anwser, and that was my problem... boolean expressions....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My condition it didnt make sense, like you said...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway i solved by inserting the logic operador in the string argument , and checking the operador in the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"Macro definition
DEFINE checkif_cond.
  case &amp;amp;2.
    when 'EQ'.
      if &amp;amp;1 eq &amp;amp;3.
        &amp;amp;4 = 'X'.
      endif.
    when 'NE'.
      if &amp;amp;1 ne &amp;amp;3.
        &amp;amp;4 = 'X'.
      endif.
  endcase.
END-OF-DEFINITION.

.....


ASSIGN (str_1) TO &amp;lt;fs_value1&amp;gt;.
"Now condition goes like this:
"&amp;lt;fs_value&amp;gt;  -  value.. X or space
"str_2  - operator EQ or NE
"str_3 - valor to compare X or space 
      checkif_cond &amp;lt;fs_value1&amp;gt; str_2 str_3 lv_result.
      IF lv_result IS INITIAL.
        EXIT.
      ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;João Martins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 17:50:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-logic-expression/m-p/7819092#M1588846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-24T17:50:45Z</dc:date>
    </item>
  </channel>
</rss>

