cancel
Showing results for 
Search instead for 
Did you mean: 

IF condition in Sapscript

Former Member
0 Kudos

Hi all,

Have created a new window in one of the scripts recently.

I was asked to display this window( with some data) only for company code NL01.

So I kept the condition , IF reguh-zbukr = 'NL01'..and wrote the code..

Now Im asked to extend the functionality to some other company codes..

I have written code lke this..pls suggest whether it is correct or not...( I cant test this now..but no test data available as of now..so need your help..Thanks)

/:IF &REGUH-ZBUKR& = 'NL01' OR  &REGUH-ZBUKR& = 'BE01' OR
/=  &REGUH-ZBUKR& = 'BE02'
ZI  Sold to
/:   ENDIF

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Your code is ok, but you don't use /=, you should write the IF condition on the same line:

/:   IF &REGUH-ZBUKR& = 'NL01' OR  &REGUH-ZBUKR& = 'BE01' OR  &REGUH-ZBUKR& = 'BE02'
ZI  Sold to
/:   ENDIF

Max

Former Member
0 Kudos

Max notes correctly...but you might also consider:


/: DEFINE &CO_SWITCH& = ' '
/:PERFORM CHECK_COCO IN PROGRAM(your routines program)
/:USING &REGUH-ZBUKR&
/:CHANGING &CO_SWITCH&
/:ENDPERFORM.
/: IF &CO_SWITCH& eq 'X'
ZI  Sold to
 . . . .
/: ENDIF.

Your CHECK_COCO routine would examin the value passed in and determine whether or not to set &CO_SWITCH ON or OFF. This would allow you to read rows of customizing table or variables table, or apply logic to determine on/off, and you would not have to change your SAPScript in the future if the requirements changed.

Former Member
0 Kudos

Max,

There isnt much space..to keep the whole IF condition in one line..

So have used '/=' for continuation...

Now my doubt is whether to use.. "/" or '=' or '/=' for continuation?

Pls suggest..

Thanks,

Priya

Former Member
0 Kudos

Hi Priya,

Then in this case in the Change Editor of the Script place the cursor in the IF Condition Line and follow the menu path EDIT--->PAGE LEFT/RIGHT which will take care of it.

Let me know in case of any.

Regards,

SRinivas

former_member203305
Active Contributor
0 Kudos

Hi,

If it was working before with one company and u just want to add more companies to the IF sentence, what u r doing is correct.

just OR..company OR..company..

That's all.

Regards