Download presentation
Presentation is loading. Please wait.
1
Flow of Control MINS298c Fall 1998 Chapter 9
2
Overview ABAP Programming Structures for: –Iteration –Decisions Control Flow –If … Then –Do & While loops In Class Exercise
3
Decisions Conditions are created with logical operators Simple or Compound (with parentheses) Standard Logical Operators = eq EQUAL > gt GREATER THAN <> ne NOT EQUAL < lt LESS THAN >= ge GREATER THAN or EQUAL TO <= le LESS THAN or EQUAL TO New Operators a BETWEEN b AND c means (a >= b) AND (a <= c) IS INITIAL means variable has initial condition
4
New Operators Between a BETWEEN b AND c means (a >= b) AND (a <= c) IS INITIAL means variable has initial condition Character Strings –CA : contains any characters of the right side –CO : contains only characters from right side –CS : contains string from right side ignore trailing blanks; not case sensitive –CP : contains pattern from right side use * for any char string and + for any single char
5
String Operators var1(6) value ‘ABAP/4’. IF var1 ca ‘XP’. IF var1 co ‘ABP4’. IF var1 cs ‘AA’. IF var1 cp ‘*/4’. IF var1 cp ‘*/4++’. True or False Given
6
If IF condition. process one. ELSEIF condition. process two. ELSE. process three. ENDIF. Things to watch - no THEN - periods
7
If IF condition. process one. ELSEIF condition. process two. ELSE. process three. ENDIF. 1 3 2 T T F F
8
Comparisons of different types IF a < b {where a and b are of different types} Hierarchy of conversion rules –same type then pad –one type f all type f –one type p all type p –one type d (or t) convert other –comparing n to c or to x converts all to type p –type x and type c converts x to c
9
Will it write or not? data: num1(4) value ‘124’, num2(5) value ‘00124’. if num1 = num2. write ‘numbers are equal’. endif.
10
Case Requires same item in every comparison CASE variable WHEN value1. same as (variable = value1) process1. WHEN value2. process2. WHEN value3. process3. WHEN OTHERS. catches all the other conditions process4. ENDCASE. !!! Only deals with =
11
Looping DO loops - –does at least once –may be counted or unconditional WHILE Loops –conditional: may or may do initially EXIT SY-INDEX
12
Two Dos –DO process condition to exit (Use EXIT Command) –ENDDO –DO x times process alternate condition to exit (Use EXIT Command) –ENDDO
13
While –WHILE condition process change in condition –ENDWHILE
14
Do vs While T T
15
Efficiencies Compound Conditions –ANDs put most restrictive condition first –ORs puts least restrictive condition first CASE and nested IF statements –put most likely conditions first
16
In-class Assignment #5 Create a program to display all the numbers between 0 and 100 and report which are divisible by 2, 3, or 5 Assignment 5 MINS298c Spring 1998 Number Divisible by 2 3 5 1 no no no … 30 yes yes yes
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.