ABAP EVENTS & Interaction

Post on 21-Jan-2016

39 views 0 download

description

ABAP EVENTS & Interaction. Northern Arizona University College of Business. Processing Events. Events are markers that define certain code The event is terminated by: The Explicit ending of the event The start of another event The beginning of sub-routines (form). Select Options. - PowerPoint PPT Presentation

Transcript of ABAP EVENTS & Interaction

1

ABAP EVENTS & Interaction

Northern Arizona University

College of Business

2

Processing Events

Events are markers that define certain code

The event is terminated by: The Explicit ending of the event

The start of another event

The beginning of sub-routines (form)

3

Select Options

The Select Options are placed after the data declaration portion of the program and before Initialization .

Select-Options:

S_Carrid For SPFLI-Carrid .

4

Initialization Event

The Initialization event occurs after the data declaration portion of the program, including the Select-Options.

Initialization .S_Carrid-Low = ‘AA’ .S_Carrid-High = ‘ZZ’ .Append S_Carrid .Clear S_Carrid .

5

At Selection-Screen

The At Selection-Screen event is processed after the selection screen is displayed.

At Selection-Screen .If S_Carrid < ‘A’ .

Message I999 with ‘no value will select all records’ .EndIf .

6

Start-Of-Selection

The Start-Of-Selection marks the place in the code where data is selected from the database.

Start-Of-Selection . “heart of the programSelect * from whatever into table IT_whatever where Carrid in S_Carrid.

End-Of-Selection .

7

At Line-Selection

After the Start-Of-Selection section. Used for drill-down (double click).At Line-Selection .

Case sy-lsind .When 1 .

Perform Whatever_Detail .When Others .

Message S999 with ‘no further drill down’ .EndCase .

8

Database Table Joins

Select from SFLIGHT Into table F_Tab where carrid = IT_SPFLI-carrid and connid = IT_SPFLI-connid .

Select from SAPLANE Into table P_Tab where planetype = IT_SFLIGHT-planetype .

9

Hiding fields

If a line is double clicked the field is populated with the data from the line holding the field.

The fields are hidden so they can be restored.

Hide carrid, connid .

10

Messages

Messages are displayed in the status bar at the bottom of the screen, or in information windows.

11

Message-ID

The Message-ID defines the message-ID library used.

Each library can have 1,000 possible messages (000 – 999).

12

Defining the Message-ID

Program zWhatever

Message-ID ZZ .

13

Displaying Messages

Message I999 .

Message I999 with Text-001 .

Message I999 with ‘whatever’ .

14

Message Types

E Error Application stops

W Warning Press enter to continue

I Information Pop-up window, press enter to

continue

15

Message Types

A Abend Cancels the transaction

S Success Feedback only

X Abort Aborts the program,

short memory dump

16

Forms (sub-routines)

A form is a set of program logic set into a module. The module (form) is called (perform). Forms are always placed at the end of the program. Forms can be nested.

17

Defining a form

Form ABC .

. . . . .

EndForm .

18

Calling a form

Perform ABC .

19

Using Parameters to pass data

Data can be passed to and from a form.

Parameters can be passed by reference or by value (using).

If passed by reference the form can change the value of the source field.

If passed by value the form cannot change the value of the source field.

20

Using Parameters to pass data – Example – by Reference

Form Demo Using P1 Type I P2 Type I .

P1 = P1 + 1 .

P2 = 0 .

EndForm .

Perform Demo Using X Y .

(X and Y will be modified when the statements are executed) .

21

Using Parameters to pass data – Example – by Value

Form Demo Using Value(P1) Type I .

P1 = P1 + 1 .

EndForm .

Perform Demo Using X .

(X will not be modified) .

22

Using Parameters to pass data – Example – Changing Value

Form Demo Changing Value(P1) Type I .

P1 = P1 + 1 .

EndForm .

Perform Demo Using X .

(X will be modified when EndForm is reached) .

23

Using Parameters to pass data – Example – Table

Tables: SPFLI .

Data: Begin of T_Demo Occurs 100 .

Include Structure SPFLI .

Data: End of T_Demo .

24

Using Parameters to pass data – Example – Table

Form Sort_Table Tables I_Demo Structure SPFLI .

Sort I_Demo by Carrid .

EndForm .

Perform Sort_Table T_Demo .

25

Using Parameters to pass data – Example – Table

Tables are always passed by reference, not by value. Any change immediately effects the referenced table .

Structure allows a reference to individual fields within a table or record (structure).

Tables, Using, and Changing can all be passed together. Tables must be first .

26

Program Structure

Program name (with message-id).

Define tables.

Parameters and Select-options.

Define data.

Initialization.

At Selection screen.

27

Program Structure

Start-of-Selection.

Main part of program logic.

End-of-Selection.

At Line-Selection.

Form(s).