21
Training Programming in ABAP Programming in ABAP Basic Program Structure Controlling the Flow of an ABAP Program

Programming in ABAP

Embed Size (px)

Citation preview

Page 1: Programming in ABAP

ABAP Training

Programming in ABAPProgramming in ABAP

Basic Program StructureControlling the Flow of an ABAP Program

Page 2: Programming in ABAP

Programming in ABAP 2

ABAP Training

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

Page 3: Programming in ABAP

Programming in ABAP 3

ABAP Training

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

Page 4: Programming in ABAP

Programming in ABAP 4

ABAP Training

Creating New Program

Page 5: Programming in ABAP

Programming in ABAP 5

ABAP Training

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

Page 6: Programming in ABAP

Programming in ABAP 6

ABAP Training

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

Page 7: Programming in ABAP

Programming in ABAP 7

ABAP Training

Program Attributes

Program Type Interface pool

Interfaces for local classes Class pool

Local classes

Page 8: Programming in ABAP

Programming in ABAP 8

ABAP Training

Program Attributes

Program Status indicate the status of a program development:

SAP Standard production program Customer production program System program Test program

Page 9: Programming in ABAP

Programming in ABAP 9

ABAP Training

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

Page 10: Programming in ABAP

Programming in ABAP 10

ABAP Training

Program Attributes

Authorization groups specifies the group authorized to view and modify

the program

Page 11: Programming in ABAP

Programming in ABAP 11

ABAP Training

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

Page 12: Programming in ABAP

Programming in ABAP 12

ABAP Training

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

Page 13: Programming in ABAP

Programming in ABAP 13

ABAP Training

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

Page 14: Programming in ABAP

Programming in ABAP 14

ABAP Training

ABAP Modules

SubroutinesForm....ENDFORM

FunctionsFunction....ENDFUNCTION

Processing blocks for events<Event keyword>

Event statements<Event keyword>

Event statements Modules of a module pool

Module....ENDMODULE

Page 15: Programming in ABAP

Programming in ABAP 15

ABAP Training

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

Page 16: Programming in ABAP

Programming in ABAP 16

ABAP Training

Syntax Elements

Statements Each statement begins with a keyword and ends with a

periodWRITE ‘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

Page 17: Programming in ABAP

Programming in ABAP 17

ABAP Training

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

Page 18: Programming in ABAP

Programming in ABAP 18

ABAP Training

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

Page 19: Programming in ABAP

Programming in ABAP 19

ABAP Training

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

Page 20: Programming in ABAP

Programming in ABAP 20

ABAP Training

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

Page 21: Programming in ABAP

Programming in ABAP 21

ABAP Training

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