2023 Jan 20 6:41 AM
i have num1 and num2 i want to find percentage in sap abap.
2023 Jan 20 6:49 AM
data(percentage) = cond #( when num2 ne 0
then ( num1 / num2 ) * 100
else 0 ).
2023 Jan 20 7:08 AM
2023 Jan 20 7:19 AM
I should add a raise exception, but ... too early in the morning 😉
2023 Jan 20 8:06 AM
Not ABAP, mathematics. You are not clear in your question: do you want to know how much num1 represents in num2, or vice versa? A number between 0 and 100? With any number of decimals?
2023 Jan 24 6:24 PM
Hi aravindcsebe,
PARAMETERS: num1(6) type n,
num2(6) type n.
data:
val(3) type n,
val2(3) TYPE n.
val = ( ( num1 ) / ( num1 + num2 ) ) * 100.
val2 = 100 - val.
write:/ val, val2.
this is the report for find percentage of two numbers.
I hope you understand,
If it helps, please accept this answer.
Regards,
Berinath Ulisi.