<?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 ABAP-Logic/Command: Execute An Expression Stored In A Variable in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150459#M117375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider the following code - &amp;lt;b&amp;gt;Is it possible to execute the statement/expression stored in variables expression1, expression2 and expression3?&amp;lt;/b&amp;gt; The result should be: &lt;/P&gt;&lt;P&gt;sum = 5 , subname = 'First' &amp;amp; i_output should be sorted by lifnr and ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*---DATA DECLARATIONS
DATA: sum         TYPE i,
      op1         TYPE i,
      op2         TYPE i,

      name        TYPE string,
      subname     TYPE string,
      offset      TYPE i,

      expression1 TYPE string,
      expression2 TYPE string,
      expression3 TYPE string.

DATA: BEGIN OF i_output OCCURS 0,
      lifnr TYPE lfa1-lifnr,
      ebeln TYPE ekko-ebeln,
      ebelp TYPE ekpo-ebelp,
      END OF i_output.

*---BUILD EXPRESSION 1
op1 = 2.
op2 = 3.
expression1 = 'sum = op1 + op2'.

*---BUILD EXPRESSION 2
name   = ' First Name'.
offset = 5.
expression2 = 'subname = name+1(offset)'.

*---POPULATE ITAB I_OUTPUT
MOVE: '111111' TO i_output-lifnr,
      'PO1'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.

MOVE: '111511' TO i_output-lifnr,
      'PO1'    TO i_output-ebeln,
      '020'    TO i_output-ebelp.
APPEND i_output.

MOVE: '111111' TO i_output-lifnr,
      'PO3'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.

MOVE: '114111' TO i_output-lifnr,
      'PO2'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.

MOVE: '111121' TO i_output-lifnr,
      'PO2'    TO i_output-ebeln,
      '020'    TO i_output-ebelp.
APPEND i_output.

CLEAR i_output.

*---BUILD EXPRESSION 3
expression3 = 'sort i_output by lifnr ebeln'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jan 2006 18:14:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-01-26T18:14:26Z</dc:date>
    <item>
      <title>ABAP-Logic/Command: Execute An Expression Stored In A Variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150459#M117375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider the following code - &amp;lt;b&amp;gt;Is it possible to execute the statement/expression stored in variables expression1, expression2 and expression3?&amp;lt;/b&amp;gt; The result should be: &lt;/P&gt;&lt;P&gt;sum = 5 , subname = 'First' &amp;amp; i_output should be sorted by lifnr and ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*---DATA DECLARATIONS
DATA: sum         TYPE i,
      op1         TYPE i,
      op2         TYPE i,

      name        TYPE string,
      subname     TYPE string,
      offset      TYPE i,

      expression1 TYPE string,
      expression2 TYPE string,
      expression3 TYPE string.

DATA: BEGIN OF i_output OCCURS 0,
      lifnr TYPE lfa1-lifnr,
      ebeln TYPE ekko-ebeln,
      ebelp TYPE ekpo-ebelp,
      END OF i_output.

*---BUILD EXPRESSION 1
op1 = 2.
op2 = 3.
expression1 = 'sum = op1 + op2'.

*---BUILD EXPRESSION 2
name   = ' First Name'.
offset = 5.
expression2 = 'subname = name+1(offset)'.

*---POPULATE ITAB I_OUTPUT
MOVE: '111111' TO i_output-lifnr,
      'PO1'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.

MOVE: '111511' TO i_output-lifnr,
      'PO1'    TO i_output-ebeln,
      '020'    TO i_output-ebelp.
APPEND i_output.

MOVE: '111111' TO i_output-lifnr,
      'PO3'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.

MOVE: '114111' TO i_output-lifnr,
      'PO2'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.

MOVE: '111121' TO i_output-lifnr,
      'PO2'    TO i_output-ebeln,
      '020'    TO i_output-ebelp.
APPEND i_output.

CLEAR i_output.

*---BUILD EXPRESSION 3
expression3 = 'sort i_output by lifnr ebeln'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jan 2006 18:14:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150459#M117375</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-26T18:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP-Logic/Command: Execute An Expression Stored In A Variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150460#M117376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can achieve this by generating a subroutine pool dynamically, passing the code lines (expressions) as an internal table. Here is the syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GENERATE SUBROUTINE POOL itab NAME name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jan 2006 18:26:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150460#M117376</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-26T18:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP-Logic/Command: Execute An Expression Stored In A Variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150461#M117377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But, how can you pass some value/data (say a table which has to be sorted) from the main report to the subroutine-pool?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jan 2006 18:45:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150461#M117377</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-26T18:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP-Logic/Command: Execute An Expression Stored In A Variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150462#M117378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; You can achieve this by generating a subroutine pool&lt;/P&gt;&lt;P&gt;&amp;gt; dynamically, passing the code lines (expressions) as&lt;/P&gt;&lt;P&gt;&amp;gt; an internal table. Here is the syntax:&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; GENERATE SUBROUTINE POOL itab NAME name.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Hope this helps,&lt;/P&gt;&lt;P&gt;&amp;gt; Bhanu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hey Banu, thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jan 2006 19:12:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-logic-command-execute-an-expression-stored-in-a-variable/m-p/1150462#M117378</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-26T19:12:10Z</dc:date>
    </item>
  </channel>
</rss>

