<?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 IF statement...like dynamic where clause... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152148#M1514737</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sume,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would try to use an approach using ranges:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
  gv_material TYPE matnr.

gv_material = '292-392-392-202'.

IF gv_material = '292-392-392-202'.
  WRITE: / `Static check:`, gv_material, `matches!`.
ELSE.
  WRITE: / `Static check:`, gv_material, `doesn't match!`.
ENDIF.

PERFORM dynamic_check
            USING
               gv_material
               'I'
               'EQ'
               '292-392-392-202'
               space.

PERFORM dynamic_check
            USING
               gv_material
               'I'
               'CP'
               '*292*'
               space.

PERFORM dynamic_check
            USING
               gv_material
               'I'
               'CP'
               '*ABC*'
               space.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  dynamic_check
*&amp;amp;---------------------------------------------------------------------*
FORM dynamic_check USING pv_value    TYPE clike
                         pv_sign     TYPE ddsign
                         pv_option   TYPE ddoption
                         pv_low      TYPE string
                         pv_high     TYPE string.

  DATA lr_range TYPE RANGE OF string.
  DATA ls_range LIKE LINE  OF lr_range.

  ls_range-sign   = pv_sign.
  ls_range-option = pv_option.
  ls_range-low    = pv_low.
  ls_range-high   = pv_high.
  APPEND ls_range TO lr_range.

  IF pv_value IN lr_range.
    WRITE: / `Dynamic check matches: `, pv_value, ls_range-sign, ls_range-option, ls_range-low, ls_range-high.
  ELSE.
    WRITE: / `Dynamic check doesn't match:`, pv_value, ls_range-sign, ls_range-option, ls_range-low, ls_range-high.
  ENDIF.

ENDFORM.                    "dynamic_check&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;For values of SIGN and OPTION check the values of the domains used in the data elements of the parameters of form dynamic_check.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output is like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Static check:                292-392-392-202    matches!
Dynamic check matches:       292-392-392-202    I EQ 292-392-392-202
Dynamic check matches:       292-392-392-202    I CP *292*
Dynamic check doesn't match: 292-392-392-202    I CP *ABC*&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alejiandro  Sensejl on Aug 11, 2010 8:23 PM: &lt;/P&gt;&lt;P&gt;&lt;EM&gt;Unfortunately I don't know why the code-tag isn't working, I sent a mail to SCN tech-team about this... Sorry, but you have to copy the code somehow to have a look at it &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Aug 2010 18:21:45 GMT</pubDate>
    <dc:creator>alejiandro_sensejl</dc:creator>
    <dc:date>2010-08-11T18:21:45Z</dc:date>
    <item>
      <title>Dynamic IF statement...like dynamic where clause...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152144#M1514733</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;I know how to do a dynamic where clause by putting (varname) like shown below -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from cust_mstr where (varname).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I do it something like this in &lt;STRONG&gt;IF&lt;/STRONG&gt; statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (varname).&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;STRONG&gt;varname&lt;/STRONG&gt; will have different conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help will be greately appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sume&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 15:45:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152144#M1514733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-11T15:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statement...like dynamic where clause...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152145#M1514734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried? No, it's not possible (yet), as far as I know, you might have to use dynamically created code, see GENERATE SUBROUTINE POOL, or maybe there is a simpler solution (like using ranges with IN operator), depending on what (varname) might contain.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 15:56:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152145#M1514734</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-08-11T15:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statement...like dynamic where clause...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152146#M1514735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sume,&lt;/P&gt;&lt;P&gt;            You can use field-symbols for defining IF statements. We can not write it like dynamic where cls but v can write like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
if &amp;lt;FLD&amp;gt; = &amp;lt;VAL&amp;gt;.
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;Anmol.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 16:20:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152146#M1514735</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-11T16:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statement...like dynamic where clause...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152147#M1514736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field symbol also do not work as the values are tread like variable values and not dynamic if stament.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 17:05:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152147#M1514736</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-11T17:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statement...like dynamic where clause...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152148#M1514737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sume,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would try to use an approach using ranges:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
  gv_material TYPE matnr.

gv_material = '292-392-392-202'.

IF gv_material = '292-392-392-202'.
  WRITE: / `Static check:`, gv_material, `matches!`.
ELSE.
  WRITE: / `Static check:`, gv_material, `doesn't match!`.
ENDIF.

PERFORM dynamic_check
            USING
               gv_material
               'I'
               'EQ'
               '292-392-392-202'
               space.

PERFORM dynamic_check
            USING
               gv_material
               'I'
               'CP'
               '*292*'
               space.

PERFORM dynamic_check
            USING
               gv_material
               'I'
               'CP'
               '*ABC*'
               space.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  dynamic_check
*&amp;amp;---------------------------------------------------------------------*
FORM dynamic_check USING pv_value    TYPE clike
                         pv_sign     TYPE ddsign
                         pv_option   TYPE ddoption
                         pv_low      TYPE string
                         pv_high     TYPE string.

  DATA lr_range TYPE RANGE OF string.
  DATA ls_range LIKE LINE  OF lr_range.

  ls_range-sign   = pv_sign.
  ls_range-option = pv_option.
  ls_range-low    = pv_low.
  ls_range-high   = pv_high.
  APPEND ls_range TO lr_range.

  IF pv_value IN lr_range.
    WRITE: / `Dynamic check matches: `, pv_value, ls_range-sign, ls_range-option, ls_range-low, ls_range-high.
  ELSE.
    WRITE: / `Dynamic check doesn't match:`, pv_value, ls_range-sign, ls_range-option, ls_range-low, ls_range-high.
  ENDIF.

ENDFORM.                    "dynamic_check&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;For values of SIGN and OPTION check the values of the domains used in the data elements of the parameters of form dynamic_check.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output is like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Static check:                292-392-392-202    matches!
Dynamic check matches:       292-392-392-202    I EQ 292-392-392-202
Dynamic check matches:       292-392-392-202    I CP *292*
Dynamic check doesn't match: 292-392-392-202    I CP *ABC*&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alejiandro  Sensejl on Aug 11, 2010 8:23 PM: &lt;/P&gt;&lt;P&gt;&lt;EM&gt;Unfortunately I don't know why the code-tag isn't working, I sent a mail to SCN tech-team about this... Sorry, but you have to copy the code somehow to have a look at it &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 18:21:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statement-like-dynamic-where-clause/m-p/7152148#M1514737</guid>
      <dc:creator>alejiandro_sensejl</dc:creator>
      <dc:date>2010-08-11T18:21:45Z</dc:date>
    </item>
  </channel>
</rss>

