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 and Div

rnb86
Participant
0 Likes
1,786

Hi friends,

if ( ( n MOD 2 ) == 0 ).

when i say this in my syntax, it throws an error saying that mod is not supported. Can anybody tell me why. As far as i knw, it is the right syntax.

please correct me if im wrong.

Same is the error even for Div operator too.

im trying to display only even numbers in this particular program.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,119

double == is not required

v_var = n mod 2.

if v_var eq 0

6 REPLIES 6
Read only

Former Member
0 Likes
1,120

double == is not required

v_var = n mod 2.

if v_var eq 0

Read only

Former Member
0 Likes
1,119

Hi,

Please try this.

if ( ( n MOD 2 ) = 0 ).

...

else.

...

endif.

Regards,

Ferry Lianto

Read only

0 Likes
1,119

Hi ferrry,

thanx for your suggestion, but i trie with single "=" also, but i havnt got the output.

I got the answer to my question but what i need is that why the output is not displayed when i say n mod 2 = 0 is my query.

Read only

0 Likes
1,119

Hi Raghu,

When u say mod it means that the remainder is zero for e.g 4 MOD 2 = 0 ,

if this condidtion is satisfied then only the output is displayed.

Just Try out this.

report test.

parameter : p_n1 type i.

data : g_result type i.

compute g_result = p_n1 mod 2.

if g_result = 0.

write 'Remainder is zero'.

else.

write 'Remainder is not zero'.

endif

Regards,

Vaibhav B Gawali.

Read only

0 Likes
1,119

Thank you Pragya and Vaibhav.

<b>I did not knw that the mod and div operatoions can't be performed within the if condition</b>. Thank you Pragya for your answer.

And as for Vaibhav, thank you for your answer too. I know the logic and i already finished this report. But i wanted to knw why the mod was not working in the IF condition.

Thanks to you all, my doubt has been clarified.

Regards,

Raghu.

Read only

Former Member
0 Likes
1,119

Hi Raghu,

we can not use mathematical computation in If expression.

you may calculate the vaue first and then can compare to zero.

e.g.

var2 = var1 mod 2.

If var2 = 0.

...

else

...

endif.

Regards,

Pragya