‎2007 Nov 05 8:54 PM
hello,
I am trying to calculate a field and the result is a decimal. the field is not showing the decimal amount. ep-hwsteaa has the amount of 80.00. ep-hwste has the amount of 200.00. w-dec should be 0.4. when I run in debug mode, w_dec is 0.000.
I am not sure if I have this coded right or not.
If someonw could please take a look at this and let me know what I am doing wrong, that would be very helpful
thanks in advance for the help
DATA: w_dec type P DECIMALS 3,
w_hwsteaa type p DECIMALS 2,
w_hwste type p DECIMALS 2.
l_steuer_ep-hwbas = ( ep-hwsteaa / ep-hwste ) * ep-hwbas.
w_hwsteaa = ep-hwsteaa.
w_hwste = ep-hwste.
w_dec = ( w_hwsteaa / w_hwste ).
‎2007 Nov 05 9:13 PM
Go to the program attributes and make sure that "Fixed point arithmetic" is checked.
Rob
‎2007 Nov 05 9:12 PM
Hi,
Please check the values of EP-HWSTEAA and EP-HWSTE.
It is fine in my system, please try this.
DATA: W_DEC TYPE P DECIMALS 3,
W_HWSTEAA TYPE P DECIMALS 2,
W_HWSTE TYPE P DECIMALS 2.
W_HWSTEAA = '80'.
W_HWSTE = '200'.
W_DEC = ( W_HWSTEAA / W_HWSTE ).
WRITE: /W_DEC.
Regards,
Ferry Lianto
‎2007 Nov 05 9:13 PM
Go to the program attributes and make sure that "Fixed point arithmetic" is checked.
Rob
‎2007 Nov 05 9:25 PM
Rob,
I check the attributes and the "Fixed point arithmetic" was not checked. I checked it
Ferry,
I tried your suggestion (after setting the fixed point arithmetic switch) and the result is still the same. w_dec still contains 0.000.
‎2007 Nov 05 9:31 PM
I got 0.4 when I tested it with fixed point checked.
Did you save and activate?
Is this an include?
Rob
Message was edited by:
Rob Burbank
‎2007 Nov 05 9:33 PM
Hi,
As Rob suggested, please ensure the "Fixed point arithmetic" option is checked.
And try to regenerate the program again after the above option changed.
Regards,
Ferry Lianto
‎2007 Nov 06 1:06 PM
this is an include.
I am working with a Z copy of RFUMSV00. the include that I am trying to code the logic is zfi_rfums_selection_forms.
‎2007 Nov 06 1:19 PM
I tried this morning and the calculations are working correctly. is there something special with an include? whay would it not work yesterday wghen I made the change anf now this morning it is working.
‎2007 Nov 06 2:44 PM
I believe the include program inherits the attributes from the main program.
Did you reset the attributes of the main program?
Rob
‎2007 Nov 06 2:48 PM
Rob,
I don't understand what you mean be reset the attributes. I changed the main program to check the box for the "fixed point arithmetic" and activated the program
‎2007 Nov 06 3:17 PM
When did you activate the main program?
If you are modifying a copy of a standard SAP program, changing the attributesmay have unintended consequences. Does the unmodified version handle decimals correctly?
Rob
‎2007 Nov 06 3:23 PM
Rob
I am assuming that it handles the decimals. I ran my copy of the report and looks excatly like the unmiodified production program except for the code changes that I have made for the new columns. I am not usre if within the program, or includes, or BADI's if they are doing decimal calculations.
‎2007 Nov 06 3:26 PM
rob,
if this would be a problem and I would have to un-mark the attribute, how do you get around this. do you do the calculation and multiply the result by 100 to get a whole number. and then after you use this number do you divide the result by 100 to get the actual number?
‎2007 Nov 06 3:35 PM
Hi,
Try this way
report zars no standard page heading
line-size 170
line-count 65(4).
data: w_dec type p decimals 3,
w_hwsteaa type p decimals 2,
w_hwste type p decimals 2.
data : v_dec type p decimals 2.
w_hwsteaa = '80'.
w_hwste = '200'.
w_dec = ( w_hwsteaa / w_hwste ).
write: w_dec decimals 2.
move w_dec to v_dec.
write : / v_dec.
a®
‎2007 Nov 06 7:19 PM
I have tried to run the program with the fixed point arithmetic attribute turned on. I am getting another dump at a different place. since the original program did not have this attribute turned, I am a liile heistant to turn it on. that being said, is there a way for me to get my calculation with having to turn on this attribute. I have tried all of the code examples in this thread but none of them work. I found something where you can enable and display this fixed point attribute bbut I am not sure how to use this
‎2007 Nov 06 7:28 PM
Hi,
Check this link from SAP docu
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2d0c358411d1829f0000e829fbfe/content.htm
+
If the attribute Fixed point arithmetic is set for a program, the system rounds type P fields according to the number of decimal places or pads them with zeros. The decimal sign in this case is always the period (.), regardless of the users personal settings. We recommend that you always set the fixed point arithmetic attribute.
+
a®
‎2007 Nov 06 7:31 PM
‎2007 Nov 06 7:32 PM
I copied this program from a SAP standard program. the standard program does not have this coded. I have changed the attribute in my program and made the corrections to correct the dump ( dumping on the statement hlp_hwnet = 1000000000000.). I am running the standard program and my program with the same parameters and the numbers look like they are matching
‎2007 Nov 06 7:34 PM
yes I did and I did not get any result for w_dec. all I got was zeros
‎2007 Nov 06 7:35 PM
I took the code and created a test program with the fixed point arithmetic attribute not checked. I did not check any values, only zeros
‎2007 Nov 06 7:42 PM
Hi,
The following is the documentation i have a got , when i press F1 on Fixed Point Arthemetic
+
If you do not, packed numbers (ABAP/4 type P, Dictionary types CURR, DEC or QUAN) will be treated as integers when they are used in assignments, comparisons and calculations, irrespective of the number of decimal places defined. Intermediate results in arithmetic calculations will also be rounded to the next whole number. The number of decimal places defined is only taken into account when you output the answer using the WRITE statement.
+
a®
‎2007 Nov 12 6:09 PM
does,
I have checked the attribute and the calculation worked. I ran the standard program which did not have the attribute set and my program which does have the attribute set and the reports were identical in the amounts. what I didn't know is that I had bad test data. all of the test data were whole numbers (numbers that had no cents). when the user ran this against real data, the report did not show the cents amount. so now I have to uncheck this attribute and I am back to square one. I have to find a way to do my calculations without having this attribute checked. If anyone has any ideas on how to do this, it would be a big help. I have tried all of the examples that were sent to me in this post and I still get zero amounts when I run them
thanks in advance for any help
‎2007 Nov 12 7:04 PM
hello,
I found in another post where the person got around this issue by creating a function module in a function group that had the fixed point arithmetic attribute checked. is this the only way that I can get my calculations to worked?
thanks...
‎2007 Nov 13 7:53 PM
corrected on my own. I had to create new Z tables to include decimals