cancel
Showing results for 
Search instead for 
Did you mean: 

If Statement in SAP Scripts

Former Member
0 Kudos

Hi All,

I have written the below If statement in SAP scripts but when i execute the same the controll doent check the second line entries. If firtst line doesnot satisfy it goes to the else part. Kindly suggest what is wrong in this..

/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR

/: &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR

/: &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR

/: &T156T-BWART& = '343' OR &T156T-BWART& = '344'.

/: ELSE

/: ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please ignore my above comment and try with the following code

Extended command is /=

/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR
/= &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR
/= &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR
/= &T156T-BWART& = '343' OR &T156T-BWART& = '344'.

/: ELSE

/: ENDIF.

Hope this helsp you.

Regards,

Rajani

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi,

You can also try this,



/: IF '321,322,349,350,312,326,343,344' CS &T156T-BWART&.
* ----
* ----
/: endif

Regards,

Vik

Former Member
0 Kudos

Hi Neha,

[Conditional Text: IF|http://help.sap.com/saphelp_45b/helpdata/en/d1/80325f454211d189710000e8322d00/content.htm]

Regards,

Sravanthi

Former Member
0 Kudos

can we use

IF var IN ( 'A' , 'B' ).

kesavadas_thekkillath
Active Contributor
0 Kudos

neha just try my idea once ...

Former Member
0 Kudos

Hi Neha,

any of these below tags will not work in this case.

/E, /:, space, /=, =

the only solution to your problem is to break the code in multiple IF conditions. which is not poosible too because you are using 'OR' conditions.

So the simplest way wiill be to write a PERFORM (subroutine) and inside that under these conditions set a flag and use that flag value to decide for further printing.

If you need any exaple for the PERFORM writing please let me know.

Regards,

Raj Gupta

kesavadas_thekkillath
Active Contributor
0 Kudos

instead check all tose conditions in your program and set a flag variable if true.

ex:

if a = 1 or a = 2 or a = 3 ...

flag = 'X'.

endif.

in your script

if &flag& = 'X'.

else.

endif.

sridhar_meesala
Active Contributor
0 Kudos

Hi,

Try like this.

/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR
= &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR
= &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR
= &T156T-BWART& = '343' OR &T156T-BWART& = '344'.

/: ELSE

/: ENDIF.

Thanks,

Sri.

Former Member
0 Kudos

Hi,

Since the second line is a continuation of the first line , you need to give spaces for the other lines,

And you must try to fit it in one line using Shift + F8 when you reach the end of first line.

Regards

Sajimon Chandran

Former Member
0 Kudos

hI sajimon,

Does hift + F8 worksonly one time..?

Former Member
0 Kudos

Hi neha,

Try to use the '/E' fo rnext line

/E->Extended line

Here is a code:

/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR
/E  &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR
/E  &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR
/E &T156T-BWART& = '343' OR &T156T-BWART& = '344'.

/: ELSE

/: ENDIF.

Hope this helps you.

Regards,

Rajani

Former Member
0 Kudos

Try this way.

/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR

/ &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR

/ &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR

/ &T156T-BWART& = '343' OR &T156T-BWART& = '344'.

/: ELSE

/: ENDIF.

Former Member
0 Kudos

not its not working

Former Member
0 Kudos

Hi,

In scripts you ahve to specify an single command statement in a single line if there is a if statement it has to be in a single line only. Change your code so that each if condition is limited to a single line.

REgards,

Himanshu

Former Member
0 Kudos

Hi,

Write the whole if statement in the same line and check. When you reach the end of line hit SHIFT+F8 to extend the line and continue with the if statement in the same line.

Regards,

Vik

GauthamV
Active Contributor
0 Kudos

use space instead of /: in next line.


/: IF &T156T-BWART& = '321' OR &T156T-BWART& = '322' OR
   &T156T-BWART& = '349' OR &T156T-BWART& = '350' OR
   &T156T-BWART& = '312' OR &T156T-BWART& = '326' OR
   &T156T-BWART& = '343' OR &T156T-BWART& = '344'.

/: ELSE

/: ENDIF.