270 likes | 420 Views
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.
E N D
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 • The Select Options are placed after the data declaration portion of the program and before Initialization . Select-Options: S_Carrid For SPFLI-Carrid .
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 .
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 .
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 program Select * from whatever into table IT_whatever where Carrid in S_Carrid. End-Of-Selection .
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 .
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 .
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 .
Messages • Messages are displayed in the status bar at the bottom of the screen, or in information windows.
Message-ID • The Message-ID defines the message-ID library used. • Each library can have 1,000 possible messages (000 – 999).
Defining the Message-ID Program zWhatever Message-ID ZZ .
Displaying Messages Message I999 . Message I999 with Text-001 . Message I999 with ‘whatever’ .
Message Types E Error Application stops W Warning Press enter to continue I Information Pop-up window, press enter to continue
Message Types A Abend Cancels the transaction S Success Feedback only X Abort Aborts the program, short memory dump
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.
Defining a form Form ABC . . . . . . EndForm .
Calling a form Perform ABC .
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.
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) .
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) .
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) .
Using Parameters to pass data – Example – Table Tables: SPFLI . Data: Begin of T_Demo Occurs 100 . Include Structure SPFLI . Data: End of T_Demo .
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 .
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 .
Program Structure Program name (with message-id). Define tables. Parameters and Select-options. Define data. Initialization. At Selection screen.
Program Structure Start-of-Selection. Main part of program logic. End-of-Selection. At Line-Selection. Form(s).