<?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: Executing an Arithmatic Formula stored as String in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638553#M876278</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;do this way ...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data : zform type i.

zform = ( A / 2 ) + (  (B * 1.25)  + 2 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Apr 2008 05:12:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-03T05:12:34Z</dc:date>
    <item>
      <title>Executing an Arithmatic Formula stored as String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638552#M876277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help,&lt;/P&gt;&lt;P&gt;I have similar problem with Mr. Vijayakumar V.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to get result value of an arithmatic formula which stored as string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex: &lt;/P&gt;&lt;P&gt;zform = '( A / 2 ) + ( B * 1.25 + 2 )'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if I have A = 10, and B = 4.&lt;/P&gt;&lt;P&gt;I do expect the final result to be : 12 &lt;/P&gt;&lt;P&gt;for ( 5 + 7 ) = 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any simple way to do this or&lt;/P&gt;&lt;P&gt;Is there built in function in ABAP to deal with something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 05:09:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638552#M876277</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T05:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Executing an Arithmatic Formula stored as String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638553#M876278</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;do this way ...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data : zform type i.

zform = ( A / 2 ) + (  (B * 1.25)  + 2 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 05:12:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638553#M876278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T05:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Executing an Arithmatic Formula stored as String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638554#M876279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;data : zform type p decimals 2,a type p decimals 2,
    b type p decimals 2.

define name.

  a =  &amp;amp;1 / 2.
  b  = &amp;amp;2 * '1.25'.
  b = b + 2.
  zform = a + b.


  write zform.

end-of-definition.

name 10 4.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pass the value like 10 4.&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;V.Balaji&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if Usefull...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Balaji V on Apr 3, 2008 7:30 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Balaji V on Apr 3, 2008 7:31 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 05:28:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638554#M876279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T05:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Executing an Arithmatic Formula stored as String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638555#M876280</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;do this way ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : zform type p decimals 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because if decimals places also there u need to collect with zero errors...&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;..
zform = ( A / 2 ) + (  (B * 1.25)  + 2 ).
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 05:31:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638555#M876280</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T05:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Executing an Arithmatic Formula stored as String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638556#M876281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Oki,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can solve your problem by generating subroutine at runtime.&lt;/P&gt;&lt;P&gt;Please look at sample code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  z_jr05.

DATA: code(72) OCCURS 10,
      prog(8),
      msg(120),
      lin(3),
      wrd(10),
      off(3),
      var_string(50),
      p_result  TYPE i.

var_string  = 'temp_result = ( A * B ) + 199.'.
REPLACE ALL OCCURRENCES  OF'A' IN var_string WITH '10'.
REPLACE ALL OCCURRENCES  OF'B' IN var_string WITH '11'.

APPEND 'PROGRAM SUBPOOL.'                  TO code.
APPEND 'FORM HITUNG changing p_result.'    TO code.
APPEND 'data: temp_result type i.'         TO code.
APPEND  var_string                         TO code.
APPEND 'p_result = temp_result.'           TO code.
APPEND 'ENDFORM.'                          TO code.

GENERATE SUBROUTINE POOL code NAME prog
        MESSAGE msg LINE lin
        WORD wrd    OFFSET off.

IF sy-subrc &amp;lt;&amp;gt; 0.
  WRITE: / 'Error during generation in line', lin,
  / msg,
  / 'Word:', wrd, 'at offset', off.
ELSE.
  WRITE: / 'The name of the subroutine pool is', prog.
  SKIP 2.
  PERFORM hitung IN PROGRAM (prog) CHANGING p_result.
  WRITE p_result.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 06:40:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/executing-an-arithmatic-formula-stored-as-string/m-p/3638556#M876281</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T06:40:49Z</dc:date>
    </item>
  </channel>
</rss>

