<?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: Rounded value in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927217#M940539</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;1.Declare a variable  with reference to Packed decimal.&lt;/P&gt;&lt;P&gt; like DATA: v_round type p decimal 1.&lt;/P&gt;&lt;P&gt;2.If you need rounding the value use u can use the FM ROUND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rounding to spec. no. of dec. place (round up, round down, comm. round&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Functionality&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function module rounds the value INPUT to ANDEC decimal places. The parameter SIGN determines whether rounding is down ('-'), up ('+') or commercial ('X').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If SIGN = SPACE, there is no rounding (OUTPUT = INPUT).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The value VALUE is to be rounded up to the nearest hundred.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: VALUE TYPE F,&lt;/P&gt;&lt;P&gt;ROUND_VALUE TYPE F.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'ROUND'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;DECIMALS = 2-&lt;/P&gt;&lt;P&gt;INPUT = VALUE&lt;/P&gt;&lt;P&gt;SIGN = '+'&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;OUTPUT = ROUND_VALUE&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;INPUT_INVALD = 01&lt;/P&gt;&lt;P&gt;OVERFLOW = 02&lt;/P&gt;&lt;P&gt;TYPE_INVALID = 03. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result of floating point rounding calculations can be incorrect in certain cases because of rounding errors.&lt;/P&gt;&lt;P&gt;If INPUT is a field of type P, internal calculatons similarly use packed numbers. This is expensive, but more accurate. If the calculation accuracy is very important, INPUT should thus be a field of type P.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shiva Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 May 2008 11:56:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-27T11:56:39Z</dc:date>
    <item>
      <title>Rounded value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927215#M940537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I displayed one field, it containe data like 1.0004,2.546,4.508etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here it displayed only rounded value like 1,1.5,2,2.5,3,3.5 values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please tell me the code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 10:45:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927215#M940537</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T10:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rounded value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927216#M940538</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;check the type of the field in field declaration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Megha Sharma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 11:49:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927216#M940538</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T11:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rounded value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927217#M940539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;1.Declare a variable  with reference to Packed decimal.&lt;/P&gt;&lt;P&gt; like DATA: v_round type p decimal 1.&lt;/P&gt;&lt;P&gt;2.If you need rounding the value use u can use the FM ROUND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rounding to spec. no. of dec. place (round up, round down, comm. round&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Functionality&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function module rounds the value INPUT to ANDEC decimal places. The parameter SIGN determines whether rounding is down ('-'), up ('+') or commercial ('X').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If SIGN = SPACE, there is no rounding (OUTPUT = INPUT).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The value VALUE is to be rounded up to the nearest hundred.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: VALUE TYPE F,&lt;/P&gt;&lt;P&gt;ROUND_VALUE TYPE F.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'ROUND'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;DECIMALS = 2-&lt;/P&gt;&lt;P&gt;INPUT = VALUE&lt;/P&gt;&lt;P&gt;SIGN = '+'&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;OUTPUT = ROUND_VALUE&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;INPUT_INVALD = 01&lt;/P&gt;&lt;P&gt;OVERFLOW = 02&lt;/P&gt;&lt;P&gt;TYPE_INVALID = 03. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result of floating point rounding calculations can be incorrect in certain cases because of rounding errors.&lt;/P&gt;&lt;P&gt;If INPUT is a field of type P, internal calculatons similarly use packed numbers. This is expensive, but more accurate. If the calculation accuracy is very important, INPUT should thus be a field of type P.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shiva Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 11:56:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927217#M940539</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T11:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rounded value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927218#M940540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Declare the field like this.&lt;/P&gt;&lt;P&gt;parameters : v_num type P decimals 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or &lt;/P&gt;&lt;P&gt;Use these FUnctions.&lt;/P&gt;&lt;P&gt;ROUND&lt;/P&gt;&lt;P&gt;CEIL&lt;/P&gt;&lt;P&gt;FLOOR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Sandeep Reddy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 14:45:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927218#M940540</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T14:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rounded value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927219#M940541</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;      Even if you declare in packaged decimal(P) with decimal addition the value gets approaximated at the time of assignment to the variable of type P. You keep your result of type i only.Thereafter u write your result to a character variable and display that character variable. It will display accurate value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: op1 type i value 23,&lt;/P&gt;&lt;P&gt;         op2 type i value 22,&lt;/P&gt;&lt;P&gt;          result_i type i,&lt;/P&gt;&lt;P&gt;          result_c(20) type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;result_i = op1/op1.&lt;/P&gt;&lt;P&gt;write result_i to result_c.&lt;/P&gt;&lt;P&gt;condense result_c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls give points if helpfull.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 18:45:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927219#M940541</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T18:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rounded value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927220#M940542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check the data type of the field declared...it must be of type ie rounded to result u are getting&lt;/P&gt;&lt;P&gt;declare the field of type say char&lt;/P&gt;&lt;P&gt;followin code will help you...here unit price is declared of type char not NETWR so it can be rounded to desired no of places&lt;/P&gt;&lt;P&gt;\as we hv done it for three decimal places&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="4" type="ul"&gt;&lt;P&gt;Round Off the unit price after three decimal places&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: l_dec_part TYPE char18,&lt;/P&gt;&lt;P&gt;l_int_part TYPE char18,&lt;/P&gt;&lt;P&gt;int        TYPE int2,&lt;/P&gt;&lt;P&gt;decimals   TYPE int2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONSTANTS: l_c_1   TYPE char1 VALUE '1',&lt;/P&gt;&lt;P&gt;l_c_2   TYPE char1 VALUE '2',&lt;/P&gt;&lt;P&gt;l_c_3   TYPE char1 VALUE '3',&lt;/P&gt;&lt;P&gt;l_c_4   TYPE char1 VALUE '4',&lt;/P&gt;&lt;P&gt;l_c_5   TYPE char1 VALUE '5',&lt;/P&gt;&lt;P&gt;l_c_001 TYPE char4 VALUE '.001',&lt;/P&gt;&lt;P&gt;l_c_0   TYPE char1 VALUE '0',&lt;/P&gt;&lt;P&gt;l_c_00  TYPE char3 VALUE '.00'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPLIT v_unitprice AT '.' INTO l_int_part l_dec_part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int      = NUMOFCHAR( l_int_part ).&lt;/P&gt;&lt;P&gt;decimals = NUMOFCHAR( l_dec_part ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF decimals &amp;gt; l_c_2.&lt;/P&gt;&lt;P&gt;int = int + l_c_4.&lt;/P&gt;&lt;P&gt;IF v_unitprice+int(1) &amp;gt; l_c_5.&lt;/P&gt;&lt;P&gt;v_unitprice = v_unitprice+0(int) + l_c_001.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;v_unitprice = v_unitprice+0(int).&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SHIFT v_unitprice LEFT DELETING LEADING space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF decimals IS INITIAL.&lt;/P&gt;&lt;P&gt;CONCATENATE v_unitprice l_c_00 INTO v_unitprice.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR: l_int_part, l_dec_part, int, decimals.&lt;/P&gt;&lt;P&gt;SPLIT v_unitprice AT '.' INTO l_int_part l_dec_part.&lt;/P&gt;&lt;P&gt;int      = NUMOFCHAR( l_int_part ).&lt;/P&gt;&lt;P&gt;decimals = NUMOFCHAR( l_dec_part ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF decimals = l_c_1.&lt;/P&gt;&lt;P&gt;CONCATENATE v_unitprice l_c_0 INTO v_unitprice.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF decimals = l_c_2.&lt;/P&gt;&lt;P&gt;CONCATENATE v_unitprice l_c_0 INTO v_unitprice.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;End of change &amp;lt;C62963&amp;gt; by &amp;lt;SAZK&amp;gt;(Richa Khosla)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   data : l_wa_price type /fir/ro2c0bgs_pric_sub_totals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fetch the value of Price table with key item No.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   clear : l_wa_price.&lt;/P&gt;&lt;P&gt;  read table  it_price into l_wa_price with key posnr = wa_output-itm_no .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; If SY-SUBRC is INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;       v_amount = l_wa_price-netwr.&lt;/P&gt;&lt;P&gt;       v_amt1 = l_wa_price-netwr.&lt;/P&gt;&lt;P&gt;       v_unitprice = l_wa_price-netwr / wa_output-tntgew .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this..it will surely help&lt;/P&gt;&lt;P&gt;Reward points if useful&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Richa Khosla on May 28, 2008 7:15 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 May 2008 05:14:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rounded-value/m-p/3927220#M940542</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-28T05:14:03Z</dc:date>
    </item>
  </channel>
</rss>

