ABAP EVENTS & Interaction

27
1 ABAP EVENTS & Interaction Northern Arizona University College of Business

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

Page 1: ABAP EVENTS & Interaction

1

ABAP EVENTS & Interaction

Northern Arizona University

College of Business

Page 2: ABAP EVENTS & Interaction

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)

Page 3: ABAP EVENTS & Interaction

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 .

Page 4: ABAP EVENTS & Interaction

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 .

Page 5: ABAP EVENTS & Interaction

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 .

Page 6: ABAP EVENTS & Interaction

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 .

Page 7: ABAP EVENTS & Interaction

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 .

Page 8: ABAP EVENTS & Interaction

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 .

Page 9: ABAP EVENTS & Interaction

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 .

Page 10: ABAP EVENTS & Interaction

10

Messages

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

Page 11: ABAP EVENTS & Interaction

11

Message-ID

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

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

Page 12: ABAP EVENTS & Interaction

12

Defining the Message-ID

Program zWhatever

Message-ID ZZ .

Page 13: ABAP EVENTS & Interaction

13

Displaying Messages

Message I999 .

Message I999 with Text-001 .

Message I999 with ‘whatever’ .

Page 14: ABAP EVENTS & Interaction

14

Message Types

E Error Application stops

W Warning Press enter to continue

I Information Pop-up window, press enter to

continue

Page 15: ABAP EVENTS & Interaction

15

Message Types

A Abend Cancels the transaction

S Success Feedback only

X Abort Aborts the program,

short memory dump

Page 16: ABAP EVENTS & Interaction

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.

Page 17: ABAP EVENTS & Interaction

17

Defining a form

Form ABC .

. . . . .

EndForm .

Page 18: ABAP EVENTS & Interaction

18

Calling a form

Perform ABC .

Page 19: ABAP EVENTS & Interaction

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.

Page 20: ABAP EVENTS & Interaction

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

Page 21: ABAP EVENTS & Interaction

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

Page 22: ABAP EVENTS & Interaction

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

Page 23: ABAP EVENTS & Interaction

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 .

Page 24: ABAP EVENTS & Interaction

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 .

Page 25: ABAP EVENTS & Interaction

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 .

Page 26: ABAP EVENTS & Interaction

26

Program Structure

Program name (with message-id).

Define tables.

Parameters and Select-options.

Define data.

Initialization.

At Selection screen.

Page 27: ABAP EVENTS & Interaction

27

Program Structure

Start-of-Selection.

Main part of program logic.

End-of-Selection.

At Line-Selection.

Form(s).