We can help. Together we learn....

Maths in ABAP

by Voice | Monday, October 20, 2008 in |

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.

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.

Data: v_string type char10,
v_num(10) type numc.

v_string = 12wer34op.
v_num = v_string.

Write: v_num.

Output: 1234.

Try it.

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.

1 comments:

  1. Unknown on January 22, 2016 at 5:35 PM

    Thanks for a great information in your blog.I have read all the post of your blog.Great work on SAP SF

     

Categories