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

Decimal data type multiplied by quantity data type

rnb86
Participant
0 Likes
1,855

Hi all,

i have a requirement where i have to multiply 3 fields, and get that result into fourth field.

example:

data: f1 type dec, [Data type - Decimal; length 7]

f2 type dec, [Data type - Decimal; length 7]

f3 type quan. [Data type - Quantity; length 17]

data: f4 type ??

f4 = f1 * f2 * f3.

what will the data type of field f4?

Will field f4 be of decimal type. If yes, then what is the declaration syntax of f4.

can i declare it as:

data: f4 type dec.

When i do this, i get an error saying type DEC is unknown.

NOTE: For your information.I AM IMPLEMENTING THIS IN A method inside a BADI.

Points will be rewarded.

Thanks in advance.

4 REPLIES 4
Read only

Former Member
0 Likes
860

Hi

There's not a real difference beetween a quan and decimal number, because both number are decimals number, anyway the quan is a decimal number with a dimension: the unit of measure.

So your fourth number should be a quan number too: if you multiply a number and quantity u'll obtain a quantity.

It's very important the size of that number because you need to prevent a dump for overflow, probably it can quan number of the same size of f3.

Max

Read only

0 Likes
860

Hi Max,

thanks for your answer. That was really helpful. The data type of the fourth field will be quan, and i will keep in mind the size of the quan field(f4).

Read only

0 Likes
860

Hi Max,

can you give me the syntax for declaring the field using a quan data type.

Read only

0 Likes
860

Hi

U need to use a reference to a dictionary field (like MSEG-MENGE) because there isn't an abap type to be used, the data type are only these:

C Character

N Numeric string

D Date (YYYYMMDD)

T Time: HHMMSS)

X Byte (hexadecimal)

I Integer

P Packed number

F Floating point number

STRING String Variable empty string

If there isn't a dictionary field good for you, u can only use the type P.

So or:

DATA F4 TYPE MSEG-MENGE. (this field has 3 decimals)

or

DATA F4(16) TYPE P DECIMALS 2.

Max