Dialogs and Screens for SAP ABAP Lesson Nine

Screens are made up of more than just a monitor display with input and output fields.Screens' integration with the ABAP-Dictionary allows the system to perform consistency checks for their input fields automatically. These checks include required input check, type checks, foreign key checks, and fixed value checks. All of these checks rely upon ABAP Dictionary information.

Checks like the ones above can be complemented by other program specific checks. There are techniques available for screens that allow you to control in what order checks are then performed.When an error is detected, the corresponding field is called and displayed ready for input. Screen layout is also very flexible. Input fie lds, output fields, radio buttons, check boxes, and even pushbuttons can be placed on screens. They allow users to determine in which direction the program will proceed.On the whole, such user influence on program progression allows for more program flexibility in those programs that do contain screens.You can call screens from any ABAP processing block that you want.

You can link several screens to one another and then call them from within a program by simply calling the first screen.Some ABAP programs are made up exclusively of screens and their corresponding ABAP processing blocks. In this case the first screen is called directly using a transaction code.Double-click on an entry in the basic list 'timetable' to reach a screen. This screen displays dataThe major steps in creating a screen:


specifying its properties (Screen Attributes)
specifying its layout (in Fullscreen Editor)
defining attributes for the elements on the screen (Field List)
programming its flow logic
You should be able to call your screen by double -clicking a line within the basic list and you should be able to return to the basic list by choosing the appropriate function key on the screen. 
There are several ways to create screens:

Forward Navigation: You can create screens from within the ABAP Editor by double –clicking on the screen number. This transfers you into Screen Painter automatically

Object Navigator: You can also create a screen from the object list in the Object Navigator
When creating a screen for the first time the system will ask you to enter screen attributes. Enter a short description of the screen, select screen type Normal and enter the number of the subsequent screen in the Next Screen input field.
 
There are two ways of assigning field attributes to screen fields:

Adopt them from the Dictionary: You can adopt types and field attributes from existing ABAP Dictionary structures. This makes all information about the object available to you,including semantic information about its data elements and foreign key dependencies. The name of the Dictionary field is automatically adopted as a field name. 

Adopt them from a program: You can adopt field attributes from data objects already defined within a program. In order to do this, however, an activated copy of the program must already exist. The name of the data object is automatically adopted as a field name.

The Graphical Screen Painter's interface allows you to define screen elements (for example, input and output fields, keyword texts, borders, and so on) with relative ease. Choose the desired screen element from the column on the left and then place it on the screen using your mouse.

You can delete screen elements simply by selecting them with your mouse and then choosing delete.
You can move screen elements by holding down your left mouse button and dragging them to a new position.
You can maintain screen field attributes by selecting a field and choosing Attributes.
You can classify certain fields as 'mandatory'.(. "Required field"). A question mark is displayed at runtime if the field is initial.
If not all required fields have been filled at runtime and a user action is performed, an error dialog is triggered and all input fields are once again displayed ready for input.
You can also edit screen field attributes by choosing Field list.
The field list is then displayed as a tab.
This same function can also be accessed in a different format from within the Graphical Screen Painter.
The statement TABLES declares an internal data object that serves as an interface for the screen.
TABLES always refers to a structure that is defined in the ABAP Dictionary.

If a TABLES statement and a screen field both refer to the same Dictionary structure, this data object's data is transported to the screen fields every time the screen is called. Any new entries or changes that the user makes on the screen are then transferred back into this data object.

Data transport takes place automatically between screens and program data objects of the same name:
Immediately before a screen is sent to the presentation server (after all PBO event modules have been processed) the system copies field contents out of the ABAP work area into their corresponding fields in the screen work area.ABAP statements facilitate data transport between program data objects and the work area designated as the screen interface.
Data transport takes place automatically between screens and program data objects of the same name:

Immediately after a user action (before the first PAI module has been processed) the system copies field contents out of the screen work area and into their corresponding fields in the ABAP work area.ABAP statements facilitate data transport between the work area designated as the screen interface and program data objects.In order to ensure that the database data that is displayed on the screen is up-to-date, the record is read again from the database at the beginning of AT LINE-SELECTION.

Advantages of this method:

For the basic list, only those columns of the database table that are displayed on the list need to be read. This can improve performance with large lists.
The data that is displayed on the screen is always up-to-date, even if the data record selected has only just been changed using this program. This would not happen if all screen data was placed in the HIDE area when the basic list is created.
Changes made to the database using the screen do not lead to incorrect values in the basic list, as the modifiable fields are not contained in the list.
Looking ahead to the lock concept: The lock times can be shortened. You find more detailed information on this topic in the Database Dialogs II unit.
The program can be extended: Additional information from the data record can be displayed on the screen without having to make many changes.
To display data on the screen, the TABLES structure must be filled with current data before the screen is sent to the presentation server. The example above shows one way of doing this.
The data record is read from the database using SELECT SINGLE. This ensures that the structure contains current data, even if the user has just changed the data. The structure is assigned the same type as the database table line type, so that suitable fields are available for all data in the data record.
The system transports the structure data to the screen fields automatically.
Each screen has two corresponding event blocks:

PROCESS BEFORE OUTPUT (PBO) is processed immediately before a screen is displayed. At this time modules are called that take care of tasks such as inserting recommended values into input fields.
PROCESS AFTER INPUT (PAI) is processed immediately after a user action. All program logic that is influenced by user action must be processed at PAI. You will learn more about this in step three.
Note: The code for the events PBO and PAI is written using the Screen Painter and not the ABAP Editor. These two event blocks make up a screen's flow logic.
When programming flow logic, use the set of commands called Screen ABAP. MODULE is the most important Screen ABAP command. It calls a special ABAP processing block called a module.
Modules are ABAP processing blocks with no interface that can only be called from within a program's flow logic. Modules begin with the ABAP statement MODULE and end at ENDMODULE.
Program logic that logically belongs to a specific screen should normally be processed at the screen's PBO and PAI events.
If you enter 0 or leave the Next Screen field blank, the system first processes your screen completely and then carries on processing the program from where the screen was called.If you set the Next screen of screen 100 to 100, the system processes the screen again, after it has finished processing the PAI module.You can use the ABAP statement SET SCREEN within a PAI module to override dynamically the value set in the Next screen attribute.

Often the same screen number is entered in both the Screen number and Next screen fields. In this case, when you choose Enter, a field check is performed and the system returns you to the same screen. In order to leave the screen, an appropriate pushbutton must be defined that then triggers a Next screen change within the PAI module.
With the help of the OK_CODE field, different program logic can now be processed by the PAI modules depending on what the user inputs.If an OK_CODE field is not initialized, errors can occur since not every pushbutton is required to have a function code. There are two ways of doing this:

Initialize the OK_CODE field in a PBO module. Then it is set to the initial value at PAI, unless the user has carried out a user action to which a function code is assigned. In this case, the OK_CODE field contains the function code.

Use an auxiliary field and copy the contents of the OK_CODE field to the auxiliary field in a PAI module, and then initialize the OK_CODE field. In this case, the auxiliary field must be queried in the PAI module for the function code evaluation.
You can implement calls such as MODULE within a screen's flow controls (PBO and PAI events).
The modules themselves are, however, created using ABAP.
There are two ways to create a module:
using forward navigation: Double-click on the module name from within the Screen Painter Editor to create the module.
Using the Object Navigator: If you want to create a module using the object list in the Object Navigator, first display your program, then choose 'PBO module' or 'PAI module' in the ProgramObjects display and create a new development object by selecting the create icon.
A module can be called from more than one screen. (Reusability)
Be aware that modules called at PBO events must be defined using the statement MODULE ... OUTPUT, whereas modules defined with MODULE ... INPUT, can only be called at PAI events.

No comments :

Post a Comment