online Classes of SAP ERP ABAP 7.4 CONTROL STATEMENTS
Module Objectives
•Define Relational Operators
•Explain Logical Expressions
•Describe IF, CASE, SWITCH and COND statements
•Explain DO and WHILE loops
•Define CHECK, EXIT, and CONTINUE statements for use with loops
IF Statement
In every Programming language, we need conditional based code in ABAP, we use IF statement when we want to execute certain code based on any condition.
for example, if the payment method is selected as credit card we want the particular code to execute and if payment method selects as cash we want some other code to execute.
IF statements code Sample |
Relational Operators
in order to compare variables we need some logical and relational operators which we can use to check the conditions and make decisions. for example, if the payment method is equal Cash then we want the certain code to execute. to check if selected payment type is cash or not we use relational operators.
Relational Operators |
Note: It is recommended to use symbols for relational operators. Ex: use <> instead of NE.
Logical Expressions
logic expressions are used to return TRUE or FALSE based on the variables values and the operator which we used please check the example below to know about logical expressions in ABAP can how can we used them.
Logical Expressions |
String Comparison Operators
string comparison operators are used to check if the string contains a particular value, word or statement or not. please check the below example to have more idea about string comparison.
String Comparison Operators |
CASE Statement
case statment is used to check the variable based on the condition it return a value, you can see in the example below,
Case Statement |
SWITCH & COND Expression
A conditional expression with the conditional operator SWITCH has a result that is specified by a case distinction. A conditional expression with the conditional operator COND has a result that is specified by logical expressions
ABAP 7.40
- If none of the conditions are met
- the variable is set
- to its default value
COND Statment Sample |
Switch Statment Sample |
DO and WHILE Loops
Do while loops is Control Flow Statement it executes the code at least once based on the block condition, it will keep executing until condition pass.
Do While loop Sample |
CHECK Statement
The line of code was only executed when the condition specified in the CHECK statement was true.
Check Statment |
EXIT Statement
The line of code was only executed three times. This is because the EXIT statement terminated the loop completely on the fourth loop pass prior to this statement.
Exit Statement |
CONTINUE Statement
The line of code was only executed once the index value was greater than 8. When the index value was less than 8, the CONTINUE statement caused this statement to be skipped.
Continue Statement |
FLAGS using ABAP_BOOL
Use the type ABAP_BOOL for flags and the constants ABAP_TRUE, ABAP_FALSE, and ABAP_UNDEFINED for operations.
Same as the previous example but using ABAP_BOOL data type and ABAP_TRUE.
Flags using ABAP Bool |
Webcrs travel is a web-based Travel and ERP for tour operators that helps travel agencies maximize their online bookings while reducing their administrative costs. You can sell your travel products via multiple channels(B2C, B2B and B2B2C) and efficiently manage your operations through our advanced back-office automation module.
ReplyDelete