1 / 16

Flow of Control

Flow of Control. MINS298c Fall 1998 Chapter 9. Overview. ABAP Programming Structures for: Iteration Decisions Control Flow If … Then Do & While loops In Class Exercise. Decisions. Conditions are created with logical operators Simple or Compound (with parentheses)

fremont
Download Presentation

Flow of Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 Given 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

  6. If IF condition. process one. ELSEIF condition. process two. ELSE. process three. ENDIF. Things to watch - no THEN - periods

  7. If F T IF condition. process one. ELSEIF condition. process two. ELSE. process three. ENDIF. 1 F T 2 3

  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

More Related