Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

data type problem:888 = 88.8

former_member192022
Participant
0 Likes
501

data:aaa type dec16_3.

...

loop at itab.

aaa = itab-field1.

endloop.

field1 type is dec15_2.

in su01,all my user set is ok.

when i debuging,

i change the value of itab-field1,for exmple, the vlaue is 99(a integer ,without decimal fraction) ,the system change 99 into 0.99 .why?

if i change the value into 99.00(a integer ,with two decimal fraction),the system do not change it.

if itab-field1 = 888 then aaa = 88.8. my god,SAP is so oddness.

2 REPLIES 2
Read only

Clemenss
Active Contributor
0 Likes
456

Hi Jason,

all dec numbers are stored as binary coded decimals (BCD), dec15_2 means that the last two digits are interpreted as decimals. This is due to automatic type conversion that two digits like 99 without any information about decimals will be stored 'as is' and get interpreted as last two digits for decimals - resulting in .99.

When units and currencies are involved, it gets even worse: In DDIC CURR and QUAN fields are connected to a currency key (CUKY) or unit key. Internal storing is always 3 digits and i.e. CUKY field gives information about number of decimals ( 1 for Japanese Yen, 2 for USD and so on).

Conclusion: Many things in SAP are odd, most of them are caused by the business-orientation of system and programming language. It takes it's time to understand but then it turns out to be useful.

Regards,

Clemens

Read only

0 Likes
456

thank you Li.you have more experience than me .

my msn:meiok1@hotmail.com

My question has been answered.

the way is :

ABAP Edit \main menu\goto\attribute\

check the fixed point arithmetic checkbox.

the checkbox is checked default.

but my program is a copied program.

it has include,and i renamed the include to an exist

include name.So the main program become a include.(Maybe

it's a bug).I change the new main program type from include back to executable program.

the "fixed point arithmetic" checkbox is unchecked.