
{
//Division
division(10,3,4) as value1, // [Ans:3.3333]
div(55,5) as value2, // [Ans:11]
(10.5 / 3.2) as value3, // [Ans:3.28125]
// multiplication
(10 * 3) as value4, // [Ans:30]
(10 *6 * 3) as value5, // [Ans:180]
//Modulo
mod(2,3) as value6, // [Ans:2]
// Addition
(2 +3) as value7, // [Ans:5]
(2.2 + 3.7) as value8, // [Ans:5.9]
// (2 + 3.7) as value8--> is not possible as both are different data types
//subtraction
(2 -3) as value9, // [Ans:-1]
(21 -1) as value10, // [Ans:20]
(21.5 - 1.7) as value11, // [Ans:1.98]
//(21.5 - 1) as value11--> is not possible as both are different data types
//BODMAS
(2+3-4*3) as value12, // [Ans:-7]
cast( 2+3-4*3 as abap.fltp)/ 2.0 as value13 // [Ans:-3.5]
// As ‘/’ only support fltp data type, we changed to fltp
}
Suppose we have a parameter1 as CHAR datatype but need to perform an Arithmetic operation like addition, we can’t directly change CHAR to INT as shown in the image.
So, in such a case, we can change CHAR datatype to INT by having NUMC as intermediate,
CHAR --> NUMC --> INT
cast ( cast (parameter1 as abap.numc( 8 )) as abap.int8)as datatype_int
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
7 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 | |
4 | |
4 |