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: 

Help me

Former Member
0 Kudos
123

Hi Experts,

i have coded like this. But this condition is not working fine. how to code it?

if cdpos-tabname eq 'DMAKT'

or cdpos-tabname eq 'MARA'

or cdpos-tabname eq 'MAKT'.

do something...

elseif cdpos-tabname ne 'DMAKT'

or cdpos-tabname ne 'MARA'

or cdpos-tabname ne'MAKT'.

do something.

else.

do something.

endif.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
93

Hi silviya,

1. try giving brackets, like this.

(and give just one ELSE)

(no ELSEIF)

2.

if ( cdpos-tabname eq 'DMAKT'

or cdpos-tabname eq 'MARA'

or cdpos-tabname eq 'MAKT') .

do something...

<b> else.</b>

ENDIF.

regards,

amit m.

8 REPLIES 8

Former Member
0 Kudos
94

Hi silviya,

1. try giving brackets, like this.

(and give just one ELSE)

(no ELSEIF)

2.

if ( cdpos-tabname eq 'DMAKT'

or cdpos-tabname eq 'MARA'

or cdpos-tabname eq 'MAKT') .

do something...

<b> else.</b>

ENDIF.

regards,

amit m.

0 Kudos
93

hi silviya,

put the if condition in <b>BRACKETS</b>

if ( cdpos-tabname eq 'DMAKT' )

or ( cdpos-tabname eq 'MARA' )

or ( cdpos-tabname eq 'MAKT' ).

Regards,

Santosh

0 Kudos
93

if cdpos-tabname eq 'DMAKT'

or cdpos-tabname eq 'MARA'

or cdpos-tabname eq 'MAKT'.

do something...

else.

do something.

Former Member
0 Kudos
93

HI,

TRY PUTTING THE CONDITIONS IN BRACKETS.

LIKE

IF ( CDPOS-TABNAME = 'DMAKT' ) OR ( CDPOS-TABNAME = 'MARA' ) OR ( cdpos-tabname eq 'MAKT').

do something.

ELSE.

do something

ENDIF.

THANKS,

PRIYA

Former Member
0 Kudos
93

Hi

I can't understand what you really want to do, but where you use NE option you should'nt use OR but AND

elseif cdpos-tabname ne 'DMAKT' <----


or cdpos-tabname ne 'MARA' <----


or cdpos-tabname ne'MAKT'. <----


elseif cdpos-tabname ne 'DMAKT' <----


AND cdpos-tabname ne 'MARA' <----


AND cdpos-tabname ne'MAKT'. <----


Remember: NEVER NEVER NEVER use NE together OR because the condition is always true, example.

MY_NAME = 'MAX'.

IF MY_NAME <> 'MAX' OR

MY_NAME <> 'BOB'.

-


> It's true because MY_NAME <> 'BOB'

MY_NAME = 'BOB'.

IF MY_NAME <> 'MAX' OR

MY_NAME <> 'BOB'.

-


> It's true because MY_NAME <> 'MAX'

MY_NAME = 'TIM'.

IF MY_NAME <> 'MAX' OR

MY_NAME <> 'BOB'.

-


> It's true because MY_NAME <> 'MAX' and MY_NAME <> 'BOB'

Max

Former Member
0 Kudos
93

Hai thomas,

Just check this out...

if ((cdpos-tabname eq 'DMAKT')

or (cdpos-tabname eq 'MARA')

or (cdpos-tabname eq 'MAKT')).

do something...

elseif ((cdpos-tabname ne 'DMAKT')

or (cdpos-tabname ne 'MARA')

or (cdpos-tabname ne'MAKT')).

do something........

else.

do something.

endif.

Regards,

Srikanth.

Reward points if helpful.

Former Member
0 Kudos
93

Hi Silviya,

Is it syntax error or execution error?

It shouldn't be a syntax error. There is no problem in writing the IF condition.Needn't hav to put in brackets.

Isn't cdpos is an internal table with header line?

Try giving like this.

if cdpos-tabname eq 'DMAKT' or cdpos-tabname eq 'MARA'

or cdpos-tabname eq 'MAKT'.

do something.

else.

do something.

endif.

no need of the second if condition.

Regards,

Sylendra.

Former Member
0 Kudos
93

Hi Silviya,

you can consider writing a <b>CASE</b> statement.


  case cdpos-tabname.
    when 'DMAKT' or 'MARA' or 'MAKT'.
       do something...
    when others.
      do something.
  endcase.

regards,

Kinshuk Saxena