Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

Welcome back to the next step in your journey to becoming a citizen developer with SAP Build Apps! In the previous blog, we explored how to create relevant variables and make them meaningful in SAP Build Apps. In this blog, I will explain what conditional logic is in a programming sense.

Conditional logic simply allows you to tell your application what to do under certain conditions. In other words, it helps you define what actions need to be taken if a specific condition is met. In many programming languages, like Java, Python, etc..we can achieve conditional logic by making use of “if/then/else” statements. That is, if a specific condition is met, then perform a specific action. Or else, if the condition is not met, perform this action instead.

To illustrate how we can use conditional logic, I will make use of 2 examples:

  1. Conditional logic for defining rules/parameters for creating classifications: let’s think about this in an everyday scenario: if the temperature is below 15 degrees Celsius, we would define the weather as “cold”. But, if the temperature is above 15 degrees Celcius, we would define the weather as warm.

Of course, we always have the possibility of expanding on this logic and adding more conditions to be checked and the actions to be taken.

  1. Conditional logic to define actions to be takenSuppose that using the previous example we have determined that the weather is cold. We can now define what actions to take given the weather classification that we have just established. If it is cold, we will define the action to be taken as wearing a jersey. Once this action is taken, we can add additional logic checks like checking whether it is raining or not. If it is raining, we can define the action to be taken as remembering to carry an umbrella. If it is not raining, no additional action needs to be taken so we need not define anything else.If it is not cold, we can define the action to be taken as wearing a T-shirt. We can also add an additional action, like remembering to drink plenty of water.

Be mindful that the order in which you define your conditions and actions are very important. Always think carefully about which conditions need to be checked in order for certain actions to take place

Now, let’s  illustrate Conditional Logic with a more technical example: you try to create a new account on an application. If the email address that you have entered is indeed a valid email address, your account will be created. However, if it is not, you may get an error message informing you that the account could not be created because your email address is invalid.

Conditional logic, is a crucial part of decision making and defining actions within applications. Now that we understand the concept of conditional logic and how it works, in the next blog, we will take a look at how to leverage it in SAP Build Apps.

Be sure to check out other Low-Code/No-Code blogs by following the community tag!

1 Comment