An input field is a rectangular screen element in which you can enter data, whereas an output field is a rectangular screen element in which the system displays text or other data.
Automatic field input checks relate to the data type of the input fields.
For example, you can only enter a valid date in a date field.
Input fields that are congruent with the ABAP Dictionary fields may have built-in data consistency checks, such as foreign key checks and value sets.
Input fields can hold possible help values.
INPUT/OUTPUT FIELDS: ATTRIBUTE
The four attributes for input or output fields are General, Dictionary, Program, and Display.
Each attribute consists of several elements:
General attributes may include elements, such as Name, Text, Dropdown, Icon display, Start position, Size, and Context menu.
Dictionary attributes may be listed as Data format, Memory ID, Foreign key check, Conversion exit, Search help, and so on.
Program attributes include Dialog behavior, Input help, Output options, and Input options, among others.
Display attributes relate to the display features, such as Font, Bright, Invisible, Two-dimensional, and Web display properties.
Using the SCREEN system table, you can temporarily change the relevant object attributes.
CREATING INPUT/OUTPUT FIELDS
You can use two methods to create input or output fields:
You can enter the field directly in the layout editor. The number of underscore characters in the object text attribute determines the size of the field.
You use a template from the ABAP Dictionary, which you access by selecting Dict/Program fields.
You must declare the field globally using the DATA or TABLES statement for using the contents of an input or output field in your program.
DEFAULT MEMORI IN SAP MEMORY
The SAP system enables you to save default values in the SAP memory, using parameter IDs.
In the PAI processing block, Set parameter copies the corresponding field contents into the SAP system memory.
At the end of the PBO, after the data is transferred from the program, the screen field might still retain its initial value. In this case, Get parameter copies the corresponding field contents from the SAP memory.
DEFINING SET AND GET ATTRIBUTE
In the ABAP Dictionary, you can link an input or output field to an area of the SAP memory. The Parameter ID is displayed in the Dictionary attribute Parameter ID of the Screen Painter.
The SET and GET parameter attributes (SPA and GPA in the table displayed) allow you to enable the relevant parameter functions separately.
DIALOG MESSAGE CATEGORY
The dialog messages are divided into six categories: A, X, E, W, I, and S.
The message type A is for termination of the process and the user must restart the transaction.
The type X message works like the type A message, except that it includes short dump MESSAGE_TYPE_X.
The type E message interrupts the processing with an error, and the user must correct the entry.
The type W message interrupts the processing with a warning, and the user can correct the entries.
The type I message interrupts the processing with information, but the user can continue by confirming the message.
The type S message denotes success, which is the information displayed on the next screen.
AUTOMATIC FIELD INPUT CHECKS
The first check ensures that all the required fields are filled.
This is supplemented by a field format check.
The fixed values defined in the domain are also checked.
For a foreign key check to happen, the screen field should refer back to an ABAP Dictionary field, for which a check table is defined.
Thus, the system automatically checks the values you enter after the screen is displayed, but before the PAI modules are processed.
FIELD INPUT CHECKS WITH ERROR DIALOG
You can program your own field checks in the PAI event by using the FIELD statement with MODULE addition. This instructs the system to process that specific module only for the field statement that you specify.
The system sends the screen again if an error or warning message occurs during the module, but without processing the PBO module. The message is displayed and the field to which the check was applied is ready for input.
CHECKING GROUPS OF FLIEDS
To ensure that more than one field is ready for input following an error dialog, you list the relevant fields in the FIELD statement. You include both the FIELD and the MODULE statement in a CHAIN … ENDCHAIN block.
You can include individual fields in more than one CHAIN … ENDCHAIN block.
The FIELD statement makes the field ready for input again.
CONTROLLING ERROR DIALOG
The current screen is sent again if the system sends an error or warning message, but the PBO is not processed again.
When this happens, only the fields to which the module is assigned are ready for input again.
The PAI module after user input is not completely reprocessed, but restarted somewhere within the processing block.
The system finds out which fields the user has changed and resumes processing at the first corresponding FIELD statement.
THE FIELD STATEMENT AND DATA TRANSPORT
The data is transported from the screen fields into the ABAP fields with the same name in the PAI processing block.
First, the system transports the fields not contained in FIELD statements. The remaining fields are transported when the system processes the relevant FIELD statement.
CONDITIONAL MODULE CALLS
Avoiding field input checks wherever possible improves the performance of your program, as frequent access to the database may slow down the system.
If you leave the screen by mistake, you might make inconsistent entries to satisfy the input checks. Therefore, you should be able to get back to the program, without these field checks taking place.
A program security prompt warns you if you leave the screen unintentionally, so that you can avoid losing the data that you entered.
EXECUTION IF THE VALUE IS NOT INITIAL
You can use the ON INPUT addition in a MODULE statement after FIELD, to ensure that the module is called only if the field contents change from their initial value.
The ON CHAIN-INPUT addition defined within a CHAIN block ensures that the module is called if the contents of at least one screen field within the CHAIN BLOCK do not equal their initial value.
EXECUTION ON CHANGE
The module is called only if you enter a new value in the relevant field with the ON REQUEST addition in a MODULE statement after FIELD.
The ON CHAIN-REQUEST addition defined within a CHAIN block ensures that the module is called if you change the contents of at least one screen field within the CHAIN block.
AVOIDING FIELD INPUT CHECKS
The module with the AT EXIT-COMMAND addition is processed not only before the automatic field input checks, but also before all the other PAI modules. It is executed when the function has a type E.
SWITCH DEPENDING MODULE CALL
When you specify a SWITCH, it should also have the state ON. Otherwise, the dialog module will not be called.
You cannot specify the addition together with the statement FIELD.
You use the Back and Cancel functions to take you back one logical level.
If the screens are on the same level as the initial screen, they lead back to the initial screen.
If the screens contain detailed information, they lead back to the screen that called the current screen.
The Exit function returns to where the processing unit was called.
All the three functions (Back, Exit, and Cancel), when selected on the initial screen of a program, lead back to the screen from which the current program was called.
SINGLE SCREEN TRANSACTION
By clicking Back, you can exit the current transaction and return to the calling program, which may be the Workplace.
This function works like the Exit function.
The Cancel function displays the screen again with initialized data fields and allows the user to select a new object.
If you enter data on the screen – SY-DATAR = X or your own flag – you can avoid accidental loss of data by using a predefined security prompt.
For the Exit and Cancel functions, a dialog box is first sent to the user. The system checks the input on the screen for the Exit function.
The Exit and Cancel functions must have a function type E.
The input check precedes the dialog in the case of the Back function.
Switching from the Change to the Display mode can result in unsaved data being lost. If the user chooses not to save, the system will display the original data stored in the database.
The SAP system contains a series of function modules that you can use for the user dialogs.
Input help or F4 help is a standard function in the R/3 system, which allows you to display a list of possible entries for a screen field.
A dropdown list with possible entries appears on the right side of the field. It is visible whenever the cursor is placed in the field.
Dropdown boxes contain possible entries in a pick list, from which you can choose an entry.
You execute a series of steps in the Screen Painter, to create a dropdown box for an input field:
Set the Dropdown attribute to List box.
Change the Visible length attribute to the displayed length of the descriptive text.
Set the Value list attribute to ' ' (space), so that you can access value help from the ABAP Dictionary.
If required, set the function code for the selection.
The search help assigned to the ABAP Dictionary field is in the form of a check table with two columns or a table of fixed values.
The values are filled automatically from here.
CHECKBOXES AND RADIO BUTTON GROUP
When you can choose only a single element from a group of fields, you use a radio button. On selecting one option, all the others are ruled out, as they are automatically deselected.
To choose one or more elements from a group of fields, you use checkboxes, which can indicate multiple choices.
RADIO BUTTON AND CHECKBOXES: ATTRIBUTE
Checkboxes and radio buttons possess four attributes, General, Dictionary, Program, and Display.
Examples of General attributes are Name, Text, Icon display, Start position, Size, Function code, Function type, and so on.
Dictionary attributes list features, such as Data format, Memory ID, and From ABAP Dictionary.
The Program attribute has the Dialog behavior feature, whereas the Display attribute enables the Invisible mode.
Certain points are worth noting in the context of checkboxes and radio buttons:
You must attach a name to checkboxes and radio buttons.
The text is contained in the Text field of the attributes.
You must enter the name in the Icon name attribute, to display an icon. A quick info for the icon then appears in the appropriate field.
You can change the Input field and Invisible attributes dynamically using the SCREEN system table.
CREATING A CHECK BOX
Checkboxes are created in the full screen editor of the Screen Painter.
You create them by selecting the checkbox object from the object list; placing it on the screen; and assigning a name to each checkbox.
In the ABAP program, create a field with the same name; type, c; and length, 1.
CREATING A RADIO BUTTON GROUP
First, you create the radio buttons as individual elements.
Next, choose radio button from the object list and place it on the screen. Ensure that you assign a name to each radio button.
In the ABAP program, create a field with the same name; type, c; and length, 1. You can find out the radio button chosen by the user, by querying the field contents in the ABAP program. If a radio button is not selected, the initial field value remains.
PROGRAM FLOW FOR RADIO BUTTONS AND CHECKBOXES
The program flow for radio buttons and checkboxes is similar.
When you select the field, a PAI event might or might not be triggered off. This depends on whether or not you assign a function code to a checkbox or radio button.
You can assign a function code to a radio button after you define a radio button group. The system then assigns the same function code to all radio buttons of the group.
Pushbuttons are the input fields for the OK_CODE command field.
You can quickly access functions that relate to individual screen elements or groups of screen elements, using the mouse.
You can use pushbuttons in the data area of your screen to show or hide further information.
The attributes of pushbuttons are General, Dictionary, Program, and Display.
Pushbuttons may contain a Text attribute, an Icon, or both. You use the function module ICON_CREATE, to specify an icon statically or dynamically.
You can change the Visible length, Output field, and Invisible attributes dynamically, using the system table SCREEN.
CREATING AND PROCESSING PUSHBUTTON
To create a pushbutton, choose the pushbutton object from the Screen Painter Element List and place it on the screen. Now assign a name to it. You can enter a static text in the Text attribute. Ensure that you enter a function code for the pushbutton in the Function code attribute.
Your second step is to activate the command field or the OK_CODE field. You must give the field a name in the Element List of the Screen Painter and then declare an identically named field in the ABAP program with reference to the system field sy-ucomm.