# How to get “IF” Statements going in SAPERION

## Aim of this article

SAPERION is not very forthcoming when it comes to documentation relating to formulas. Well, most of the documentation can be summarized as, well, vague. So I have endeavored to create a conditional statement in a text field. I will not expand on the various formulas I tried, but will give you a summary of test formulas that you can also try.

## Setup the test

Let us start with any arbitrary 2 field mask

Search, a variable field

Description, a DDC field

You should now have something like this

Now let us assign a default value to the first field, the value is =”Love Saperion”. This will be our test string

Now we will need a formula to start testing. Enter the description field. We will create a formula that tests whether there are any spaces in the @Search variable field.

To do this we will use the Pos function

Use this formula in the Default value box: **
**

**Pos (” “, @Search) > 0 ? “Yes” : “No”
**

Test the mask

Hit the test button

Is there a space? Seems like the formula is working.

Now remove the ” Saperion” form the search field and click in another field to recalculate.

It seems to work.

## But what has happened here?

Let us expand the formula to understand how the formula can resemble something like =if(1=2,True,False)

Let us start with the formula

Pos (” “, @Search) > 0 __ ?__ “Yes”

__“No”__

**:**< The logic test > __ ?__ <True>

__<False>__

**:**Now let us translate it to something perhaps more Excel-ish

IF(Find(” “,@Search) ** , **“Yes”

**“No”)**

__,__< The logic test > __ ,__ <True>

__<False>__

**,**

## Conclusion

It is quite simple, just take out some brackets and the formula makes sense. The biggest problem is testing and troubleshooting for find the right formula to work in SAPERION.

## Sample Formulas

Give theses a go as well:

SysDate:

SysTime:

MachineName

DBName

='”‘+ (Pos (” “, @Search) > 0 ? (Copy (@Search, 0, Pos (” “, @Search)) + ‘*” AND “‘ + Copy (@Search, Pos (” “, @Search)+1, Length(@Search) – Pos (” “, @Search))) : (@Search) )+’*”‘

## Further Reading

__You will find more information on SAPERION system formulas here__