<?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 Logical Expression in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050400#M1611719</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 have an internal table contains field for logical expression EQ, GE, GT etc.&lt;/P&gt;&lt;P&gt;I would like to use this logical expression in my ABAP code.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;READ TABLE INTAB INDEX 1.&lt;/P&gt;&lt;P&gt;Comparing the value of a and b based on the logical expression from the INTAB.&lt;/P&gt;&lt;P&gt;How can i achieve this ?&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.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jul 2011 10:58:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-07-07T10:58:12Z</dc:date>
    <item>
      <title>Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050400#M1611719</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 have an internal table contains field for logical expression EQ, GE, GT etc.&lt;/P&gt;&lt;P&gt;I would like to use this logical expression in my ABAP code.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;READ TABLE INTAB INDEX 1.&lt;/P&gt;&lt;P&gt;Comparing the value of a and b based on the logical expression from the INTAB.&lt;/P&gt;&lt;P&gt;How can i achieve this ?&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.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 10:58:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050400#M1611719</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T10:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050401#M1611720</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 doubt if we can pass a variable in place of logical expression.&lt;/P&gt;&lt;P&gt;You can try by reading your internal table, and having various if conditions.But that doesnt look like a good solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 11:07:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050401#M1611720</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T11:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050402#M1611721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    Make use of macros, just check below example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : lv_abc  TYPE i VALUE 5,
       lv_bca  TYPE i VALUE 3.


DEFINE mac.

  if lv_abc &amp;amp;1 lv_bca.
    write :/ 'Bala'.
  else.
    write :/'Krishna'.
  endif.

END-OF-DEFINITION.

mac gt.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In above code, you can pass the INTAB table field value with the defined macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mac intab-field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 11:21:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050402#M1611721</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2011-07-07T11:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050403#M1611722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, i have try not to use if and else condition to fulfill the requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Bala,&lt;/P&gt;&lt;P&gt;Thanks for providing example, however i'm not really get it on how to use it.&lt;/P&gt;&lt;P&gt;I will provide more details scenario&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table ZTAB consist of following structure and records&lt;/P&gt;&lt;P&gt;abc      GT&lt;/P&gt;&lt;P&gt;cef       EQ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a = 50.&lt;/P&gt;&lt;P&gt;b = 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ztab with key field = 'abc'.&lt;/P&gt;&lt;P&gt;Based on the table entries from ztab, i sud use the operation GT to compare between value a and b.&lt;/P&gt;&lt;P&gt;so instead of using this way&lt;/P&gt;&lt;P&gt;IF ztab-sign = 'GT'.&lt;/P&gt;&lt;P&gt; IF a GT b.&lt;/P&gt;&lt;P&gt; WRITE: 'Successful'&lt;/P&gt;&lt;P&gt; ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to define the operation based on the table entries ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 14:22:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050403#M1611722</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T14:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050404#M1611723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you could use an approach populating a RANGE.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF ztab OCCURS 0,
        field(10) TYPE c,
        operator(2) TYPE c,
      END OF ztab.

RANGES: r_field FOR sbfadxth-keychar10. "any DDIC field with the same
                                        "type as ZTAB-FIELD

INITIALIZATION.
* Just initializing the example you provided
  ztab-field = 'abc'.
  ztab-operator = 'EQ'.
  APPEND ztab.

  ztab-field = 'cef'.
  ztab-operator = 'GT'.
  APPEND ztab.

START-OF-SELECTION.
  READ TABLE ztab WITH KEY field = 'abc'.
  IF sy-subrc = 0.
*   Now you'll fill the range according to the entry you've just READ
    CLEAR: r_field.
    REFRESH: r_field.

    r_field-sign = 'I'.
    r_field-option = ztab-operator.
    r_field-low = ztab-field.
    r_field-high = space.
    APPEND r_field.

*   Finally you make the comparison
    IF a IN r_field.
      WRITE: 'Successful'.
    ENDIF.

  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps. Kind regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 16:27:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050404#M1611723</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T16:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050405#M1611724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi O. SITI EPBP,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you could create form routines for the operators and call them dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PERFORM (ztab-sign) using a b changing result.
WRITE: / a,ztab-sign,b,'is',result.

FORM GT using p_val_a p_val_b changing p_result.
  IF  p_val_a  &amp;gt; p_val_b .
    p_result. = 'TRUE'.
  ELSE.
    p_result. = 'FALSE'.
  ENDIF.
ENDFORM.
FORM LT using p_val_a p_val_b changing p_result.
  IF  p_val_a  &amp;lt; p_val_b .
    p_result. = 'TRUE'.
  ELSE.
    p_result. = 'FALSE'.
  ENDIF.
ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create one form for each operator.&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;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 22:10:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050405#M1611724</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-07-07T22:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050406#M1611725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    The required code has to be declared in the Macro defination, it is define between the statement DEFINE and END-OF-DEFINATION, with the help of CASE statement you can code for all the possible Options. Just check the below example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : v_aaa TYPE i VALUE 50,
       v_bbb TYPE i VALUE 100.

TYPES : BEGIN OF ty_ztab,
          field  TYPE c LENGTH 5,
          option TYPE c LENGTH 2,
        END OF ty_ztab.

DATA : i_ztab  TYPE TABLE OF ty_ztab,
       wa_ztab TYPE ty_ztab.


DEFINE macro.

  case &amp;amp;1.
    when 'GT'.

      if v_aaa gt v_bbb.
        write :/ v_aaa, 'Greater than', v_bbb.
      else.
        write :/ v_aaa, 'Less than', v_bbb.
      endif.

    when 'EQ'.

      if v_aaa eq v_bbb.
        write :/ 'Equal'.
      endif.

    when 'LT'.

    when 'NE'.

    when others.
  endcase.

END-OF-DEFINITION.


START-OF-SELECTION.

  wa_ztab-field = 'abc'.
  wa_ztab-option = 'GT'.
  APPEND wa_ztab TO i_ztab.
  CLEAR : wa_ztab.

  wa_ztab-field = 'cef'.
  wa_ztab-option = 'EQ'.
  APPEND wa_ztab TO i_ztab.
  CLEAR : wa_ztab.

  READ TABLE i_ztab INTO wa_ztab WITH KEY
                    field = 'abc'.
  IF sy-subrc = 0.
    macro wa_ztab-option.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output will be :-  50 Less than 100, which is written in ELSE condition of the CASE condition GT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2011 06:54:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050406#M1611725</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2011-07-08T06:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Logical Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050407#M1611726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alvaro ,&lt;/P&gt;&lt;P&gt;Thanks for the solution. Point Rewarded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Bala,&lt;/P&gt;&lt;P&gt;Your solution will work too, however i try to eliminate using too much IF and ENDIF statement for this requirement.&lt;/P&gt;&lt;P&gt;But thanks for your details explanation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2011 14:09:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logical-expression/m-p/8050407#M1611726</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-08T14:09:02Z</dc:date>
    </item>
  </channel>
</rss>

