<?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: operate currency fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045688#M87807</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to help. Please close the thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 31 Oct 2005 17:12:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-10-31T17:12:25Z</dc:date>
    <item>
      <title>operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045678#M87797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings, I am trying to calculate tax rates for a Purchase &lt;/P&gt;&lt;P&gt;Order by operating as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: ekko, ekpo, komv.&lt;/P&gt;&lt;P&gt;data: tax_rate type p decimals 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... Appropriate looping&lt;/P&gt;&lt;P&gt;tax_rate = komv-kbetr / ( ekpo-netpr * ekpo-menge )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which means:&lt;/P&gt;&lt;P&gt;rate = tax amount / ( net price * quantity )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The value stored in tax_rate is always 0 after executing the code, regardless of the values stored in tables.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;The currency type used is such that when I debug the program and visualize the values of kbetr and netpr the value shown is actually the real value divided by 100 and the quantity field has 3 decimal places. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also when visualizing partial results I get things like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: net_value type p decimals 2.&lt;/P&gt;&lt;P&gt;net_value = ekpo-netpr * ekpo-menge.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when netpr has a value of 97.00 and menge 2.000 the value stored in net_value is 194000.00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone clarify this situation? How do I control the  currency conversions and how do I manage P-type variables with different decimal places? Any help is much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 16:38:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045678#M87797</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T16:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045679#M87798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sergio,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably the Tax % is too low.&lt;/P&gt;&lt;P&gt;Try: &lt;/P&gt;&lt;P&gt;tax_rate = ( komv-kbetr * 100 ) / ( ekpo-netpr * ekpo-menge ).&lt;/P&gt;&lt;P&gt;This should bring up the tax as % and show the digits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your second question on net_value:&lt;/P&gt;&lt;P&gt;It depends on how you plan to use. If you want to display it correctly or pass it on, use:&lt;/P&gt;&lt;P&gt;write net_value currency curr.&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;write net_value to var_xxx currency curr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 17:04:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045679#M87798</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T17:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045680#M87799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much, tried to multiply by 100 but the result is still 0. About the write sentece, it works well, but what I need is to transfer the value to another variable in order to continue a series of calculations needed, is in this case where the problem arises.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;SAF&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 19:43:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045680#M87799</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T19:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045681#M87800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sergio - how are you filling structure KOMV? It's just a structure (not a table). If you don't put a value into komv-kbetr (from say konv-kbetr), the result will be 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 20:01:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045681#M87800</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T20:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045682#M87801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob, I am filling the structure by fetching records from the database, I checked that komv-kbetr contains a value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the actual calculation I am doing, by checking in the debugger is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tax_rate = 31.04 / ( 97.00 * 2.000 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but the result yields 0 no matter what values I put in the operands, I am suspecting it has to do with the field types and what I am seeing is the output conversion for the fields and the real data stored in the fields are much smaller values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data types are as follows:&lt;/P&gt;&lt;P&gt;tax_rate(6) type p decimals 2&lt;/P&gt;&lt;P&gt;kbetr type kbetr curr 11&lt;/P&gt;&lt;P&gt;netpr type bprei curr 11&lt;/P&gt;&lt;P&gt;menge type menge quan 13,3&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 20:39:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045682#M87801</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T20:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045683#M87802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What happens if you:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ekko, ekpo, komv.
DATA: tax_rate TYPE p DECIMALS 2.

komv-kbetr  = 3104.
komv-kbetr  = komv-kbetr / 100.
ekpo-netpr = 97.
ekpo-menge = 2.

tax_rate = komv-kbetr / ( ekpo-netpr * ekpo-menge ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get tax_rate = 0.16.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 20:59:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045683#M87802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T20:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045684#M87803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Specifically, I get a non-zero tax_rate for:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ekko, ekpo, komv, konv.
DATA: tax_rate TYPE p DECIMALS 2,
      rate LIKE komv-kbetr.


rate  = 3105.
rate  = rate / 100.

SELECT kbetr FROM  konv UP TO 1 ROWS
       INTO komv-kbetr
       WHERE  kbetr  = rate.

ENDSELECT.

SELECT netpr menge FROM  ekpo UP TO 1 ROWS
       INTO (ekpo-netpr, ekpo-menge)
       WHERE  netpr  = 97.

ENDSELECT.

tax_rate = komv-kbetr / ( ekpo-netpr * ekpo-menge ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So I think that somehow komv-kbetr is 0 in your program. Did you set a break-point before and after it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I changed your values slightly to make sure I retrieved data.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 21:18:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045684#M87803</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T21:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045685#M87804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob, yes, I actually took the values from the debugger. In order to investigate the problem further, I did the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: quantity type f,&lt;/P&gt;&lt;P&gt;price type f,&lt;/P&gt;&lt;P&gt;tax type f,&lt;/P&gt;&lt;P&gt;rate_f type f.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... Data Retrieval&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE wa_ekpo-menge TO quantity.&lt;/P&gt;&lt;P&gt;MOVE wa_ekpo-netpr TO price.&lt;/P&gt;&lt;P&gt;MOVE wa_komv-kbetr TO tax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rate_f = tax / ( net * quantity ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With this, the only way I get the 0.16 rate is dividing quantity / 1000, when moving the value 2.000 into the f variable, it translates into the value 2000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By modifying the original formula to be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rate = wa_komv-kbetr / (wa_ekpo-netpr*(wa_ekpo-menge/1000)).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still get rate = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the only way I obtained the correct value 0.16 is by using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rate = wa_komv-kbetr&lt;STRONG&gt;100000 / (wa_ekpo-netpr&lt;/STRONG&gt;(wa_ekpo-menge)).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since I found that when translating the 97.00 value in netpr into the f variable, it becomes 9700 which is the actual currency value entered for the order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found that the currency type for this order is COP instead of USD, it works well with dollars but when working with different currencies the values stored are shifted by 100 or 1000. The question is now: Is there a way to control the way calculations are made according to the currency type?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 21:50:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045685#M87804</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T21:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045686#M87805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I'm beginning to see. You might be able to use the ratio fields in table TCURR for the currency you are working with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2005 21:59:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045686#M87805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-28T21:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045687#M87806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob, thank yo very much for your answers, all have been very helpful, besides checking the ratio values in the TCURR table, I was able to track down the problem. What was happening was that the fixed point arithmetic option in the program attributes was unchecked, so the interpreter was taking the variables of type p in a very different way than expected (bitwise is my guess), by checking that option all calculations inside the program started to work flawlessly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was a very good lesson to learn and I hope this thread will be useful for others as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again and best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sergio A. Feo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2005 16:43:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045687#M87806</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-31T16:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: operate currency fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045688#M87807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to help. Please close the thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2005 17:12:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/operate-currency-fields/m-p/1045688#M87807</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-31T17:12:25Z</dc:date>
    </item>
  </channel>
</rss>

