ABAP Training - Module Poolnew
ABAP Training - Module Poolnew
Report Programs
Conventional Report
Online Programs
Interactive Report
Screen Components
Screen Painter
Screen Attributes
Screen Layout
Screen Layout
5
7
6
|
ABAP
Top Include
PBO Modules
DYNPRO PROCESSOR
** SCREEN 9000 ** PROCESS BEFORE OUTPUT. MODULE CLEAR. PROCESS AFTER INPUT. MODULE CHECK. MODULE SELECT.
ABAP PROCESSOR
** INCLUDE MZAVGO01 MODULE CLEAR OUTPUT. ... ENDMODULE.
** INCLUDE MZAVGI01 MODULE CHECK INPUT. ... ENDMODULE. MODULE SELECT INPUT. ... ENDMODULE.
** SCREEN 9001 ** PROCESS BEFORE OUTPUT. PROCESS AFTER INPUT. MODULE UPDATE.
PBO
Screen Work Area
name
Aaron
phone
215-387-3232
Identical Names
DATA num(12).
city
Philadelphia
DATA city(20).
Philadelphia
PAI
|
Online program name must begin with SAPM and then either a Y or Z.
Program Attributes
With TOP INCL. should be checked. Go back to Repository Browser, not source code.
Title Type M
Application
Screen Attributes
Screen Painter
Screen Attributes
Short Description
Screen Type
Next Screen
required
|
required
optional
Flow Logic
Screen Painter
Flow Logic
Screen 9000
PROCESS BEFORE OUTPUT.
MODULE INITIALIZE.
ABAP module to clear all fields before screen is displayed. ABAP module to calculate average after user has entered values and pressed Enter.
PBO Module
** MY220_PLAYER_AVGO01 - Include Program ** MODULE INITIALIZE OUTPUT.
PAI Module
The fields POINTS, GAMES, and AVERAGE need to be defined as global data.
** MY220_PLAYER_AVGI01 - Include Program ** MODULE CALCULATE INPUT. CHECK GAMES <> 0. AVERAGE = POINTS / GAMES. ENDMODULE.
|
Global Data
Main Program
** SAPMY220_PLAYER_AVG ** INCLUDE MY220_PLAYER_AVGTOP. INCLUDE MY220_PLAYER_AVGO01.
It is important that these program fields are named the same as the screen fields so automatic data transport will occur between the screen work area and program work area.
INCLUDE MY220_PLAYER_AVGI01.
Top Include
** MY220_PLAYER_AVGTOP - Include Program **
PROGRAM SAPMY220_PLAYER_AVG.
DATA: POINTS TYPE I, GAMES TYPE I, AVERAGE TYPE P DECIMALS 2.
|
When the PAI event is triggered, values are transported from the screen work area to the program fields with the same names before any PAI modules are executed.
Player Average Total Points Total Games 165 6
F8
Transaction Code
Transaction Text
Program Name
Initial Screen
required
|
required
SAPMY220_PLAYER_AVG
required
9000
Question???
Screen 9000
PROCESS BEFORE OUTPUT.
Screen 9001
PROCESS BEFORE OUTPUT.
MODULE INITIALISE.
MODULE CALCULATE.
We could have calculated the players average in the PBO of screen 9001. Why is it better to do the calculation in the PAI of screen 9000 instead of the PBO of screen 9001?
Graphical Elements
6
|
Scrollable Fields
ABAP Course #3
Description Instructor
Anthon, Dionne
scrollable field
Scrollable fields have a visible length that is smaller than the defined length.
Anthon, Dionne Bacon, Patricia Banning, Mark Cooper, Angela Shepski, Lee
PROGRAM SAPMZA01.
TABLES YMOVIE.
Screen 9000
PROCESS BEFORE OUTPUT. MODULE INITIALIZE.
CLEAR YMOVIE.
ENDMODULE. ** MZA01I01 - PAI Modules **
F1
Data element short text Data element documentation system-wide only if maintained system-wide automatic
Execute transaction
Year Category
If a change is made to an ABAP Dictionary field (e.g., category length is changed from 3 to 6 characters) and the appropriate Dictionary objects are reactivated, the change will take effect throughout the system where this field is used.
Academy Awards
Execute transaction
Year Category
Automatic Checks
Proper Format ?
Values in input/output templates painted from the ABAP Dictionary are checked for
Valid Value ?
SCREEN
Enter
NO
YES
Data transport from screen fields to program fields with the same names.
Enter
If a required field is not entered, the system will display the error message: Required entry not made.
|
Academy Awards
Year Category
? PIC
19a4 PIC
Enter
If a field format is incorrect, the system will display an appropriate error message.
|
Category
Enter
Address Information Customer # C32
If the value entered does not exist in the foreign key (check) table, the system will display the error message: Entry <x> does not exist (please check your entry).
|
Enter
If a valid value is not entered, the system will display the error message: Please enter a valid value.
|
Overview
Academy Awards Year Category 1910 PIC
Academy Awards
Enter
Year Category
1910 PIC
E: No record exists
Instead of informing the user on the second screen that a record does not exist, we want to issue a message on the first screen.
MESSAGE Statement
MESSAGE <tnnn> [WITH <var1> <var2> <var3> <var4>].
** MZA02TOP - Top Include ** PROGRAM SAPMZA02 MESSAGE-ID ZA.
TABLES YMOVIE.
** MZA02I01 - PAI Modules ** MODULE SELECT_LISTING INPUT. * code to select record from YMOVIE IF SY-SUBRC <> 0.
t = message type nnn = message number -------------------------------------var1 = message variable 1 var2 = message variable 2 var3 = message variable 3 var4 = message variable 4
Message class (ID) must be specified on PROGRAM statement in Top Include. MESSAGE statement in PAI module of first screen.
Message Types
S: success I: information
A: abend X: exit
W: warning
E: error
|
The message type determines where the message is displayed and what action the user can or must take on the current screen.
Success Message
PAI Module of 1st Screen
Enter
MESSAGE S001.
Academy Awards
1910
PIC
The SUCCESS message is displayed at the bottom of the next screen; therefore, the user cannot make any changes to the values on the current screen.
No record exists
|
Information Message
Academy Awards Year Category 1910 PIC
i
PAI Module of 1st Screen
MESSAGE I001.
Enter
The INFORMATION message is displayed on the current screen in a dialog box. The user cannot make any changes to the values on the current screen. After pressing the Enter key on the dialog box, the user will be taken to the next screen.
Academy Awards
Year Category 1910 PIC
i
|
No record exists
Abend Message
Academy Awards Year Category 1910 PIC The ABEND message is displayed on the current screen in a dialog box. The user cannot make any changes to the values on the current screen. After pressing the Enter key on the dialog box, the transaction will be terminated. PAI Module of 1st Screen
Warning Message
PAI Module of 1st Screen
Enter
MESSAGE W001.
W: No record exists
The WARNING message is displayed at the bottom of the current screen. The user can make changes to the values on the current screen, but does not have to make any changes. After pressing the Enter key on the current screen, the user will be taken to the next screen.
Error Message
X
PAI Module of 1st Screen
Academy Awards
Year
Category
1910 PIC
Enter
MESSAGE E001.
E: No record exists
|
The ERROR message is displayed at the bottom of the current screen. The user must make changes to the values on the current screen. After pressing the Enter key on the current screen, the user will be taken to the next screen only if the appropriate corrections were made.
Problem !!!
W: No record exists
E: No record exists
When we issue a WARNING or ERROR message, the system stops on the current screen to allow the user to make corrections; however, these fields are not open for input.
Overview
Academy Awards Year Category 1932 PIC
Enter
1932
PIC
1932
PIC
E: No record exists
|
E: No record exists
User-Defined Checks
Method #1
Method #2
Method #3
|
Flow Logic FIELD statement keeps a single screen field open for input on an error or warning message.
Issue error or warning message in PAI Module
Issue error or warning message with Flow Logic SELECT statement Define valid values with Flow Logic VALUES statement
|
1932
PIC
Enter
Category
E: No record exists
|
This Flow Logic SELECT statement will retrieve one record. If no record matches, an error message is issued. The Flow Logic FIELD statement will leave the YMOVIE-AAYEAR screen field open for input if this error message is issued.
Academy Awards
1932 PIC
Enter
Year
Category
1932
PIC
E: No record exists
This Flow Logic CHAIN and ENDCHAIN group the FIELD statements and the MODULE statement together. The Flow Logic FIELD statements will leave both the YMOVIE-AAYEAR and YMOVIE-CATEGORY screen fields open for input if an error or warning message is issued in the SELECT_LISTING module.
Academy Awards
Year
1932 PIC
Enter
Category
E: No record exists
|
Enter
YES
Data transported from screen fields D and E to program fields D and E. Fields A, B, and C are not transported yet because these fields are in a FIELD statement. Module ONE executed. Data transport for field A. Module TWO executed. Data transport for fields B and C. Module THREE executed. Module FOUR executed. Go to PBO of next screen
A B C D E
NO
PROCESS AFTER INPUT. MODULE ONE. FIELD A MODULE TWO. CHAIN: FIELD: B, C. MODULE THREE. ENDCHAIN. FIELD A MODULE FOUR.
|
Questions???
PROCESS AFTER INPUT. FIELD A . FIELD B SELECT * FROM TABLE WHERE FIELD1 = A AND FIELD2 = B INTO TABLE WHENEVER NOT FOUND SEND ERRORMESSAGE 001.
This FIELD statement is not associated with a PAI module, a Flow Logic SELECT statement, or a Flow Logic VALUES statement; however, it is essential for the execution of this PAI event. WHY???
If this error message is issued, will screen field A be open for input?
Overview
Academy Awards
Execute transaction
Year Category
1994 PIC
Default Values
Cursor Positioning
OR
Academy Awards
Year Category 1994 PIC
GET
SET
You can check the SPA field attribute instead of coding the SET PARAMETER ID statement in a PAI module.
|
Cursor Position
Academy Awards Year Category Winner Notes 1994 PIC Forrest Gump The Shawshank Redemption should have won.
Upon entering a screen, the cursor will automatically be positioned in the first input/output template open for input unless you position the cursor in a different field using the screen attributes or a PBO module.
|
Screen Attributes
Short Description Screen Type Cursor position
YMOVIE-NOTES
** PBO Module **
OR
Notes
|
Screen 9000
PROCESS BEFORE OUTPUT. MODULE INITIALIZE.
Screen 9001
PROCESS BEFORE OUTPUT. MODULE INITIALIZE.
ELSE.
SET PF-STATUS SECOND. SET TITLEBAR TWO. ENDIF.
ENDMODULE.
Notice that the call to module INITIALIZE in the PBO of each screen refers to the same ABAP module.
|
TABLES YMOVIE.
DATA OKCODE(4).
To check the OK Code of an online program, you must define this field in both the screen (Field List) and the program work area (Top Include). Remember that these fields must be given the same name.
Exit
Edit
Loop
ENDMODULE.
You should clear out the OKCODE before a screen is displayed so an old value does not remain if the user presses Enter.
We only want to select a record from YMOVIE if the user has invoked the EDIT function code (e.g., clicked on the Edit pushbutton).
** MZA05I01 - PAI Modules ** MODULE SELECT_LISTING INPUT. IF OKCODE = EDIT. * code to select record from YMOVIE ENDIF. ENDMODULE.
Function Types
Function Code
Type
Type E
Type S
Type P
Type T
Overview
Exit
Year
Category
Edit
Loop
1994 PIC
Academy Awards
Exit
Year
Update
1994 PIC Forrest Gump
Academy Awards
Currently, the screen sequence of our online program is determined by static Next Screen attributes on each screen. We will learn how to dynamically set the screen sequence and add a pop-up dialog box to enter a critics name.
Enter Name
Screen 9000
PROCESS BEFORE OUTPUT.
ENDMODULE.
MODULE TWO INPUT. ...
MODULE INITIALIZE.
ENDMODULE.
When LEAVE SCREEN is encountered, the system immediately terminates the current screens PAI event and goes to the PBO event of the screen specified in the Next Screen attribute.
Screen 9000
PROCESS AFTER INPUT.
ENDMODULE.
FIELD YMOVIE-AAYEAR VALUES (BETWEEN 1927 AND 1996). CHAIN. When SET SCREEN is encountered, FIELD: YMOVIE-AAYEAR, the system temporarily ignores the YMOVIE-CATEGORY. value in the Next Screen attribute MODULE SELECT_LISTING. and uses the value specified instead. ENDCHAIN. The current screens PAI processing is
not terminated.
|
MODULE SELECT_LISTING INPUT. IF OKCODE = EDIT. * code to select record from YMOVIE LEAVE TO SCREEN 9001. ENDIF. ENDMODULE.
Screen 9000
PROCESS AFTER INPUT.
FIELD YMOVIE-AAYEAR VALUES (BETWEEN 1927 AND 1996). CHAIN. When LEAVE TO SCREEN is FIELD: YMOVIE-AAYEAR, encountered, the system terminates YMOVIE-CATEGORY. the current screens PAI event and MODULE SELECT_LISTING. immediately goes to the PBO event ENDCHAIN. of the screen specified in the statement.
|
Academy Awards
Year Category
Winner Notes Critic
Screen 9002 is a Modal dialog box type screen with a dialog box type GUI status.
Exit
Enter Name
CALL SCREEN 9002 STARTING AT 30 5 ENDING AT 60 10. This ABAP code would be in a PAI module for screen 9001.
|
Screen 9002
PROCESS BEFORE OUTPUT. MODULE INITIALIZE.
MODULE INITIALIZE OUTPUT. * set GUI status and titlebar * depending on screen number * and clear okcode ENDMODULE.
Because screen 9002 was called, SCREEN 0 refers to the calling screen (9001).
|
ENDMODULE.
Question ???
Screen 9100
Screen 9100
Screen Attributes
Short Description Screen Type Next screen
9100
Screen Attributes
Short Description Screen Type Next screen
What happens after all PAI modules are processed and the next screen is itself?
What happens after all PAI modules are processed and the next screen is blank?
Overview
ON INPUT
ON REQUEST
AT CURSORSELECTION
|
AT EXITCOMMAND
ON INPUT
Module CHECK will be executed only if the value in field A is not equal to the initial value appropriate to its data type (e.g., blanks for character fields and zeroes for numeric fields).
ON REQUEST
Module CHECK will be executed only if a value has been entered in field A since the screen was displayed.
AT EXIT-COMMAND
Module END will be executed only if the user invoked a function code with the E function type.
Timing of AT EXIT-COMMAND
Type E Function Code
SCREEN
YES
Data transport from screen fields to program fields with the same names.
|
AT EXIT-COMMAND Example
Exit
Edit
Loop
PROCESS AFTER INPUT. FIELD YMOVIE-AAYEAR VALUES (BETWEEN 1927 AND 1996). CHAIN. FIELD: YMOVIE-AAYEAR, YMOVIE-CATEGORY. MODULE SELECT_LISTING. ENDCHAIN.
If the user invokes the EXIT function code (e.g., clicking on Exit), we will terminate the transaction. Because this function code is type E, we can use AT EXIT-COMMAND to have the module END executed immediately (even before the automatic field checks).
|
AT CURSOR-SELECTION
Module SEL1 will be executed only if the user invoked the function code CS with the S function type and the cursor was positioned in field A.
PROCESS AFTER INPUT. FIELD A MODULE SEL1 AT CURSOR-SELECTION. MODULE SEL2 AT CURSOR-SELECTION.
Module SEL2 will be executed only if the user invoked the function code CS with the S function type and the cursor was not positioned in field A.
|
Subscreens
Customer 11
Main Screen
Main Screen
Subscreen Area #1
Screen Painter
Subscreen Area #2
Subscreen Area #3
Flow Logic
________________
This subscreen area must be given a name up to 10 characters long (e.g. SUB1).
Customer Name
11 Tools International
This SCREEN_NUM variable contains the number of the subscreen to display in the specified subscreen area.
Subscreen Area
SUB1
Bank (Sub
Customer Name
11 Tools International
To invoke the PAI event of the actual subscreen, the CALL SUBSCREEN statement must be used in the PAI event of the main screen.
PROCESS AFTER INPUT. for main screen 9010 * CALL SUBSCREEN <area>. CALL SUBSCREEN SUB1.
|
Creating a Subscreen
Screen Painter
Screen Attributes
Screen Type = Subscreen
|
Subscreen Restrictions
SET PF-STATUS SET TITLEBAR SET SCREEN CALL SCREEN LEAVE TO SCREEN CALL SUBSCREEN AT EXIT-COMMAND OK Field
|
Upon completion of this section you will be able to: Create tabstrips in the graphical screen painter. Create subscreens for use with tabstrips. Integrate tabstrips in a module pool program . . .
-
1991
PIC
FEM
MAL
Year
1991
Year
1991
Nominees
Beauty and the Beast Bugsy
A
B
Subscreen Area
C
|
Process on Help-Request
Screen 9000
PROCESS BEFORE OUTPUT. ... PROCESS AFTER INPUT. ... PROCESS ON HELP-REQUEST.
Category
F1
Trigger PROCESS ON HELP-REQUEST Flow Logic event for the particular field. This event will display the specified supplemental documentation (i.e., 0001).
|
Process on Value-Request
Screen 9000
Academy Awards
Year
Category
1994
PIC
F4
Trigger PROCESS ON VALUE-REQUEST Flow Logic event for the particular field. This event will execute the specified module (i.e., VALUE_LIST).
|