Problem with division as output is either 0 or 1 when using ifthenelse condition in ABAP program

The problem is that your second parameter is 0 which is an integer, so the output always comes as an integer as ifthenelse takes data type from the second parameter. So, in your case, if the answer is less than .5, it is converted to zeroes and in case more than .5, it is converted to 1. You would require to use cast for the second parameter to convert it to decimal data type as follows

 ifthenelse(Query.Den= 0, cast(0, 'Decimal(16, 02)'), Query.Num / Query.Den)
Rishi Raj
Rishi Raj

I am a coder