cancel
Showing results for 
Search instead for 
Did you mean: 

Grouping the logical expressions in IF condition is not working

Former Member
0 Kudos

Hi Experts,

My requirement is to group the logical expressions in IF condition like the below

I tried it like

IF ( &NAST-KSCHL& = 'ZBE0' OR &NAST-KSCHL& = 'ZBEC' ) AND ( &VBDKR-SPRAS& <> 'F' )

code...

ELSEIF

Code....

ELSE

code...

ENDIF

But the system is showing the grouping in the IF condition is wrong. The problem is i am not supposed to break that AND condition and put it as another IF inside the first IF condition.

Pls provide your valuable inputs.

Thanks,

Srinivas

Accepted Solutions (0)

Answers (5)

Answers (5)

maciej_domagaa
Contributor
0 Kudos

You may try something like this:


IF &NAST-KSCHL& = 'ZBE0' OR &NAST-KSCHL& = 'ZBEC' 
DEFINE KSCHL_ZBE = 'X'
ELSE
DEFINE KSCHL_ZBE = ' '
ENDIF

IF KSCHL_ZBE = 'X' AND &VBDKR-SPRAS& NE 'F'
code...
ELSEIF
Code....
ELSE
code...
ENDIF

satyajit_mohapatra
Active Contributor
0 Kudos

As per my knowledge, you can't have brackets in IF condition in SAPSCRIPTS and also you can't continue it to second line.

I think you have to restructure your condition based on that.

IF ( &A& EQ '1' OR &A& EQ '2') AND ( &B& EQ '1' ).

ENDIF.

is same as

IF &A& EQ '1' OR &A& EQ '2'

IF &B& EQ '1' .

ENDIF.

ENDIF.

Former Member
0 Kudos

Hi ,

Thanks for your valuable inputs.Sorry there was a mistake in the code which I have posted.Below is the correct statement

( &VBDKR-SPRAS& NE 'F' )

Jorge,

Thanks for pointing it out.

Lokesh,

Actually I am not supposed to split that logical condition , I want that to be a single conditional statement itself.

Former Member
0 Kudos

Are you having a customized print program for this script?

If yes you can also try to code these in print program itself and then bring the condition in the script editor..

May be something like that:

data: w_flag type flag, 
         w_flag_2 type flag. 

  IF ( NAST-KSCHL = 'ZBE0' OR NAST-KSCHL = 'ZBEC' ) AND ( VBDKR-SPRAS = 'F' ) 

    w_flag = 'X'. 

  elseif <another condition> 

    w_flag_1 = 'X'. 
  endif. 

and so on....

And call this w_flag and w_Flag_2 in script editor if the same way...

Edited by: Lokesh Tarey on May 26, 2010 1:04 PM

Former Member
0 Kudos

Hi,

Sometimes to play with sap script editor becomes very much difficult if you have scenario like as you mentioned..

Type this, and i hope it will work..

/:     IF &NAST-KSCHL& = 'ZBE0' OR &NAST-KSCHL& = 'ZBEC'    
/:     IF &VBDKR-SPRAS& =  'F' 

your code.. 

/:     ENDIF 
/:     ELSEIF <LOGICAL EXP>
/:     IF &VBDKR-SPRAS& =  'F' 

your code.. 

/:     ENDIF 
/:     ENDIF

Now please try to use one more IF statement, give the logical expression same as in ELSEIF

Although it is time consuming but sill you can try..

Edited by: Lokesh Tarey on May 26, 2010 12:30 PM

Former Member
0 Kudos

Hi,

check your code in ( &VBDKR-SPRAS& 'F' ) since it is wrong. It must be like this:

( &VBDKR-SPRAS& = 'F' )