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

Calculating ( - ) field values.

Former Member
0 Likes
1,458

Hi,

I have declared fields BEWEG (Internal Movements) and netto (Net Volume) for a internal table. The data type of these fields is mseg-menge.

Sometimes when the value is negative like 578.000-, in internal table it stores as *8.00-.

It goes for dump when i try to do addition using this.

Why is that * coming in the value?

Is it because of lengh?

But for positve values, it works fine.

Ezhil.

9 REPLIES 9
Read only

Former Member
0 Likes
1,404

Hi,

can you please show the declaration of the fields.

regards, Dieter

Sorry i have seen mseg-menge.

Edited by: Dieter Gröhn on Nov 27, 2009 1:58 PM

Read only

0 Likes
1,404

YPES: BEGIN OF ITEM,

werks1 LIKE T001L-WERKS,

LGORT1 LIKE T001L-LGORT,

zypom LIKE zys_mara-zypom,

lgobe1(50),

bukrs1 LIKE t001k-bukrs,

stloc LIKE zyt001l-zystloc,

flag LIKE zyt001l-zyflag,

zyfrb like zys_mara-zyfrb,

zyqua like zys_mara-zyqua,

anfang LIKE mard-labst,

prod LIKE mseg-menge, "MN210704

beweg LIKE mseg-menge, "MN210704

netto LIKE mseg-menge,

other LIKE mseg-menge,

adjust LIKE mseg-menge,

verk LIKE mseg-menge,

return LIKE mseg-menge,

end1 LIKE mard-vmlab,

diff LIKE mseg-menge,

zyppg like zys_mara-zyppg,

zytcd like zys_mara-zytcd,

zydt1 like zys_mara-zydt1,

zyfil Like zys_mara-zyfil,

zytyp like zys_mara-zytyp,

zymer like zys_mara-zymer,

add LIKE mseg-menge,

END OF ITEM.

Read only

0 Likes
1,404

MSEG-MENGE points to domain MENG13 which does not allow the negative sign. You should change the declaration to a field that allows negative values (e.g. MSKU-LABST which uses domain MENG13V).

Thomas

Read only

0 Likes
1,404

Hi,

i have tried this and there are no problems.


data menge like mseg-menge.
*
menge = 578000.
*
write: / menge.
*
menge = menge * ( -1 ).
*
write: / menge.
*
add 1000000 to menge.
*
write: / menge.
*

Regards, Dieter

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,404

Hello Thomas,

I think if you read the F1 help for the "Sign" attribute of the domain. It says that:

If the flag is not set but the field contains negative values, problems might occur during screen output

I personally declare many amount fields as WRBTR & based on Debit/Credit indicator multiply with '-1'. May be i have been doing this incorrect all way wrong.

Plz clarify.

BR,

Suhas

Read only

0 Likes
1,404

I think you guys are right, this flags matters for screen output. But then it is a mystery to me how the OP is generating this problem.

Thomas

Read only

Former Member
0 Likes
1,404

Is the value is truncated when you select data from database table or when you are assigning values from some other internal tables ( Used earlier for data fetching ) to your items table.

you need to check data type of your other variables which you are using to pass data to your item internal table

Read only

0 Likes
1,404

While fetching from database

Read only

0 Likes
1,404

Hi,

1. the negative values flag at domain level is relevant only for screen input/output.

2. I got used to write

menge = - menge.

what seems to me the fastest and most transparent way.

3. the only other way to create a dump might be a numeric overflow.

Regards,

Clemens