Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Incorrect logical expression: Comparison / SELECT-OPTION can only be follow

Hi,

I'm new to ABAP, please help me with the below code. When i check the code i get the message "E:Incorrect logical expression: Comparison / SELECT-OPTION can only be followed by "AND", "OR" or ")".

data: pphd(7) type p decimals 2,

ppha(7) type p decimals 2,

abs_pphd(7) type p decimals 2.

if pphd >= 0.

if pphd < 1.

ppha = 0.

elseif 1 <= pphd <= 4.

ppha = '0.16'.

elseif 4.01 <= pphd <= 8.

ppha = '0.32'.

elseif 8.01 <= pphd <= 12.

ppha = '0.50'.

elseif 12.01 <= pphd <= 16.

ppha = '0.66'.

elseif 16.01 <= pphd <= 20.

ppha = '0.83'.

elseif 20.01 <= pphd <= 24.

ppha = '1.00'.

elseif 24.01 <= pphd <= 28.

ppha = '1.16'.

elseif 28.01 <= pphd <= 32.

ppha = '1.32'.

elseif pphd >= 32.

ppha = '1.50'.

endif.

else.

abs_pphd = abs( pphd ).

if abs_pphd < 1.

abs_ppha = 0.

elseif 1 <= abs_pphd <= 4.

ppha = '-0.16'.

elseif 4.01 <= abs_pphd <= 8.

ppha = '-0.32'.

elseif 8.01 <= abs_pphd <= 12.

ppha = '-0.50'.

elseif 12.01 <= abs_pphd <= 16.

ppha = '-0.66'.

elseif 16.01 <= abs_pphd <= 20.

ppha = '-0.83'.

elseif 20.01 <= abs_pphd <= 24.

ppha = '-1.00'.

elseif 24.01 <= abs_pphd <= 28.

ppha = '-1.16'.

elseif 28.01 <= abs_pphd <= 32.

ppha = '-1.32'.

elseif abs_pphd >= 32.

ppha = '-1.50'.

endif.

endif.

Thanks,

AM

Tags:
Former Member
Former Member replied

1, 4, 4.01 should be inside quotes:

elseif pphd between '1.00' and '4.00'.

Also be careful when comparing characters and decimals. Characters are compared left to right.

Better use:

CONSTANTS: c_1 type p decimals 2 value '1.00',
                      c_4 type p decimals 2 value '4.00'.

.....
elseif pphd between c_1 and c_4.

and similiar.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question