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

Problem with amounts in Internal Table

Former Member
0 Likes
803

I have 2 internal tables with header line . I am doing the following operation.

itab2-amt = itab2-amt + itab-amt .

itab2-amt1 = itab2-amt1 + itab-amt1.

amt and amt1 are defined as 9 characters each .

In Debug mode itab amt and amt 1 show as 1110.34 and 2222.22 .

But when I do the above operation

itab2-amt = 111034

itab2-amt1 = 222222

Please advise .

Thanks ,

Hari

9 REPLIES 9
Read only

Former Member
0 Likes
761

See if the check box for fixed point arithmetic is chosen in the program attruibutes section.

Regards,

Ravi

Read only

0 Likes
761

I checked it looks good . But why is that in one internal table it is different from the other .

Thanks ,

Hari

Read only

0 Likes
761

Because in the first table, the character value is assigned literally ('1110.34'). But as soon as you perform a caclulation with fixed point arithmetic turned off, it treats all numbers as integers.So the results are ijntegers.

Press F1 on the fixed point arithmetic checkbox in the attributes.

And Subramanian is correct. It's best not to do arithmetic on character fields. At best, performance is compromised; at worst, it can dump.

Rob

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
761

Hi,

Do not perform arithmetic operations on character fields.

Check if the field is referring to NUMC, if yes try to define as a packed decimal and do the operations.

After all your operations are done, and you want it to be stored into a character data type, you may move it to another variable.

Regards

Subramanian

Read only

Former Member
0 Likes
761

Hi Hari,

If both the fields of internal tables are character types then it should be working fine. You can do arithmetic operations also on characters fields. Can you copy paste your code containig internal table declaration aslo.

Ashven

Read only

Former Member
0 Likes
761

hi hari,

why dont u declare amt fields in both the itabs as type WRBTR

e.g. amt1 type wrbtr.

or you can use currency option to format the amount field in your write statement.

e.g. write itab-amt currency USD.

cheers,

vikram

pls reward for helpful replies!!

Read only

Former Member
0 Likes
761

I THINK YOU DINT ASSIGN YOUR AMT FIELD AS

DATA : AMT TYPE P DECIMALS 2.

OR ASSIGN LIKE ANY CURRENCY FIELD.

I THINK YOU ASSIGNED IT AS NUMERIC SO THE PROBLEM IS THERE PLS CORRECT ME IF I AM WRONG.

REGARDS

SHIBA DUTTA

Read only

Former Member
0 Likes
761

Hi,

Kinldy check the Check box for Fixed Point arthemetic.

It is availble in the attributes of the program.

REgards

Nagaraju

Read only

Former Member
0 Likes
761

Hi,

You try to declare AMT.

Ex.

DATA: amt TYPE i DECIMALS 2

Reward if useful