<?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 Unwanted rounding using inline declaration in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443654#M1928454</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;What will be the result of value_2 and value_3 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/827093" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using debug this what I get:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/827083" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IMHO it needs to be like value4 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something here....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DATA(value_2)&amp;nbsp; = ( '5.555' + '1.77777' ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data c_1 TYPE p DECIMALS 3 VALUE '5.555' . " 1 of type Packed Number&lt;/P&gt;&lt;P&gt;&amp;nbsp; data c_2 TYPE p DECIMALS 5 VALUE '1.77777' . " 2 of type Packed Number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATA(value_3) = ( c_1 + c_2 ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATA: value4 TYPE p DECIMALS 5 . " Data: value4 of type Packed Number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; value4 = ( c_1 + c_2 ) .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 08 Nov 2015 09:27:35 GMT</pubDate>
    <dc:creator>rosenberg_eitan</dc:creator>
    <dc:date>2015-11-08T09:27:35Z</dc:date>
    <item>
      <title>Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443654#M1928454</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;What will be the result of value_2 and value_3 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/827093" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using debug this what I get:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/827083" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IMHO it needs to be like value4 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something here....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DATA(value_2)&amp;nbsp; = ( '5.555' + '1.77777' ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data c_1 TYPE p DECIMALS 3 VALUE '5.555' . " 1 of type Packed Number&lt;/P&gt;&lt;P&gt;&amp;nbsp; data c_2 TYPE p DECIMALS 5 VALUE '1.77777' . " 2 of type Packed Number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATA(value_3) = ( c_1 + c_2 ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATA: value4 TYPE p DECIMALS 5 . " Data: value4 of type Packed Number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; value4 = ( c_1 + c_2 ) .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Nov 2015 09:27:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443654#M1928454</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2015-11-08T09:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443655#M1928455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have done a small thes in VBS .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/828095" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/828096" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As value4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea friends &lt;SPAN __jive_emoticon_name="sad" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_macro jive_emote" src="https://community.sap.com/1348/images/emoticons/sad.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 10:10:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443655#M1928455</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2015-11-10T10:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443656#M1928456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eitan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know the exact reason of this issue ('Hello, ABAP gurus, where are you?') but what I noticed is that value2 and value3 got type P(8) - without DECIMALS part (you can see it in debugger). So they naturally truncate all decimal parts, like if you simply declare them as 'data value2 type p'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought it is because ABAP cannot chose between DECIMAL 3 and DECIMALS 5 (as you have both types on the right side), but when I changed both c_1 and c_2 to DECIMALS 5 - it didn't work neither. So it seems like ABAP cannot correctly specify decimal part of type p and always uses DECIMALS 0.&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>Tue, 10 Nov 2015 11:31:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443656#M1928456</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-11-10T11:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443657#M1928457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eitan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you should dig further into the conversion rules defined for ABAP - &lt;A href="http://help.sap.com/abapdocu_740/en/abenuse_conversion_rules_guidl.htm" title="http://help.sap.com/abapdocu_740/en/abenuse_conversion_rules_guidl.htm"&gt;ABAP Keyword Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IMO the developer should not a generic type for the LHS of the expression, you can use the operator CONV to do the conversion for you. See the sample code below -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;TYPES pack_dec TYPE p DECIMALS 5.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; DATA(value_2) = CONV pack_dec('5.555' + '1.77777').&lt;/P&gt;
&lt;P&gt;&amp;nbsp; cl_demo_output=&amp;gt;write_data(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXPORTING&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = value_2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&amp;nbsp; = 'Variable 2'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ).&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; DATA c_1 TYPE p DECIMALS 3 VALUE '5.555' . " 1 of type Packed Number&lt;/P&gt;
&lt;P&gt;&amp;nbsp; DATA c_2 TYPE p DECIMALS 5 VALUE '1.77777' . " 2 of type Packed Number&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; DATA(value_3) = CONV pack_dec( c_1 + c_2 ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp; cl_demo_output=&amp;gt;write_data(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXPORTING&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = value_3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&amp;nbsp; = 'Variable 3'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ).&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; DATA value_4 TYPE pack_dec. " Data: value4 of type Packed Number&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; value_4 = c_1 + c_2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; cl_demo_output=&amp;gt;write_data(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXPORTING&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = value_4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&amp;nbsp; = 'Variable 4'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ).&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;" Display the log&lt;/P&gt;
&lt;P&gt;cl_demo_output=&amp;gt;display( ).&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Suhas Saha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 12:42:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443657#M1928457</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2015-11-10T12:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443658#M1928458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eitan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just to add to what Suhas already said. There is quite some discussion on the topic in the comments to &lt;A __default_attr="3984" __jive_macro_name="user" class="jive_macro_user jive_macro" data-objecttype="3" data-orig-content="Horst Keller" href="https://community.sap.com/"&gt;&lt;/A&gt;s original post on the topic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://scn.sap.com/community/abap/blog/2013/05/23/abap-news-for-release-740--inline-declarations" title="https://scn.sap.com/community/abap/blog/2013/05/23/abap-news-for-release-740--inline-declarations"&gt;https://scn.sap.com/community/abap/blog/2013/05/23/abap-news-for-release-740--inline-declarations&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Christian &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 14:36:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443658#M1928458</guid>
      <dc:creator>ceedee666</dc:creator>
      <dc:date>2015-11-10T14:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443659#M1928459</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;I was under the assumption that SAP will behave under the same rules as my math teacher thought me at junior school.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems that whoever wrote VBS interpreter have the same teacher..... &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_macro jive_emote" src="https://community.sap.com/1348/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 05:00:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443659#M1928459</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2015-11-11T05:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443660#M1928460</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;Thanks for the daily lesson .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You solve the mystery for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was under the impression that ABAP will behave more along the lines of the rest of the industry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example take a look at this java script code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/828631" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/828650" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 05:54:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443660#M1928460</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2015-11-11T05:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443661#M1928461</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;&lt;A _jive_internal="true" href="https://answers.sap.com/people/suhas.saha"&gt;Suhas&lt;/A&gt; recommended the right thing to do, using CONV, and &lt;A _jive_internal="true" href="https://answers.sap.com/people/alexander.skaskevich"&gt;Alexander Skaskevich&lt;/A&gt; is also correct in saying that ABAP is not able to determine the "right" type here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason is that for an&lt;STRONG&gt; arithmetic expression as RHS of an inline declaration&lt;/STRONG&gt;, the &lt;STRONG&gt;calculation type&lt;/STRONG&gt; of the arithmetic expression is used as data type for the declaration. Unfortunately, the compiler cannot extract an unambiguous data type from calculation type p (it cannot not take the operand with largest value range or most decimal places because type p is handled in a very special way in calculations). &lt;STRONG&gt;Therefore, for calculation type p, the data type for the declaration is always set to&amp;nbsp; p, length 8 without decimal places&lt;/STRONG&gt;. This results in loss of decimal places and even can lead to overflow exceptions (if you have numbers too large for p length 8 on the RHS).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I admit that this has been missing in the documentation &lt;SPAN __jive_emoticon_name="plain" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1381/images/emoticons/plain.gif"&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For 7.50, SP02, I added this fact and a warning hint to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="http://help.sap.com/abapdocu_740/en/index.htm?file=abenequals_arith_expr.htm"&gt;=, Arithmetic Expression&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://help.sap.com/abapdocu_740/en/index.htm?file=abenarith_type.htm"&gt;arith_exp - Calculation Type&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The portal version of the documentation will be updated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also asked the developer, if it wouldn't be a good idea to raise a syntax warning when using calculation type p on the RHS of an inline declaration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;A _jive_internal="true" href="https://answers.sap.com/people/christian.drumm"&gt;Christian&lt;/A&gt; for notifying. Interestingly I had hotline service that week and received the same incident internally the same day ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Horst&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: A summarizing example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN class="qtext"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;TYPES pack8_3&amp;nbsp; TYPE p LENGTH 8 DECIMALS 3. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;TYPES pack16&amp;nbsp;&amp;nbsp; TYPE p LENGTH 16. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DATA&amp;nbsp; number1&amp;nbsp; TYPE pack8_3 VALUE '12345.6789'. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DATA&amp;nbsp; number2&amp;nbsp; TYPE pack16 VALUE&amp;nbsp; '12345678901234567890'. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DATA(result1) = number1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "p, length 8, decimals 3 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DATA(result2) = number2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "p, length 16 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;TRY. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA(result3) = 1 * number1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "p, length 8, decimals 0 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA(result4) = 1 * number2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "p, length 8 -&amp;gt;exception &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; CATCH cx_sy_arithmetic_overflow. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ENDTRY. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DATA(result5) = CONV pack8_3( 1 * number1 ). "p, length 8, decimals 3 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DATA(result6) = CONV pack16(&amp;nbsp; 1 * number2 ). "p, length 16&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;











&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 08:12:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443661#M1928461</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2015-11-18T08:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443662#M1928462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Horst,&lt;/P&gt;&lt;P&gt;Thanks for the clarification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder how the "internal" calculation data type is being determined in such case?&lt;/P&gt;&lt;P&gt;According to Eitan's example, I understand that it doesn't use P length 8 (Otherwise, the result of &lt;SPAN class="string"&gt;5.555&lt;/SPAN&gt; + &lt;SPAN class="number"&gt;&lt;SPAN class="string"&gt;1.77777 should have been 8, but that's not the case).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 11:57:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443662#M1928462</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-11-18T11:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unwanted rounding using inline declaration</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443663#M1928463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I knew that someone is going to ask that &lt;SPAN __jive_emoticon_name="wink" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_macro jive_emote" src="https://community.sap.com/1381/images/emoticons/wink.gif"&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now that's the old story of calculation &lt;SPAN style="font-size: 13.3333px;"&gt; type p&lt;/SPAN&gt; as documented under &lt;A class="jive-link-external-small" href="http://help.sap.com/abapdocu_740/en/index.htm?file=abenarith_type.htm" style="font-family: inherit; font-size: 10pt; font-weight: inherit; font-style: inherit; color: #3778c7; text-decoration: underline !important; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;arith_exp - Calculation Type&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN class="bold" style="font-weight: bold; color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;Calculation type&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt; &lt;/SPAN&gt;&lt;SPAN class="qtext" style="font-family: 'Courier New'; font-weight: bold; color: #000000; font-size: 12.8px; background-color: #fefeff;"&gt;p&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;Fixed point arithmetic The arithmetic expression is calculated to an internal accuracy of 31 &lt;/SPAN&gt;&lt;A class="grey" style="color: #505050; font-family: Arial; font-size: 12.8px; background-color: #fefeff;" title="Glossary Entry"&gt;decimal places&lt;/A&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt; and using a special decimal floating point arithmetic for intermediate results. During the calculation, the decimal point for numbers of type &lt;/SPAN&gt;&lt;SPAN class="qtext" style="font-family: 'Courier New'; font-weight: bold; color: #000000; font-size: 12.8px; background-color: #fefeff;"&gt;p&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt; is not fixed. If an overflow occurs because an intermediate result is greater than 10^31 - 1, the whole expression is recalculated to an internal accuracy of 63 decimal places, or a maximum value of 10^63 -1 for intermediate results. If another overflow occurs, the handleable exception CX_SY_ARITHMETIC_OVERFLOW is raised. An overflow always occurs if the level of accuracy is not sufficient for all decimal places before the decimal separator. Surplus &lt;/SPAN&gt;&lt;A class="grey" style="color: #505050; font-family: Arial; font-size: 12.8px; background-color: #fefeff;" title="Glossary Entry"&gt;decimal places&lt;/A&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt; do not raise an exception, but are rounded to the nearest whole number for each intermediate result. &lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It's a runtime thing. The compiler cannot evaluate that for type inference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 12:20:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unwanted-rounding-using-inline-declaration/m-p/11443663#M1928463</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2015-11-18T12:20:58Z</dc:date>
    </item>
  </channel>
</rss>

