Skip to Content
avatar image
Former Member

Grouping the logical expressions in IF condition is not working

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    May 26, 2010 at 10:04 AM

    Hi,

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

    ( &VBDKR-SPRAS& = 'F' )

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 26, 2010 at 10:27 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 26, 2010 at 10:39 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • May 26, 2010 at 11:55 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • May 27, 2010 at 12:58 PM

    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
    

    Add comment
    10|10000 characters needed characters exceeded