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

operator MOD is not supported!

Former Member
0 Likes
2,056

data year type i.

year = input+6(4).

IF input+8(2) EQ '00'.

IF year MOD 400 EQ '0'.

leap = 'X'.

ENDIF.

ELSEIF year MOD 4 EQ '0'

leap = 'X'.

ENDIF.

whats wrong in this code!

Thanks,

Bharat

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,229

data year type i.

data modval1 type i.

data modval2 type i.

year = input+6(4).

modval1 = year MOD 400.

modval2 = year MOD 4.

IF input+8(2) EQ '00'.

IF modval1 EQ 0.

leap = 'X'.

ENDIF.

ELSEIF modval2 EQ 0

leap = 'X'.

ENDIF.

Change it like this it will work.

data year type i.

year = input+6(4).

IF input+8(2) EQ '00'.

IF year MOD 400 EQ '0'.

leap = 'X'.

ENDIF.

ELSEIF year MOD 4 EQ '0'

leap = 'X'.

ENDIF.

whats wrong in this code!

Thanks,

Bharat

6 REPLIES 6
Read only

Former Member
0 Likes
1,230

data year type i.

data modval1 type i.

data modval2 type i.

year = input+6(4).

modval1 = year MOD 400.

modval2 = year MOD 4.

IF input+8(2) EQ '00'.

IF modval1 EQ 0.

leap = 'X'.

ENDIF.

ELSEIF modval2 EQ 0

leap = 'X'.

ENDIF.

Change it like this it will work.

Read only

0 Likes
1,229

Hi Sudhir,

Can you explain me why does the system behave like this!

Cheers,

Bharat

Read only

Former Member
0 Likes
1,229

Hi Bharat,

1) I think your intension may be of checking whether a year is leap year or not.

2) For this you need to check only on Year

3) Try with this code.

data year type i.

data year_400 type i.

data year_4 type i.

year = input+6(4).

IF input+8(2) EQ '00'.

year_400 = YEAR MOD 400.

year_4 = YEAR MOD 4.

IF year_400 EQ '0'.

leap = 'X'.

ELSEIF year _4 EQ '0'

leap = 'X'.

ENDIF

ENDIF.

In ABAP, A condition has the following form:

<var1> <op> <var2>.

Valid compare operators <op>:

EQ (=)

NE (<>, ><)

LT (<)

LE (<=, =<)

GT (>)

GE (=>,>=)

All variables, SY fields, test module parameters, SET/GET parameters and constant values can be used as variables <var1> and <var2>.

<b>So Atrthmetic expressions can not be parts of <var1> or <var2>.</b>

Thanks,

Vinay

Read only

Former Member
0 Likes
1,229

System does not interpret arithmatic expression in a logical condition.

Read only

0 Likes
1,229

Sudhir,

Do u have a link on these rules or stuff like that!

Thanks,

Bharat