Maths in ABAP

sap yard
Share on Facebook36Share on LinkedIn21Tweet about this on TwitterShare on Google+1
Please Share!!

Being an Engineering student, I am bit inclined towards Mathematics. A few months ago when I wanted to write a program to find out prime numbers, I felt the need of ABAP command which can give me remainder (something like % in C). Finally I found it out and here are some compilations of such ABAP commands.

Finding the absolute value of a number: |a| -> ABS( a ).
Finding the lowest integer greater than a: CEIL( a ).
Finding the greatest integer less than a: FLOOR( a ).
For trigonometric operands, try ACOS, COS, etc
Finding the square root of a, a > 0: SQRT( a )
Finding the length of characters in the string: STRLEN( a )
Finding remainder a/b: a MOD b.

[adToAppearHere]

If you want to remove characters from any string which has both characters and numbers then there is an easy trick.

Suppose, you have an string like 12wer34op. Take a variable which is type NUMC and assign string to this variable and you will have only integers.

Food for thought:
With the hint above, what do you think would be the output v_num. Please write it at the comment section before you write the code in your system and execute the program. It would be fun. We are sure, you would be amazed with the output.

If you like Maths, you would also like to read our other post, Do all ABAPers know Fixed Point Arithmetic?

We all know ABAP is very simple language and help is present just with one click. Still I face problems now and then with all the help present on the net, I feel a quick tip from a friend/colleague is more helpful. We can help you with our experience. We can help and together we can learn.

If you want to get such practical issues and resolutions straight to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share button at the left side of your screen.

Thank you very much for your time!!

 

Share on Facebook36Share on LinkedIn21Tweet about this on TwitterShare on Google+1
Please Share!!

About the Author

Bhavesh K Ratnam
Bhavesh K Ratnam
Qualification: B.Tech, M.Tech from IIT Kharagpur, India. SAP ABAP Experience since 2006. Find more about him on LinkedIn.

2 Comments on "Maths in ABAP"

  1. I was almost betting that the output would be 120003400 . Nice .

Please help us improve. Please Shout Often & Loud!!