You are on page 1of 21

ABAP Training

Programming in ABAP

Basic Program Structure


Controlling the Flow of an ABAP Program
ABAP Training Programming in ABAP 2

Objectives

 Aim is to introduce concepts associated with creating and executing


an ABAP program, including
 Defining program attributes

 Understanding the modular nature of an ABAP program

 Structure & syntax of ABAP statements

 Declarative & operational keywords, & comments

 Flow control in ABAP

 External control - event handling

 Internal control - IF, CASE, LOOP, ...


ABAP Training Programming in ABAP 3

Programming in ABAP
 basic program structure
 program attributes

 Type

 Status

 Application

 Authorization groups

 Selection screen

 Development class

 source code

 Statements and Comments

 execution of ABAP programs


 flow control in ABAP
ABAP Training Programming in ABAP 4

Creating New Program


ABAP Training Programming in ABAP 5

Program Attributes

 Program Type
 Executable program

 generates lists

 Include program

 contains code that cannot be executed on its own

 must be called from another program with an INCLUDE

statement
ABAP Training Programming in ABAP 6

Program Attributes

 Program Type
 Module pool

 processing steps for screen module

 executed with a transaction code or menu function

 Function group

 called from an application program using CALL FUNCTION

 Subroutine pool
ABAP Training Programming in ABAP 7

Program Attributes

 Program Type
 Interface pool

 Interfaces for local classes

 Class pool

 Local classes
ABAP Training Programming in ABAP 8

Program Attributes

 Program Status
 indicate the status of a program development:

 SAP Standard production program

 Customer production program

 System program

 Test program
ABAP Training Programming in ABAP 9

Program Attributes

 Application
 specifies the R/3 application area for which this program is

relevant:
 Basis or System Program

 Financial Accounting

 Human Resources, Planning

 Materials Management ...


ABAP Training Programming in ABAP 10

Program Attributes

 Authorization groups
 specifies the group authorized to view and modify the

program
ABAP Training Programming in ABAP 11

Program Attributes

 Development class
 Describes the area the program belongs to

 Determines the transport layer and transport attributes of

the program
 Begins with A..S or u..X

 SAP standard objects (customer objects can not be

created here)
 Changes to objects recorded by workbench organizer

 Can be transported
ABAP Training Programming in ABAP 12

Program Attributes

 Development class
 Begins with Y or Z

 Customer objects

 Changes recorded in workbench organizer

 Can be transported

 Begins with $

 Local class

 Changes not recorded in workbench organizer

 Cannot be transported
ABAP Training Programming in ABAP 13

Source Code

 An ABAP program has a modular structure


 All programs consist of a series of modules

 Simplest is just one module

 Syntax clearly separates individual processing blocks

 Sequential execution of code lines within processing blocks


ABAP Training Programming in ABAP 14

ABAP Modules
 Subroutines
Form....ENDFORM
 Functions
Function....ENDFUNCTION
 Processing blocks for events
<Event keyword>
Event statements
<Event keyword>
Event statements
 Modules of a module pool
Module....ENDMODULE
ABAP Training Programming in ABAP 15

ABAP Modules

 Sequential coding within processing blocks


 General control flow statements

 IF, DO, WHILE, (no GOTO)

 Reports
 Collections of processing blocks that the system calls

depending on events
 Dialog programs
 Collections of processing blocks (module pool) that are called by

screen flow logic


ABAP Training Programming in ABAP 16

Syntax Elements

 Statements
 Each statement begins with a keyword and ends with a period

WRITE ‘my first ABAP’.


 Comments
 Flagged by * at the beginning of the line or ‘‘ anywhere along the

line
 Keywords
 Determines the meaning of the entire statement
ABAP Training Programming in ABAP 17

Syntax Elements - Keywords

 Types
 Declarative keywords

 Define data types or declare data objects the program

can access
 Data types tables constants parameters
 Control keywords

 Control the flow of a program within a processing block

 If, while, case


ABAP Training Programming in ABAP 18

Syntax Elements - Keywords

 Types
 Operational keywords

 Process the data (as defined by the declarative

keywords)
 Move, add, write

 Calling keywords

 Call processing blocks in the same or other program

 Perform, call, submit, leave to


ABAP Training Programming in ABAP 19

Syntax Elements - Keywords

 Types
 Modularisation keywords

 Define processing blocks in a program

 Event keywords

 Associated processing blocks are executed when the

relevant even t occurs


 At selection screen, start-of-selection,...

 Defining keywords

 Associated processing blocks are executed as soon

as they are called by an explicit statement or in


screen flow logic
 Form, function, module, ...
ABAP Training Programming in ABAP 20

Execution of ABAP Programs

 A special runtime environment is required to execute an ABAP


program
 ABAP processor which communicates with the list processor

and the dialog processor


 Calls the individual modules according to established rules
ABAP Training Programming in ABAP 21

Conclusion

 Examined concepts associated with the creation and execution of


an ABAP program
 Program attributes

 Includes, type, application, development class

 Basic program structure

 Modular nature of ABAP programs

 Forms, functions

You might also like