Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

general abap

Former Member
0 Likes
1,000

<<Moderator message: please use meaningful subjects>>

hai abapers,

general division of two fields.

how write the expression.

suposse example : c = ( a ) / ( b ).

i expect correct or not ?

1 ACCEPTED SOLUTION
Read only

bpawanchand
Active Contributor
0 Likes
979

ABAP does not support Complex arithematic operations

for example c = (A + B) * (C + D)). Like C language

you have to write the above statement in two different steps

And

As per your expression if you want to divide two intergers then use DIV operator a special operator of ABAP

if you want to divide two different types of numbers other than intergers then you can use /

<<Moderator message: please use meaningful subjects>>

hai abapers,

general division of two fields.

how write the expression.

suposse example : c = ( a ) / ( b ).

i expect correct or not ?

7 REPLIES 7
Read only

bpawanchand
Active Contributor
0 Likes
980

ABAP does not support Complex arithematic operations

for example c = (A + B) * (C + D)). Like C language

you have to write the above statement in two different steps

And

As per your expression if you want to divide two intergers then use DIV operator a special operator of ABAP

if you want to divide two different types of numbers other than intergers then you can use /

Read only

Former Member
0 Likes
979

Hello Ram,

Yes it is correct. Please check the 'TYPE' you have declared the variables.

You can check this things by creating a sample program. Do not need to post for this.

Thanks,

Jayant

Read only

Former Member
0 Likes
979

Hi,

Ya above is correct.

Also you need not specify brackets for above condition:

c = a / b.

Thanks & Regards,

Navneeth K.

Read only

Former Member
0 Likes
979

HI

if d <> 0.

a = n / d.

endif..

regards

Deepak

Read only

0 Likes
979

HI

this is important during division..

if d <> 0.

a = n / d.

endif..

regards

Deepak

Read only

Former Member
0 Likes
979

Hi Raj,

Have a look of the below site.

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb32e2358411d1829f0000e829fbfe/content.htm

DATA: pack TYPE p DECIMALS 4,

n TYPE f VALUE '+5.2',

m TYPE f VALUE '+1.1'.

pack = n / m.

WRITE pack.

pack = n DIV m.

WRITE / pack.

pack = n MOD m.

WRITE / pack.

Cheers!!

VEnk@

Read only

Former Member
0 Likes
979

Hi,

Yeah its a perfect piece of code for division.