<?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 statements in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024439#M82032</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't believe that you are allowed to having parameters dynamically.  You can do something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001
       no standard page heading.

types: t_source(72).

data: routine(32) value 'TEMP_ROUTINE',
             program(8),
             message(128),
             line type i.

data: isource type table of t_source,
             xsource type t_source.

start-of-selection.


  xsource = 'REPORT ZTEMP_REPORT.'.
  insert xsource  into isource index 1.
&amp;lt;b&amp;gt;  xsource = 'FORM &amp;amp; using message.'.&amp;lt;/b&amp;gt;
  replace '&amp;amp;' with routine into xsource.
  insert xsource  into isource index 2.


* Enter your logic here.....
  xsource = 'Data: this, that.'.
  append xsource to isource.

  xsource = 'IF This = that.'.
  append xsource to isource.
&amp;lt;b&amp;gt;  xsource = 'Write:/ message.'.&amp;lt;/b&amp;gt;
  append xsource to isource.
  xsource = 'ENDif.'.
  append xsource to isource.


  xsource = 'ENDFORM.'.
  append xsource to isource.

  generate subroutine pool isource name program
                           message message
                           line line.
  if sy-subrc = 0.
&amp;lt;b&amp;gt;    perform (routine) in program (program) 
                  using 'This is the message'.&amp;lt;/b&amp;gt;
  else.
    write:/ message.
  endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Dec 2005 20:22:22 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2005-12-07T20:22:22Z</dc:date>
    <item>
      <title>Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024432#M82025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello gurus..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My if conditions are maintained in a table and it will look like&lt;/P&gt;&lt;P&gt;00000219|001|T|SMC|04|02|EQ|O|35&lt;/P&gt;&lt;P&gt;00000219|002|T|SMC|04|02|EQ|O|75&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first 2 rows are key fields.. These 2 entries in the the database table will convert into &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;IF SMC4(2) = 35 OR SMC4(2) = 75&lt;/P&gt;&lt;P&gt;ENDIF.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say i build this if condition in an internal table somehow.. How do I make the ABAP compiler execute something in the internal table??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudhakar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 18:34:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024432#M82025</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-06T18:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024433#M82026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please explain clearly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 18:40:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024433#M82026</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-06T18:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024434#M82027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sudhakar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look into Dynamic Report / Subroutine generation GENERATE REPORT / GENERATE SUBROUTINE POOL itab NAME name. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use REPLACE statement to change your IF condition based on table entry..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Bharat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 18:41:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024434#M82027</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-06T18:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024435#M82028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this out, throw it in debug and whatch it execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


report zrich_0001
       no standard page heading.

types: t_source(72).

data: routine(32) value 'TEMP_ROUTINE',
             program(8),
             message(128),
             line type i.

data: isource type table of t_source,
             xsource type t_source.

start-of-selection.


  xsource = 'REPORT ZTEMP_REPORT.'.
  insert xsource  into isource index 1.
  xsource = 'FORM &amp;amp;.'.
  replace '&amp;amp;' with routine into xsource.
  insert xsource  into isource index 2.


* Enter your logic here.....
  xsource = 'Data: this, that.'.
  append xsource to isource.

  xsource = 'IF This = that.'.
  append xsource to isource.
  xsource = 'Write:/ ''This is = that''.'.
  append xsource to isource.
  xsource = 'ENDif.'.
  append xsource to isource.


  xsource = 'ENDFORM.'.
  append xsource to isource.

  generate subroutine pool isource name program
                           message message
                           line line.
  if sy-subrc = 0.
    perform (routine) in program (program).
  else.
    write:/ message.
  endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 18:58:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024435#M82028</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-06T18:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024436#M82029</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;You can easily achieve this by using Field symbols too. If you can cleary explain the issue, i can send you the sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 19:15:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024436#M82029</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-06T19:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024437#M82030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can easily do it using MACROS. The following is psuedo code. Adjust the code as per requirement. Basically it evaluates the part of the expression reprersented by one row in internal table at a time and keep the boolean result in memory and then it goes to next row of same expression and evaluates it and perform the boolean operation on previous result and this result to get current result. It will keep on doing till all sub expressions have been evaluated and combined.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; 
data : v_result1 type X  ,
       v_result2 type X ,
       v_result3 type X.
data : fld(4) type c value '1235'.
data : fld_name(30),
       bool_opr(20),
define exec_logexp .
  concatenate  &amp;amp;1 &amp;amp;2 '(' &amp;amp;3 ')' into fld_name.
  if fld_name &amp;amp;4  &amp;amp;5.
    v_result1 =  '1'.
  else.
    v_result1  = '0'.
  endif.
end-of-definition.


define calc_bool.
  
  v_result2 = v_result2 &amp;amp;1 v_result1.
end-of-definition.  
  
start-of-selection.
  break-point.

  Loop at itab where ... condition.

  exec_logexp itab-fld4 itab-fld5  itab-fld6 itab-fld7 itab-fld9.
*-----boolean operator
   if not itab-fld8 is initial.
     concatenate 'BIT-' itab-fld8 into bool_opr.
     calc_bool bool_opr.
   
   endiif
  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 19:46:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024437#M82030</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-06T19:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024438#M82031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything looks good buy I want to have "USING" and "CHANGING" as a part of the subroutine.. Like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have said&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;perform (routine) in program (program)&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to say&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;perform (routine) in program (program) (xx)&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;xx should contain the USING and CHANGING Parameters dynamically.. I get a syntax error as I am unable to pass xx dynamically..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can the GENERATE PROGRAM create a include program??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudhakar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2005 20:15:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024438#M82031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-07T20:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024439#M82032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't believe that you are allowed to having parameters dynamically.  You can do something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001
       no standard page heading.

types: t_source(72).

data: routine(32) value 'TEMP_ROUTINE',
             program(8),
             message(128),
             line type i.

data: isource type table of t_source,
             xsource type t_source.

start-of-selection.


  xsource = 'REPORT ZTEMP_REPORT.'.
  insert xsource  into isource index 1.
&amp;lt;b&amp;gt;  xsource = 'FORM &amp;amp; using message.'.&amp;lt;/b&amp;gt;
  replace '&amp;amp;' with routine into xsource.
  insert xsource  into isource index 2.


* Enter your logic here.....
  xsource = 'Data: this, that.'.
  append xsource to isource.

  xsource = 'IF This = that.'.
  append xsource to isource.
&amp;lt;b&amp;gt;  xsource = 'Write:/ message.'.&amp;lt;/b&amp;gt;
  append xsource to isource.
  xsource = 'ENDif.'.
  append xsource to isource.


  xsource = 'ENDFORM.'.
  append xsource to isource.

  generate subroutine pool isource name program
                           message message
                           line line.
  if sy-subrc = 0.
&amp;lt;b&amp;gt;    perform (routine) in program (program) 
                  using 'This is the message'.&amp;lt;/b&amp;gt;
  else.
    write:/ message.
  endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2005 20:22:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024439#M82032</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-07T20:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024440#M82033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unless, you were to build a call to your subroutine?.....:)&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2005 20:23:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024440#M82033</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-07T20:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024441#M82034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's what I mean,  you can generate a subroutine which will call a generated subroutine.  And you can build the parameters into the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001
       no standard page heading.

types: t_source(72).

data: routine(32) value 'CALL_ROUTINE',
             program(8),
             message(128),
             line type i.

data: isource type table of t_source,
             xsource type t_source.

start-of-selection.


* code for the first form
  xsource = 'REPORT ZTEMP_REPORT.'.
  insert xsource  into isource index 1.
  xsource = 'FORM TEMP_ROUTINE using p_message.'.
  insert xsource  into isource index 2.
  xsource = 'Data: this, that.'.
  append xsource to isource.
  xsource = 'IF This = that.'.
  append xsource to isource.
  xsource = 'Write:/ p_message.'.
  append xsource to isource.
  xsource = 'ENDif.'.
  append xsource to isource.
  xsource = 'ENDFORM.'.
  append xsource to isource.


* code for the second form.
  xsource = 'form call_routine using  p_program.'.
  append xsource to isource.
  xsource = 'perform temp_routine in program (p_program)'.
  append xsource to isource.
  xsource = ' using ''this is the message''.'.
  append xsource to isource.
  xsource = 'ENDFORM.'.
  append xsource to isource.



  generate subroutine pool isource name program
                           message message
                           line line.
  if sy-subrc = 0.
    perform (routine) in program (program) using program.
  else.
    write:/ message.
  endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2005 20:54:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024441#M82034</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-07T20:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic IF statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024442#M82035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;if this form you wish to execute is pre-existing and not itslef being created dynamically, maybe you could replace it with a function module? It is possible to call function modules and dynamically pass the parameters thorugh use of the 'PARAMETER-TABLE' addition. See today's discussion of Dynamic function module paramters in another thread.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 05:06:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-if-statements/m-p/1024442#M82035</guid>
      <dc:creator>former_member186741</dc:creator>
      <dc:date>2005-12-08T05:06:58Z</dc:date>
    </item>
  </channel>
</rss>

