Intro to ABAP - Chapter 06

W
Description

sap abap introduction, very specific,welcome download

Shared by: Guihong
-
Stats
views:
0
posted:
12/3/2012
language:
English
pages:
18
Document Sample
scope of work template
							               Control Statements




BC170_2.06.1
                        Objectives

    • The participants will be able to:
          – Use the basic Control Flow Constructs that are
            available in the ABAP Editor
          – Use the following statements in an ABAP
            Program
               • IF, CASE, DO, WHILE, ON CHANGE OF,
                 CHECK, EXIT, and CONTINUE
          – Use the Logical Expressions that are available
            in the ABAP Editor

BC170_2.06.2
               Basic Flow Control in ABAP




BC170_2.06.3
                   The IF Statement
IF X = 5.
 WRITE:/ ‘The value of X is 5’.
ELSEIF X = 6.
 WRITE:/ ‘The value of X is 6’.
ELSE .
 WRITE:/ ‘X is neither 5 nor 6’.
ENDIF.




BC170_2.06.4
               Logical Expressions
               Logical Expressions use :
                 – RELATIONAL OPERATORS
                 – LOGICAL OPERATORS
                 – STRING COMPARISON OPERATORS




BC170_2.06.5
                    Relational Operators
        Comparison                     Syntax
        Is Equal to                     =, EQ
        Is not equal to               < >, ><, NE
        Greater than                    >, GT
        Greater than or equal to     > =, = >, GE
        Less than                        <, LT
        Less than or equal to         <=, =<, LE




BC170_2.06.6
               Logical Operators



                             NOT
                             AND
                             OR

                    The hierarchy of the logical
                           operators is:
                        NOT, AND, and then OR.
                 (i.e., different from creating views)
BC170_2.06.7
        Bad
      Good Programming Practice with
            Logical Operators

               If not ( X = 0 )
               or not ( Y = 1 and
               Z = X or X = 3
               and ( Z = 5 )




BC170_2.06.8
           String Comparison Operators
       Comparison                Syntax
       Contains only               CO
       Contains any                CA
       Contains string             CS
       Contains pattern            CP
       Contains not only           CN
       Contains not any            NA
       Contains no string          NS
       Contains no pattern         NP



BC170_2.06.9
                The CASE Statement
                DATA: year(4) type c.
                …..some code to fill year variable with data…..
                CASE year.
                 WHEN ‘1997’.
                  FORMAT COLOR 6.
                 WHEN ‘1998’.
                  FORMAT COLOR 2.
                 WHEN OTHERS.
                  FORMAT COLOR 1.
                ENDCASE.


BC170_2.06.10
                      The DO Loop
DO.                             J =4.
  WRITE :/ ‘Hello world!’.      DO J TIMES.
ENDDO.                              WRITE :/ ‘Hello world!’.
                                ENDDO.




BC170_2.06.11
                   The WHILE Loop
If expression evaluates to    If expression evaluates to
TRUE, code in loop is         FALSE, code in loop is NOT
executed.                     executed, and control
                              moves to after ENDWHILE.




BC170_2.06.12
  Nested Loops and Control Structures
        DO 2 TIMES.
         WRITE :/ SY-INDEX.
         DO 3 TIMES.
          WRITE : / ‘ ‘, SY-INDEX.
         ENDDO.
        ENDDO.
The source code above would display:
    1
        1
        2
        3
    2
        1
        2
        3
  BC170_2.06.13
      The ON CHANGE OF Statement




                SELECT * FROM YCUSTOMER.
                ON CHANGE OF YCUSTOMER-COUNTRY
                  OR YCUSTOMER-STATE.
                [….]
                ENDON.
BC170_2.06.14
                ENDSELECT.
                The CHECK Statement
                              DO 10 TIMES.
                               CHECK SY-INDEX <= 4.
                               WRITE :/ SY-INDEX.
                              ENDDO.




BC170_2.06.15
                The EXIT Statement
      IF SY-SUBRC <>0.
        EXIT.
      ENDIF.




BC170_2.06.16
                The CONTINUE Statement
                                 DO 10 TIMES.
                                  IF SY-INDEX >4.
                                   CONTINUE .
                                  ENDIF.
                                  WRITE :/ SY-INDEX.
                                 ENDDO.




BC170_2.06.17
                         Summary

    • The participants should be able to:
          – Use the basic Control Flow Constructs that are
            available in the ABAP Editor
          – Use the following statements in an ABAP
            Program
                • IF, CASE, DO, WHILE, ON CHANGE OF,
                  CHECK, EXIT, and CONTINUE
          – Use the Logical Expressions that are available
            in the ABAP Editor
BC170_2.06.18

						
Shared by: 201212 29
About
download professional profile
Related docs
Other docs by Guihong
4.20統計技術程序A
Views: 0  |  Downloads: 0
审计·刘圣妮基础班·第20章(2)
Views: 2  |  Downloads: 0
鑽孔課重工成本0301月份
Views: 0  |  Downloads: 0
JapaneseChinese CgJGJqjJ4zBBpC8y
Views: 0  |  Downloads: 0
073職業性健康檢查管理規定
Views: 0  |  Downloads: 0
DOLLAR函数
Views: 0  |  Downloads: 0
電鍍危害識別
Views: 5  |  Downloads: 0
0105108 WSR方法论的一些概念和认识
Views: 17  |  Downloads: 0
06年新了解到的电路板企业
Views: 0  |  Downloads: 0
MDIS_005
Views: 0  |  Downloads: 0