Application Development 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: 

Want to put a condition based on IF Statement.

Former Member
0 Kudos

Hi.

I have a situation in which there is a specific code which I want to skip if say sales organisation is 'A' or 'B' or 'C' or 'D'.

and if I write

if sales org ne 'A'

OR sales org ne 'B'

OR sales org ne 'C'

OR sales org ne 'D'

then only perform my coding.

This kind of logic doesnt work.

Please tell me how shall I proceed?

Thanks.

8 REPLIES 8

Former Member
0 Kudos

Hi subhash,

1. do not write like this.

2. use like this.

(just copy paste)

3.

report abc.

PARAMETERS : P TYPE C.

IF NOT ( P = 'A' OR P = 'B' OR P = 'C' OR P = 'D' ).

WRITE 😕 'OK'.

ELSE.

WRITE 😕 'NOT OK'.

ENDIF.

regards,

amit m.

0 Kudos

Hi,

You have to use AND instead of OR ie

IF sales org ne 'A'

AND sales org ne 'B'

AND sales org ne 'C'

AND sales org ne 'D'.

***

ENDIF.

Regards,

Suresh Datti

abdul_hakim
Active Contributor
0 Kudos

use the below logic..

IF SALESORG EQ 'A' OR

SALESORG EQ 'B' OR

SALESORG EQ 'C' OR

SALESORG EQ 'D'.

CONTINUE.

<Ur code for validations...>

ENDIF.

Cheers,

abdul

Former Member
0 Kudos

hi,

write as

IF ( sales org <> 'A' )

OR ( sales org <> 'B' )

OR ( sales org <> 'C' )

OR ( sales org <> 'D' ).

-


-


ENDIF.

HOPE THIS HELPS,

PRIYA.

Former Member
0 Kudos

Hi Subhash,

you can use <i>case statement</i>

case sales_org.

when 'A' or 'B' or 'C' or 'D'.

do anything skipping the code.

when others.

specify code here.

endcase.

regards,

Kinshuk

former_member181962
Active Contributor
0 Kudos

YOu can also do this way:

if not sales_org in ( 'A', 'B', 'C', 'D' ).

*do something.

endif.

Regards,

Ravi

Former Member
0 Kudos

Hey Subhash,

Try this logic :

<b>Case <sales_org> .

When 'A'.

When 'B'.

When 'C'.

When 'D'.

When Others .

  • do that specific code.

Endcase.</b>

Sample code to prove this point :

data sales_org type c value 'F'.

Case sales_org .

When 'A'.

When 'B'.

When 'C'.

When 'D'.

When Others .

write : sales_org.

endcase.

Regards,

Kunal.

Former Member
0 Kudos

Hai Subash

report Zxyz.

PARAMETERS : P_sal TYPE C.

IF P_sal NOT in ( 'A' , 'B' ,'C' ,'D' ).

WRITE 😕 'OK'.

ELSE.

WRITE 😕 'NOT OK'.

ENDIF.

Thanks & regards

Sreenivasulu P