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

mod function

Former Member
0 Likes
4,467

Hi,

Iam trying to devide some value with 1500.

If reminder is not zero i want to give message.

How to achieve this using "mod" functionality.

if 3000/1500 = 2.

no message.

elseif 4000/1500 = 2.66

since reminder is not 0 i have to give message.

endif.

above 4000 will be varible.can be any number.

points guaranteed

kaki

Message was edited by: Kaki R

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,444

data: number1 type i,

number2 type i,

rest type i.

number1 = 4500.

number2 = 1500.

rest = number1 mod number2.

If rest NE 0.

WRITE: / 'REST NOT ZERO'.

ENDIF.

If rest EQ 0.

WRITE: / 'REST ZERO'.

ENDIF.

7 REPLIES 7
Read only

Former Member
0 Likes
1,444

Hi

a type p.

a = 4000/1500.

if trunc ( a ) <> 2.

message.

endif.

or

if floor ( a ) <> 2.

message.

endif.

regards

vijay

Read only

Former Member
Read only

Former Member
0 Likes
1,445

data: number1 type i,

number2 type i,

rest type i.

number1 = 4500.

number2 = 1500.

rest = number1 mod number2.

If rest NE 0.

WRITE: / 'REST NOT ZERO'.

ENDIF.

If rest EQ 0.

WRITE: / 'REST ZERO'.

ENDIF.

Read only

Former Member
0 Likes
1,444

a = b mod 1500.

if a ne 0.

message.

endif.

b is your variable(4000).

a is one more temp variable

Regards

Muthappan

Read only

0 Likes
1,444

Thank u Holger Schmidt

points allowted

cheers

kaki

Read only

abdul_hakim
Active Contributor
0 Likes
1,444

Hi use the below logic,

DATA: inp1 TYPE i,

inp2 TYPE i,

res TYPE i.

(or)

PARAMETERS: inp1 TYPE i,

inp2 TYPE i.

DATA res TYPE i.

res = inp1 MOD inp2.

IF res <> 0.

give message.

ENDIF.

Abdul

Message was edited by: Abdul Hakim

Message was edited by: Abdul Hakim

Read only

Former Member
0 Likes
1,444

Hi Kaki,

check this..


REPORT  Z_TR_ALV_REMAINDER MESSAGE-ID SY            .

data: result type i.


SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME.

PARAMETERS: value type i.

SELECTION-SCREEN END OF BLOCK A.

result = value mod 1500.

if result = 0.
 MESSAGE ID 'sy' TYPE 'I' Number '001'
            WITH 'Remainder is 0.'.


else.

 MESSAGE ID 'sy' TYPE 'I' Number '001'
            WITH 'Remainder is not 0.'.

endif.

hope this helps you.

reward with points for helpfull answers and close the thread if your question is solved.

regards,

venu.