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 Statment
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
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 Expression
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
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
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
Switch Statment
COND Statment Sample


Switch 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
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
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
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
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.

Abap_flags
Flags using ABAP Bool


Comments

  1. 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

Post a Comment

Popular posts from this blog

SAP ABAP SELECT STATEMENT

SAP ADOBE FORMS

ABAP AUTHORIZATION CONCEPT