Subscribe

RSS Feed (xml)



Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Tuesday, July 6, 2010

LESSON 39 SCREEN ELEMENTS FOR OUTPUT

SCREEN ELEMENTS FOR OUTPUT:



A text field is a rectangular area on a screen in which the system displays text.

Text fields contain labels for other elements. These labels (sometimes called "keywords"), are purely for display - they cannot be changed at runtime by the user. Text fields are displayed in a fixed position on the screen.

Text fields can also contain literals, lines, icons, and other static elements. They can contain any alphanumeric characters, but may not begin with an underscore (_) or a question mark (?). If you use a text as a label for a checkbox or radio button, it must have the same object name as the checkbox or radio button it accompanies.

If your text consists of more than one word, use underscore characters as separators. This enables the system to recognize that the different words in fact belong together. The system interprets spaces as separators between two different text fields.

Text fields can be translated. They then appear in the user's logon language.

At runtime, you can change the size (visible length) of a text field and the display attributes Bright and Invisible. To do this, use the fields SCREEN-LENGTH, SCREEN-INTENSIFIED, and SCREEN-INVISIBLE (or SCREEN-ACTIVE).

You can create text fields in either of the following ways:
Directly in the layout editor, by placing a text field object in the work area and entering the text in the Object text attribute.
By using the accompanying text of a data element from the ABAP Dictionary.

When you use fields from ABAP Dictionary structures on the screen, the system normally displays the data element text as well as the template for the input/output fields on the screen.

You can make text fields invisible at runtime.

If you make an object invisible that is enclosed in a box, the box is not displayed either.

At PBO, the system table with the line type SCREEN is initialized by the runtime environment, and filled with the static attributes from the Screen Painter.

To hide a text field at runtime, you modify the system table. Use LOOP AT SCREEN. ... MODIFY SCREEN
ENDLOOP.

To make a text field invisible, use SCREEN-INVISIBLE = 1 or SCREEN-ACTIVE = 0.

To ensure that the field TEXTFIELD1 is not displayed on the screen, you can call a module in the PROCESS BEFORE OUTPUT processing block that sets the invisible attribute for that field.

To do this, set the contents of the field SCREEN-INVISIBLE to 0.

You can process the SCREEN table like an internal table with header line (LOOP AT SCREEN. … MODIFY SCREEN. ENDLOOP.)

The system does not support the statements LOOP AT SCREEN WHERE… and READ TABLE SCREEN.

A status icon is an output field that contains an icon. You choose the relevant icon at runtime. Icons allow you to indicate a status in your application. They are predefined in the system, and take up between two and four characters.

Status icons are special output fields that display icons. The system sets the attributes 'Output field' and '2 dimensional', and these cannot be changed. The default data format is CHAR.

You can change the Visible length, Intensified, and Invisible attributes of a status icon dynamically.

You can only define a status field in the graphical layout editor. A status field is an output field with an icon. You use them to display an icon, which you specify dynamically at runtime.

To assign an icon to an output field dynamically, use the function module ICON_CREATE. The internal length of the output field must be at least 13 (icon without text). To ensure that you can display quickinfos that might be longer, define the field with defined length 132 and visible length 2.

In the ABAP program, define a field with the same name as the screen field using the field TEXT from the structure ICONS.

You select the icon you want to display from the ABAP program. Before the screen is displayed, you need to find out the technical name of the icon. You do this by calling a module in the PBO event.

You retrieve the technical name of an icon using the function module ICON_CREATE. You must pass the name of the icon you want to display to the function module. You can also pass a text to be displayed with the icon. The function module returns the technical name of the icon.

For further details about this function module, refer to its documentation.

Group boxes enclose a selection of elements that belong together (for example, a group of fields or a radio button group). They are purely display elements, and help the user to identify which elements on the screen belong together in a group.

You can use group boxes to make sure that all fields within a box have the same context menu assigned to them. For further information, refer to the Context Menus on Screens unit.

Group boxes may have a title.

You can change the Visible length and Invisible attributes using the system table SCREEN.

A group box may contain other screen objects.

At runtime, if the box contains only invisible elements and the screen attribute Runtime compression is set, the box itself is not displayed.

You define a group box in the layout editor. The object must have a name, and you may also assign a heading to the box.

You can change the group box text dynamically. To do this, you should activate the output field attribute and create a global data field in the ABAP program with the same name. Because the Screen Painter field and the program field have the same name, any changes to the field contents will be immediately visible on the screen (similarly to input/output fields).

Output objects are for improving the layout of your screens.

Text fields allow you to label input/output fields. In this case, you should use the same name for the text field as for the input/output field. If you deactivate the input/output field, the text label is then automatically deactivated as well.

Status icons allow you to provide the user with a quick graphical overview of information.

Group boxes allow you to make a group of fields that logically belong together. Runtime compression ensures that empty boxes cannot be displayed.

Static texts on a screen can be translated, so that they appear on the screen in the language in which the user is logged on. To make dynamically-assigned text accessible to translators, you must use text elements in your ABAP programs.

LESSON 40 SCREEN ELEMENTS FOR INPUT AND OUTPUT

SCREEN ELEMENTS FOR INPUT AND OUTPUT:



An input field is a rectangular screen element in which users can enter data.

An output field is a rectangular screen element in which the system displays text or other data.

Input/output fields are also known as templates.

Input fields can have automatic input checks based on thir data type (for example, a date field will only allow you to enter a valid date).

Input fields that you create with reference to ABAP Dictionary fie lds may have built-in data consistency checks (foreign key checks, value sets).

Input fields may have possible values help (F4)

You can temporarily change the object attributes marked in gray using the system table SCREEN.

It may not be possible to activate all possible combinations of attributes. This depends on the format of the input/output fie ld.
Example: You cannot activate the Leading zeros attribute for a field with the data format CHAR, since it is only relevant for numeric fields.

You can create input/output fields in two ways:
By entering them directly in the layout editor. You determine the size of the field by the number of underscore characters in the object text attribute. For numeric values, you can specify a comma as a separator, and a period as a decimal point. As the last character in the input/output field, you can enter 'V' as a placeholder for a plus or minus sign.

By using a template from the ABAP Dictionary. Choose Dict/Program fields to do this.

If you want to use the contents of an input/output field in your ABAP program, you must declare the field globally using the DATA or TABLES statement.

You can save values in SAP memory using a parameter ID. These are user and terminal-session specific, but available to all internal sessions .

SET PARAMETER copies the corresponding field contents into SAP memory in the PAI processing block.

GET PARAMETER copies the corresponding field contents from SAP memory at the end of the PBO processing block (after data has been transferred from the program), but only if the screen field still has its initial value.

You can link an input/output field to an area of SAP memory in the ABAP Dictionary.

When you use an input/output field that is defined in the ABAP Dictionary, its parameter ID is displayed in the Dictionary attribute PID in the Screen Painter.

The SPA and GPA attributes allow you to enable the set and get parameter functions separately.

You can define parameter IDs in table TPARA.

After the screen has been displayed, but before the PAI modules are processed, the system automatically checks the values that the user has entered on the screen.

The first check is to ensure that all required fields have been filled.

The system can only perform a foreign key check if a screen field refers back to a ABAP Dictionary field for which a check table has been defined and the Foreign key check attribute has been set.

The F4 help function is also active. This enables users to display possible entries.

If the automatic field input checks are insufficient for your requirements, you can program your own in the PAI event. To do this, use the FIELD statement with the MODULE addition. This means that the module you specify is only processed for the field specified in the FIELD statement.

If an error or warning message occurs during the module, the system sends the screen again, but without processing the PBO module . The message is displayed, and only the field to which the check was applied is ready for input.

Note: It is the FIELD statement that is responsible for making the field ready for input again. If you use a message in a module that is not called from within a FIELD statement, the system displays the message, but does not make the field ready for input again.

If you want to ensure that more than one field is ready for input following an error dialog, you must list all of the relevant fields in the FIELD statement, and include both that and the MODULE statement in a CHAIN … ENDCHAIN block.

You can include individual fields in more than one CHAIN … ENDCHAIN block.

Note that the FIELD statement does not only make the field ready for input again; it also means that field contents changed during the current PAI processing are only visible if the field in question was also included in the FIELD statement of the current CHAIN block.

If the system sends an error or warning message, the current screen is sent again, but the PBO is not processed again.

Only the fields to which the module is assigned are ready for input again.

After the user has entered new values, the PROCESS AFTER INPUT module is not completely reprocessed, but restarted somewhere within the processing block.

The system finds out which field the user changed and resumes processing at the first corresponding FIELD statement.

If the user merely confirms a warning message (without changing the fields contents), the system restarts the PAI processing after the MESSAGE statement where the error was triggered.

There are six different categories of message: A, X, E, W, I, and S:

A Termination The processing terminates and the user must restart the transaction.
X Exit Like message type A, but with short dump MESSAGE_TYPE_X.
E Error Processing is interrupted, and the user must correct the entry.
W Warning Processing is interrupted and the user can correct the entries (works
like an E message). However, it is also possible to confirm the existing
entries by pressing ENTER (works like an I message)
I Information Processing is interrupted, but continues when the user has confirmed
the message (pressed ENTER).
S Success Displays information on the next screen

The system transports data from screen fields into the ABAP fields with the same name in the PAI processing block. First, it transports all fields that are not contained in any FIELD statements. The remaining fields are transported when the system processes the relevant FIELD statement.

If an error or warning message occurs in a module belonging to a FIELD statement, the current values of all fields in the same CHAIN structure are automatically transported back into their corresponding screen fields.

Field input checks usually require access to the database. Consequently, avoiding them where possible improves the performance of your program.

If the user "strayed" onto the screen by mistake, he or she will not usually be able to make a consistent set of entries that will satisfy the input checks. You should therefore make it possible for a user to leave a screen without the field checks taking place.

To protect the user from losing data that he or she has already entered if they leave the screen unintentionally, you should program security prompts.

If you use the ON INPUT addition in a MODULE statement after FIELD, the module is only called if the field contents have changed from their initial value.

Within a CHAIN block, you must use the ON CHAIN-INPUT addition. The module is then called if the contents of at least one screen field within the CHAIN block have changed from their initial value.

You may only use the ON INPUT addition if the MODULE statement is contained in a FIELD statement.

If you use the ON REQUEST addition in a MODULE statement after FIELD, the module is only called if the user has entered a new value in that field.

Within a CHAIN block, you must use the ON CHAIN-REQUEST addition. The module is then called if the user has changed the contents of at least one screen field within the CHAIN block.

You may only use the ON REQUEST addition if the MODULE statement is contained in a FIELD statement.

The module with the addition AT EXIT-COMMAND is processed before the automatic field input checks. You can use it for navigation. You may only use the AT EXIT-COMMAND addition with one module. It may not have an associated FIELD statement.

If you do not leave the screen from this module, the automatic field checks are processed after it, followed by the rest of the PAI event.

Ensure that you process the contents of the OK_CODE field appropriately.
The SAP Style Guide contains details of how you should set the navigation functions

Back, Exit, and Cancel.

The BACK function (green left arrow) should lead one logical level backwards. From screens on the same level as the initial screen, it leads back to the initial screen. From screens that contain detailed information, it leads back to the screen that called the current screen.

The CANCEL function differs from BACK in its dialog behavior. For details, see the next page.

The EXIT function should return to where the processing unit was called.

On the initial screen of a program, all three functions Back, Exit, and Cancel lead back to the screen from which the current program was called.

If the user has entered data on the screen (sy-datar = 'X' or your own flag), you can avoid accidental loss of data by using a predefined security prompt.

As well as specifying the targets of the Back, Exit, and Cancel functions, the SAP Style Guide also contains information about the dialogs you should conduct with the user, and the sequence of dialogs and automatic field checks.

For the Exit and Cancel functions, you should first send a dialog box to the user. Then (in the case of the Exit function), the system checks the input on the screen. The functions in question must have function type 'E'.

In the case of the Back function, the input checks come before the dialog.

The R/3 System contains a series of function modules that you can use for the user dialogs.

You can help the user with input by using dropdown list boxes containing the possible entries.

Input help (F4 help) is a standard function in the R/3 System. It allows the user to display a list of possible entries for a screen field. If the field is ready for input, the user can place a value in it by selecting it from the list.

If a field has input help, the possible entries button appears on its right hand side. The button is visible whenever the cursor is placed in the field. You can start the help either by clicking the button or choosing F4.

As well as the possible entries, the input help displays relevant additional information about the entries. This is especially useful when the field requires a formal key.

Since the input help is a standard function, it should have the same appearance and behavior throughout the system. There are utilities in the ABAP Workbench that allow you to assign standardized input help to a screen field.

The precise description of the input help of a field usually arises from its semantics. Consequently, input help is usually defined in the ABAP Dictionary.

Dropdown list boxes allow the user to choose an entry from a pull-down list containing the possible entries. The user cannot enter values freely, but must choose a value from the list.

To create a dropdown list box for an input field, you must do the following in the
Screen Painter:

Set the Dropdown attribute to list box.
Change the visLength attribute to the displayed length of the descriptive text.
Set the Value list attribute to ' ' to use value help from the ABAP Dictionary.

If required, set the function code for the selection. Like a menu entry, this function code triggers the PAI, and you can interpret it using the OK_CODE field.

Important: The visible length of the field determines the width of the field including button) and the selection list, and you must normally change it when you convert the field to a dropdown box.

The values are filled automatically using the search help assigned to the ABAP Dictionary field. The Dictionary field must have a search help (check table) with two columns or a table of fixed values.

Various things are required of input help for a screen field (the search field):

The input help must take into account information that the system already knows (the context). This includes both information that the user has entered on the current screen, and information from previous dialog steps. The input help normally uses the context to restrict the set of possible values.

The input help must find out the values that it will then present to the user for selection. It must also determine the data that will be displayed as additional information in the list of possible values. In determining the possible values, it must take into account restrictions that arise from the context, as well as those entered by the user as specific search conditions.

The input help must conduct a user dialog. This involves (at least) displaying the possible values with additional information, and allowing the user to choose a value from it. In many cases, the input help will also contain an input screen on which the user can specify conditions to restrict the number of possible entries displayed.

When the user selects a value, the input help must place it into the search field. In many cases, there are extra fields on the input screen (often only output fields), containing extra information about the search field. The input help should also update the contents of these fields.

The ABAP Dictionary object search help is a description of an input help. Its definition contains the information that the system requires to meet the user's needs.

The interface of the search help controls the data that is passed between the input screen and the F4 help. The interface determines the context data that is required and the data that can be placed back on the input screen when the user chooses a value.

The internal behavior of the search help describes the actual F4 process. This contains the selection method, which retrieves the values for display, and the dialog behavior, which describes the interaction with the user.

Similarly to function modules, search helps have an interface, which defines their capacity to exchange data with other software components, and an internal behavior (which, in the case of a function module, is its source code).

It is only worth defining a search help if there is a mechanism that allows you to address it from a screen. This mechanism is called a search help connection, and is described later.

Like the function module editor, the search help editor also allows you to test your objects. This allows you to check how a search help behaves before you assign it to a screen field.

A search help describes the process of an input help. In order for it to work, we need a mechanism that assigns the search help to the field. This is called the search help connection.

Connecting a search help to a field affects its behavior. It is therefore regarded as part of the field definition.

The semantic and technical attributes of a screen field (type, length, F1 help) are ormally not defined directly when you define the screen. Normally, you use a reference in the Screen Painter to an existing field in the ABAP Dictionary. The screen field then inherits the attributes of the ABAP Dictionary field.
The same principle applies when you define input help for a screen field. The link between the search help and the search field is established using the ABAP Dictionary field, not the screen field.

When you assign a search help, its interface parameters are asssigned to the screen fields that are filled by the search help, or which pass information to it from the screen. The search field must be assigned to an EXPORT parameter of the search help. You should also make the search field an IMPORT parameter, so that the search help can take into account a search pattern already entered in the field by the user.

A field can have input help even if it does not have a search help - there are other mechanisms for F4 help (for example, fixed values for a domain).

There are three ways to link a search help to a field in the ABAP Dictionary.

It can be assigned directly to a field of a structure or table. You define this link in very much the same way as you would define a foreign key. You should define the assignment here (between the interface parameters of the search help and the structure field). The system generates a proposal.

If the field has a check table, its contents are automatically proposed as possible values in the input help. The key fields of the check table are displayed. If the check table has a text table, the first nonkey character field is also displayed.
If the default display is insufficient for your requirements, you can attach a search help to the check table. This is then used for all fields that have that check table. When you link the search help, you must define the assignment between the search help interface and the key of the check table.

The semantics of a field and its possible values are defined by its data element. You can therefore also link a search help to a data element. The search help is then used by all fields that are based on that data element. When you link the search help, you must specify a single EXPORT parameter, which will be used to transfer the data.

Attaching a search help to a check table (or data element) increases its reusability. However, it does restrict your options for passing extra values to the search help interface.

To allow as many fields as possible to carry useful input help, the R/3 System contains a wide range of mechanisms with which you can define it. If it is possible to use more than one of these for a particular field, the one highest in the hierarchy is used.

As well as defining the input help for a field in the ABAP Dictionary (as we have already seen), you can also define it in the screen field. This method has the disadvantage that you cannot reuse it automatically.

The screen event POV (PROCESS ON VALUE-REQUEST) allows you to program input help for a field yourself. You can make this help appear in standard form by using the function modules F4IF_FIELD_VALUE_REQUEST or F4IF_INT_TABLE_VALUE_REQUEST.
However, you should first check to see whether you cannot program your own input help better using a search help exit.

You can also attach a search help to a screen field in the Screen Painter. However, the functional scope of this technique is more restricted in comparison to attaching a search help in the ABAP Dictionary.

You should no longer use input checks programmed directly in the flow logic (and from which input help can be derived).

In the context menu (right-click) for the hit list, there is a function Technical info. This tells you which mechanism is being used in a particular case.

Use radio buttons when you want to allow a user to choose only a single element from a group of fields.

Use checkboxes when you want to allow the user to choose one or more elements from a group of fields.

With radio buttons, one selection rules out all other options within the group. When the user selects one, all of the others are automatically deselected.

When the user selects a radio button, control is not immediately passed back to a work process on the application server. As with checkboxes (but in contrast to pushbuttons), it is still possible to make further entries before pressing a pushbutton or choosing a menu option.

Checkboxes allow the user to select more than one element at once. Control is not returned to a work process on the application server. This does not happen until the user chooses a pushbutton or menu entry.

Checkboxes and radio buttons must have an object name.

As well as the input/output field, you can display text and icons for them. The text is contained in the Object text field in the attributes. To display an icon, enter its name in the Icon name attribute. You can enter quick info for the icon in the appropriate field.

You can change the Input field and Invisible attributes using the system table SCREEN.

You create checkboxes in the fullscreen editor of the Screen Painter. To do this, choose the checkbox object from the object list and place it on the screen. You must assign names to checkboxes. In the ABAP program, create a field with the same name, type C, and length 1.

You can find out whether a user has chosen a checkbox in the ABAP program by querying the field contents. If a checkbox is not selected, its field value is initial.

You can assign a function code and function type to a checkbox. When the user selects it, the PAI event is triggered as though the user had chosen a menu entry.

You create radio buttons in the layout editor of the Screen Painter. There are two steps involved:

Create the radio buttons as individual elements. Choose "radio button" from the bject list and place it on the screen. You must assign names to radio buttons. In the ABAP program, create a field with the same name, type C, and length 1.
Combine a collection of radio buttons into a radio button group. To do this, select the radio buttons in the layout editor and then choose Edit -> Group -> Radio button group -> Define.


You can find out which radio button a user has chosen by querying the field contents in the ABAP program. If a radio button is not selected, the field value is initial.

You can assign a function code and function type to a radio button group. When the user selects one of its radio buttons, the PAI event is triggered as though the user had chosen a menu entry.

A pushbutton triggers a particular function. When the user chooses it, the system tells the program which function has been chosen. At this point, control of the program passes back to a work process on the application server, which processes the PAI processing block.

Pushbuttons may contain text (Object text attribute), an icon, or both. You can either specify an icon statically, or dynamically, using the function module ICON_CREATE.

You can change the visible length , output field , and invisible attributes dynamically using the system table SCREEN.

You can change the text on a pushbutton dynamically. To do this, you must have set the Output field attribute in the Screen Painter to active, and created a global field with the same name in your ABAP program. Because the Screen Painter field and the program field have the same name, any changes to the field contents will be immediately visible on the screen (similarly to input/output fields).

When you create a pushbutton, you must:

Create the pushbutton itself. Choose the Pushbutton object from the Screen Painter object list, place it on the screen, and assign a name to it in the "Object name" attribute. You can enter a static text in the "Object text" attribute. Enter a function code for the pushbutton in the "Function code" attribute. This is placed in the OK_CODE field automatically when the user chooses the pushbutton on the screen.
Activate the OK_CODE field on the screen by assigning a name to the OK_CODE field object in the Screen Painter field list and creating a field in your ABAP program that has the same name. You m,ust give the field a name in the element list of the Screen Painter, then declare an identically-named field in the ABAP program with reference to the system field sy-ucomm.


When the user chooses a function on the screen, the system places the corresponding function code into the OK_CODE field. You can then query the field and use the result to trigger the appropriate processing block.

Pushbuttons have a function code and a function type.

If the user chooses a pushbutton that has the function type ' ', the PAI event is processed. The system places the function code that has been triggered into the OK_CODE field, which you can then query in the module.

If the user chooses a pushbutton whose function has the function type "E", the system processes a module with the addition AT EXIT-COMMAND. This happens before the automatic field transport and the field input checks. The system places the function code that has been triggered into the OK_CODE field, which you can then query in the module.

After the AT EXIT-COMMAND module, the system continues processing the screen normally (field input checks, followed by PAI processing).

Tuesday, June 29, 2010

LESSON 41 SUBSCREEN TABSTRIPS

SUBSCREEN TABSTRIPS:

A subscreen area is a reserved rectangular area on a screen, into which you place another screen at runtime. Subscreen areas may not contain any other screen elements. To use a subscreen, you create a second screen (with the type subscreen), and display it in the subscreen area you defined on the main screen.

A subscreen is an independent screen that you display within another screen. You may want to use a subscreen as a way of displaying a group of objects in certain circumstances, but not in others. You can use this technique to display or hide extra fields on the main screen, depending on the entries the user has made.

A second use for subscreens is that different programs can use the same subscreens. To do this, you must execute other screen programs within your main program.

You can include more than one subscreen on a single main screen. You can also determine the subscreens dynamically at runtime.

You can use subscreens in the following circumstances:
In screen enhancements (screen exits), Within other screen objects (tabstrip control)
In the Modification Assistant In Web transactions.

If the subscreen is larger than the subscreen area in which it is called, the system only displays as much of it as will fit onto the screen. However, you can use the Scrollable attribute to ensure that, if the screen is too big, the system will display scrollbars.

The resizing attributes control whether the size of a subscreen area can be changed vertically and horizontally. You should set these attributes if you want the size of the subscreen area to change with the size of the whole window. You can use the minimum size attribute to set a lower limit beyond which the subscreen area cannot be resized.

The Context menu attribute allows you to assign a context-sensitive menu to the output fields on the subscreen screen.

The following restrictions apply to subscreens:
CALL SUBSCREEN ... is not allowed between LOOP and ENDLOOP or between
CHAIN and ENDCHAIN.

A subscreen may not have a named OK_CODE field.
Object names must be unique within the set of all subscreens called in a single main screen.

Subscreens may not contain a module with the AT EXIT-COMMAND addition.
You cannot use the SET TITLEBAR, SET PF-STATUS, SET SCREEN, or LEAVE
SCREEN statements in the modules of a subscreen.

To create a subscreen area, choose subscreen from the object list in the Screen Painter and place it on the screen. Fix the top-left hand corner of the table control area, and then drag the object to the required size.

In the Object text field, enter a name for the subscreen area. You need this to identify the area when you call the subscreen.

To use a subscreen, you must call it in both the PBO and PAI sections of the flow logic of the main screen. The CALL SUBSCREEN statement tells the system to execute the PBO and PAI processing blocks for the subscreen as components of the PBO and PAI of the main screen. You program the ABAP modules for subscreens in the same way as for a normal screen (apart from the restrictions already mentioned).

If the subscreen is not in the same module pool as the "main program", the global data of the main program is not available to the subscreen, and the data from the screen will not be transferred back to the program. You must program the data transfer yourself (for example, using a function module that exports and imports data, with an appropriate MOVE statement in the subscreen coding).

If you want to use subscreens in the screens of several different programs, you should encapsulate the subscreens in a function group and use function modules to transport data between the program in which you want to use the subscreen and the function group.

You can pass data between the calling program and the function group using the interfaces of the function modules.

This is the technique used for customer subscreens (screen enhancements).

You use function modules to transport data between the calling program and the function group.

To declare the data from the calling program to the subscreen of the function group, use a module before the subscreen call. This should call a function module whose interface you can use to pass the required data to the function group.

The function module call must occur before the subscreen call. This ensures that the data is known in the function group before the PROCESS BEFORE OUTPUT processing block of the subscreen is called.

In the PAI module of the calling screen, the sequence is reversed: You call the PROCESS AFTER INPUT processing block of the subscreen before calling a function module to pass the data from the function group back to the calling program.

For the data from the calling program to be available globally in the function group, you must transfer the interface parameters from the function module into global data fields of the function group.

The function module that you use to transfer the data from the calling program into the function group must copy its interface parameters into the global data in the function group.

The function module that you use to transfer data from the function group to the calling program must copy the corresponding data from the global data of the function group into its interface parameters.

Tabstrip controls provide you with an easy, user-friendly way of displaying different components of an application on a single screen and allowing the user to navigate between them. Their intuitive design makes navigation much easier for end users.

Tabstrip controls are a useful way of simplifying complex applications. You can use tabstrip controls wherever you have different components of an application that form a logical unit. For example, you might have a set of header data which remains constant, while underneath it, you want to display various other sets of data.

You should not use tabstrip controls if

You need to change the screen environment (menus, pushbuttons, header data, and so on) while processing the application components. The screen surrounding the tabstrip must remain constant.

The components must be processed in a certain order. Tabstrips are designed to allow users to navigate freely between components.
The components are processed dynamically, that is, if user input on one tab page leads to other tab pages suddenly appearing.

Tabstrip controls are compatible with batch input processing.

A tabstrip control consists of individual pages. These consist of the page area and the tab title.

The tab may only have one row of tab titles.

If the tabstrip control contains too many pages, it will not be possible for all of the tab titles to be displayed at once. If this happens, the system displays a scrollbar with which you can scroll through the remaining tab pages. In the top right-hand corner of the tab is a pushbutton. If the user clicks this, a list of all of the tab titles is displayed. The active tab title is marked with a tick.

A tabstrip control consists of individual pages. These consist of the page area and the tab title.

The tab may only have one row of tab titles.

If the tabstrip control contains too many pages, it will not be possible for all of the tab titles to be displayed at once. If this happens, the system displays a scrollbar with which you can scroll through the remaining tab pages. In the top right-hand corner of the tab is a pushbutton. If the user clicks this, a list of all of the tab titles is displayed. The active tab title is marked with a tick.

A tab page consists of a tab title, a subscreen area, and a subscreen.

From a technical point of view, the system handles tab titles like pushbuttons.

The contents of tab pages are displayed using the subscreen technique. You assign a subscreen area to each tab page, for which you can then call a subscreen.

As well as the general "Object name", "Starting position" and static size attributes, tabstrip controls also have special tabstrip attributes.

You create a tabstrip control in the following three steps:

Define the tab area
Define the tab titles and, if necessary, add further tab titles
Assign a subscreen area to each tab page.

To create a tabstrip area, choose Tabstrip from the object list in the Screen Painter and place it on the screen. Fix the top-left hand corner of the table control area, and then drag the object to the required size.

Assign a name to the tabstrip control in the "Object name" attribute. You need this name to identify your tabstrip control.

In your ABAP program use the CONTROLS statement to declare an object with the same name. Use TABSTRIP as the type.

The type TABSTRIP is defined in the type pool CXTAB. The field ACTIVETAB contains the function code of the tab title of the currently active tab page. The other fields are reserved for internal use.

The default number of tab pages for a tabstrip control is two.

Technically, tab titles are treated in the same way as pushbuttons. They have an object name, a text, a function code, and a function type. You enter these in the "Object name", "Object Text", "FctCode" and "FctType" fields of the obje ct attributes.

A tab title can have the function type ' ' (space) or 'P'. If the function type is ' ' (space), the PAI processing block is triggered when the user chooses that tab, and the function code of the tab title is placed in the OK_CODE field. If the function type is 'P', the user can scroll between the different tab pages with the same type without the PAI processing block being triggered. For further details, refer to the following pages.

If you want your tabstrip control to have more than two pages, you must create further tab titles. To do this, choose Pushbutton from the object list in the Screen Painter and place it in the tab title area.

You must assign a subscreen area to each tab page.

The subscreen area assigned to a tab page is automatically entered as the "Reference object" (in the Dictionary attributes) for the tab title of that page.

To assign a subscreen area to one or more tab pages, choose the relevant tab title in the fullscreen editor, choose the Subscreen object, and place it on the tab page.

Alternatively, you can assign a single subscreen area to several tab pages by entering the name of the subscreen area directly in the "Reference object" field of the attributes of the relevant tab pages.

If you have assigned a different subscreen area to each tab page in a tabstrip control, you can scroll between the pages locally at the frontend.

To do this, you must send all of the subscreens to the front end when you send the main screen itself.
All of the tab titles in the tabstrip control must also have function type 'P'.

Now, when you scroll between the different tab pages, there is no communication between the presentation server and the application server.

When the user chooses a function on the screen that triggers PAI processing, the system processes the PAI blocks of all of the subscreens as well. This means that all of the field checks are run. In this respect, you could regard the tabstrip control as behaving like a single large screen.

Local scrolling in tabstrip controls is more appropriate for display transactions.

To program a tabstrip control to scroll locally at the front end, you must:
Assign a separate subscreen area to each tab page; a subscreen will be sent to each of these when the screen is processed.

Call all of the subscreens from the flow logic.
Assign function code type 'P' to all of the tab titles.

The system hides any tab page whose subscreen contains no elements that can be displayed.

If there are no tab pages containing elements that can be displayed, the system hides the entire tabstrip control.

If all of the tab pages share a single subscreen area, the program analyzes the function code of the chosen tab title to determine which screen is displayed.

There are two steps in this process:

In the PAI processing block, the program determines which tab page needs to be active, based on the tab title chosen by the user.

When the PBO processing block is processed again, the program displays the corresponding Screen .

During this process, the system only checks the fields of the subscreen that is actually displayed.

If you want the application program to process scrolling in a tabstrip control,
All of the tab pages must share a common subscreen area
All of the tab titles must have the function code type ' ' (space), and
In the flow logic, you must use a variable to call the screen that is to be displayed in the subscreen area.


In the PAI block, you must call a module in which the function code of the active tab title is placed in the field ACTIVETAB of the structure you created in your program with type TABSTRIP. In the example above, this is MY_TAB_STRIP.

The PBO processing block must contain a module, before the subscreen is called, in which you place the number of the subscreen in the corresponding variable. In order for the screen to be processed the first time (before the user has had a chance to choose a tab title), you must assign an initial value to this field.

You can hide a tab page at runtime by setting the corresponding tab title to inactive using the system table SCREEN (SCREEN-ACTIVE = '0'). You should do this before processing the tabstrip control for the first time, to ensure that the screen environment remains constant.

You can now create tabstrip controls on selection screens. They allow you to create logical groups of fields, and make large selection screens more user-friendly.

The following requirements must be met if you are to use selection screens with tabstrip controls in your R/3 System:

GUI version 4.0 or higher
Frontend: Motif, Windows 95, MacOs, NT 3.51 or higher.

For a selection screen with tabstrips, you must define:

•A subscreen area on the selection screen to accommodate the tabstrip control
•The individual tab titles
•Selection screens as subscreens for the individual tab pages

Since it is possible to define selection screens as subscreens, you can include selection fields that you create in this way in any other screens. Selection screens as subscreens are processed similarly to other screens.

You define a selection screen as a subscreen as follows:
SELECTION-SCREEN BEGIN OF SCREEN AS SUBSCREEN
[NESTING LEVEL ] [NO INTERVALS].
...
SELECTION-SCREEN END OF SCREEN .

Optional additions: [NESTING LEVEL ]. Each box around a tabstrip control increases the NESTING LEVEL by one.
[NO INTERVALS]. This option hides the HIGH fields for any selection criteria defined using SELECT-OPTIONS on the screen.

You define a subscreen area for a tabstrip control on a selection screen as follows: SELECTIONSCREEN BEGIN OF TABBED BLOCK FOR LINES.
SELECTION-SCREEN END OF BLOCK .

The size of the subscreen area in lines is defined by .

The system automatically generates a CONTROLS statement (CONTROLS:
TABSTRIP_BLOCKNAME TYPE TABSTRIP.) You must not write your own CONTROLS
statement. If you try to do so, a syntax error results.

You define the individual tab pages as follows:
SELECTION-SCREEN TAB (length) USER-COMMAND [DEFAULT [PROGRAM /SCREEN ]].
Optional additions: [DEFAULT [PROGRAM /SCREEN ]].
Assign the selection screen to a tab page. If you use the DEFAULT addition, you must also use the SCREEN addition. The PROGRAM addition is optional. You only need it if the screen co mes from another program.

You can delay specifying the link between the tab title and the selection screen until runtime. You can also change an existing assignment at runtime. To do this, fill the structure blockname. This is created automatically for every tabstrip block. The structure has the same name as the tabstrip block, and contains the fields PROG, DYNNR, and ACTIVETAB.

If you define a selection screen as a subscreen, you can display it on a normal screne or in a tabstrip control that is embedded in a normal screen.

All you need to do is define the selection screen as a subscreen with the relevant selection options and input parameters. You can then define a subscreen area on the screen and embed the subscreen screen in it, by calling the subscreen screen in the PBO event and, if necessary, in the PAI event as well.


LESSON 42 SCREEN ELEMENTS ANDTABLE CONTROLS

SCREEN ELEMENTS ANDTABLE CONTROLS:



A table control is an area on the screen in which the system displays data in tabular form. It is processed using a loop. The top line of a table control is the header line, which is distinguished by a gray separator.

Within a table control, you can use table elements, key words, templates, checkboxes, radio buttons, radio button groups, and pushbuttons. A line may have up to 255 columns; each column may have a title.

You can display or enter single structured lines of data using a table control.

Features:
Resizeable table for displaying and editing data.
The user or program can change the column width and position, save the changes, and reload them later.

Check column for marking lines. Marked lines are highlighted in a different color.
Line selection: Single lines, multiple lines, all lines, and deselection
Column headings double as pushbuttons for marking columns.
Scrollbars for horizontal and vertical scrolling.
You can fix any number of key (leading) columns.
Cell attributes are variable at runtime.

Users can save display variants for table controls. These variants can be saved by each user, along with the basic setting, as the current display setting or as the default display setting.

The table control contains a series of attributes that are controlled entirely at the presentation server:
These are:

Horizontal scrolling using the scrollbar in the table control
Swapping columns
Changing column widths
Marking columns
Marking lines

The PAI processing block is triggered when you scroll vertically in the table control or save the user configuration.

As well as the normal "Object name", "Start position on screen" and "Static size" attributes, table controls also have special table control attributes.

The "Special table control attributes" determine the table type and display options for a table control, as well as whether it can be configured by the user. The fields stepl and loopc of structure syst contain information about the loop processing used with table controls (see following pages).

For further information about the static attributes, refer to the online documentation.

When you create a table control, you must create:

A table control area.
Table control fields.

To create a table control area, choose the table control object from the object list in the Screen Painter and place it in the screen work area. Fix the top-left hand corner of the table control area, and then drag the object to the required size.

In the "Object name" attribute, assign a name to your table control. In the ABAP program, declare a structure with the same name, containing the dynamically changeable attributes of the table control.

The CONTROLS statement declares a complex data object with the type TABLEVIEW
(corresponding to the type CXTAB_CONTROL, declared in type group CXTAB in the ABAP
Dictionary). At runtime, the data object (my_control) contains the static attributes of the table control.

You maintain the initial values (static attributes) in the Screen Painter. The USING SCREEN addition in the CONTROLS statement determines the screen whose initial values are to be used for the table control.

You can reset a table control to its initial attributes at any time using the statement REFRESH CONTROL FROM SCREEN . does not have to be the same as the initial screen of the table control.

You create fields in a table control using the Dict./Program fields function. This involves the following steps:
Enter the name of the structure whose fields you want to use in the table control and press ENTER.

In the field list, choose the fields that you want to use and choose OK.
Position the cursor in the table control area and click the left mouse button.
The system places all of the selected fields in the table control. If the fields have data element texts, the system uses these as column headings.

Alternatively, you can position individual input/output fields in the table control area, each of which generates a single column.

When you create a table control, the system automatically proposes one with a selection column.

The selection column behaves like a checkbox. It must therefore be a field with length 1 and data type CHAR. You must enter the field name in the attributes of the table control.

The selection column is a field of the structure used for transport between the screen and the ABAP program.

The runtime attributes of a table control, which are stored in the structure declared using the CONTROLS statement, can be divided into general attributes and column attributes.

The general attributes contain information about the attributes of the table control as a whole, such as, for example, the number of fixed columns.

The column attributes are stored in an internal table (one entry per column of the internal table).

For each column, it maintains the attributes stored in the structure SCREEN, plus the special table control column attributes column position, a selection and a visibility flag, and a field for the displayed width.

For information about the names of the attributes and their precise meanings, refer to the keyword documentation in the ABAP Editor for the CONTROLS statement (then choose Tableview -> CXTAB_CONTROL).

You can change a table control dynamically by modifying the contents of the fields in the table control structure declared in your program.

The fields of the table control structure also provide information about user interaction with the table control. For example, you can use the selected field to determine whether the user has selected a particular column.

For performance reasons, you read the data for the table control once from the database and store it in an internal table using an array fetch.

The system fills the table control lines from this internal table.

Before you can display data from an internal table in a table control, you must first fill the table. Make sure that you do not fill the internal table in every PBO event, but only when the key fields change (in the above example, airline and flight number).

For the table control processing, you need to know how far the user can scroll vertically (the size of the internal table). You should therefore use the DESCRIBE TABLE statement to find out the number of entries in the internal table, and save this in the LINES field of the table control.

There is only one work area for processing lines in the table control. For this reason, you need a LOOP … ENDLOOP. structure in both the PBO and PAI events for each table control.

In the PBO processing block, you must fill one line of the table control with the corresponding line from the internal table in each loop pass.

Similarly, in the PAI processing block, you must pass the changes made in the table control back to the correct line of the internal table.

When you process functions, you must distinguish between those that should only apply to individual lines of a table control, and those that should apply to the entire screen.

There are three steps involved in displaying buffered data from the internal table in the table control:

The system loops through the lines of the table control. The lines of the screen table are processed one by one. For each line, the system carries out the following steps:

The current line of the internal table is placed in the work area of the internal table. (Note that it is possible to scroll in the table on the screen.)
The data from the work area of the internal table is copied into the relevant line of the table control.

When you use table controls on a screen, the field transport sequence changes.

In the PBO processing block, data is transferred from the ABAP program to the screen after each loop pass in the flow logic. The rest of the screen fields are filled, as normal, at the end of the PBO.

The loop statement in the flow logic LOOP AT INTO WITH CONTROL starts a loop through the screen table, and reads the line of the internal table corresponding to the current line of the screen table, placing it in .
is the name of the internal table containing the data, is the name of the work area for the internal table, and is the name of the table control on the screen.

If the fields in your table control have the same structure and name as those in the work area , the system can transport data between the ABAP program and the screen automatically (step 3).

If you are not using the same structure for the table control fields and the work area of the internal table, you must call a module between LOOP and ENDLOOP that moves the data from the work area into the screen fields (MOVE-CORRESPONDING TO …) .

The system calculates the value of -TOP_LINE when you scroll, but not when you scroll a page at a time outside the table control.

Transferring changed values from the table control back to the internal table involves the following three steps:

The system loops through the lines of the table control. The lines of the screen table are processed one by one. For each line, the system carries out the following steps:

The data from the current line of the table control is copied into the header line of the internal table.

The data in the work area must then be placed in the line of the internal table corresponding to the line of the table control that is being processed. (Note that it is possible to scroll in the table on the screen.)

In the PAI processing block, all screen fields that do not belong to a table control and that are not listed in a FIELD statement are transported back to the work fields in the ABAP program first.

The contents of the table control are transported line-by-line to the corresponding work area in the ABAP program in the appropriate loop.

Lastly, the fields that occur in FIELD statements are transported directly before the corresponding statement.

The LOOP AT . ... ENDLOOP block processes a loop through the lines of the table on the screen.

If the fields on your screen have the same names as the fields in the internal table, you must return the data from the header line of the internal table to the body of the table itself. You do this using the field -current_line.

If the fields on your screen do not have the same names as the fields in the internal table, you must first copy the data into the header line of the internal table. You can then copy the data back into the internal table itself. You can also use the field -current_line to do this.

You can modify the attributes of a table control by overwriting the field contents of the structure created in the CONTROLS statement.

To change the attributes of individual cells temporarily (!), change the table SCREEN in a PBO module that you processes between LOOP and ENDLOOP in the flow logic (LOOP AT SCREEN, MODIFY SCREEN).

In the LOOP, the runtime system initializes the attributes set statically for the table control in the Screen Painter. You can only change these in a module called from a loop through the table control.

You can change a table control dynamically by modifying the contents of the fields of its structure.

The fields of the table control structure also provide information about user interaction with the table control. For example, you can use the selected field to determine whether the user has selected a particular column.

It is possible to change the attributes of table control fields temporarily. These changes are only effective while the current screen is being processed.

To do this, you call a module from within the table control loop in the flow logic, in which you change the attributes of the current line.

To change the attributes of the fields of a line in the table control, use a LOOP AT SCREEN. ... ENDLOOP. block to loop through the fields of the current line. Within this loop, you can change the attributes of the fields of the current line of the table control.

You can easily sort the table control display by a particular column using the table control attribute -selected and -screen-name

You can scroll a page at a time in a table control using the table control attribute
-top_line.

In the PAI processing block, you need to know the current number of lines in the corresponding table control.

The system field sy-loopc contains the number of table control lines in the PBO processing block. However, in the PAI, it contains the number of filled lines.

Sy-loopc is only filled between LOOP and ENDLOOP, since it always refers to the current loop.

The LINE parameter in the GET or SET statement refers to the system field sy-stepl, the special loop index in the flow logic.

You calculate the internal table line that corresponds to the selected table control line as follows:

Line = -TOP_LINE + cursor position - 1.

The GET CURSOR statement sets the return code as follows: sy-subrc = 0. The cursor was on a field. sy-subrc = 4: The cursor was not positioned on a field.

If you use a step loop on your screen, you can place the cursor on a particular element within the step loop block. To do this, use the LINE parameter and enter the line on which the cursor should be positioned: SET CURSOR FIELD LINE .

You can also use the OFFSET and LINE parameters together.

LESSON 43 CONTEXT MENUS ON SCREENS

CONTEXT MENUS ON SCREENS:


Context menus (right mouse key, SHIFT F10) are shortcuts for functions that are frequently used.

They can be used to display context-sensitive menus. The context is defined by the position (cursor for SHIFT F10, mouse location for right mouse key) where the user called the context menu. If needed, you can specify the context more precisely with the displayed contents. This permits the user to select functions that are relevant for the current context using the context menu.

You define whether a context menu should be offered when you create a screen object (screens, input fields, table controls, boxes, ...). When the user selects a context menu on an object, an event mechanism (as understood by ABAP objects) calls a certain subroutine in the application program.

The program is assigned a menu reference. The program uses this menu reference to build the display menu. Menus defined with the Menu Painter and dynamic menus can be used here.

After the user executes a menu function, the application program regains control and can react to the user input.

Context menus are assigned to output fields. When you assign a context menu to a box, table control or screen (normal or subscreen), all the subordinate output fields that do not have a context menu inherit that one.

You can create a context menu from within the object list of the Object Navigator. Position the cursor on GUI status and right-click. The Object Navigator automatically opens the Menu Painter.

Of course you can also create a context menu directly in the Menu Painter.

A context menu is a special GUI status. Assign it a name, a descriptive text and status type Context menu.

In a context menu you can link any function codes and function texts. In particular, you can take advantage of your screen pushbuttons. The functions already provided in the interface can be used as an F4 input help.

The link technique ensures consistent context menus in large applications.

You should observe the following rules when designing context menus.

Do not use any functions that cannot be found elsewhere in the system (pushbuttons or interface).

Avoid using more than two hierarchy levels in context menus.

Do not use more than 10 entries, but map all the available pushbuttons.

Use separators to structure the context menu optically.

Place object-specific statements at the beginning of the menu.

Pressing the right mouse key triggers a callback routine in your program. You can create this callback routine in your application program with forward navigation. It is named ON_CTMENU_. You define which callback routine is called in the Screen Painter.

You can directly assign a callback routine to input/output fields, text fields and status icons. Checkboxes, radio buttons and pushbuttons do not have their own callback routines. However, these fields can inherit context menus from boxes or screens.

If you assign a callback routine to a table control, it is triggered for all the fields of the table control that do not have their own callback routine.

The callback routine has the following form:
FORM ON_CTMENU_ USING p_menu TYPE REF TO cl_ctmenu.
.
ENDFORM.

The context menu is built with a method call for the instance of class cl_ctmenu that was passed.

Clicking with the right mouse key on an output field triggers the corresponding callback routine.

You can now use the static method load_gui_status of class cl_ctmenu to load a context menu that was predefined in the Menu Painter. Using other methods of class cl_ctmenu (see next slide) you can also completely rebuild the context menu or modify a loaded menu.

If the user triggers a function in the context menu, the corresponding function code is placed in the command field and triggered depending on function type PAI of the screen.

The class cl_ctmenu provides a number of other methods in addition to the static method load_gui_status. You can use them to adjust the context menu at runtime (e.g. using the values in data fields).

The corresponding methods are called within the callback routine.

You can find further information in the documentation for class cl_ctmenu in the Class Builder.



LESSON 44 LISTS IN SCREEN PROGRAMMING

LISTS IN SCREEN PROGRAMMING:

A list is generally used to output mass data. It can be output on either the screen or a printer.

List may contain colors, symbols and icons as well as text.

There is a standard GUI status for lists. Lists may also have a header and up to four lines of column headers. These are independent program objects, and are translatable.

You can also program interactive lists, which allow users to select lines or particular values. A selection triggers further processing. This might, for example, generate a further list containing a detail list.

You fill the corresponding basic list buffer with WRITE statements at PBO or PAI. You can create your own list and column headers by programming a TOP-OF-PAGE event. This event will be triggered whenever a new page is created in the list buffer (NEW-PAGE).

You can direct the output directly to the spool with the NEW-PAGE PRINT ON statement.

To create interactive lists on screens, you can use the list events AT LINE-SELECTION, AT USER-COMMAND, TOP-OF-PAGE, END-OF-PAGE and TOP_OF_PAGE DURING LINESELECTION.

There is no common list buffer outside of a CALL level.

The list display is processed at the end of the screen in which LEAVE TO LIST-PROCESSING was programmed at PBO or PAI.

To direct the output to the spool, use the NEW-PAGE PRINT ON statement, but not LEAVE TO LIST-PROCESSING.

To create a list that is displayed on a screen, use the ABAP statement LEAVE TO LISTPROCESSING.

This sets a switch that ensures that the contents of the list buffer are output once
the current screen has been processed. The SET PF-STATUS SPACE statement ensures that the list is displayed with the standard GUI status for lists.

Once the screen has been fully processed and LEAVE TO LIST- PROCESSING was executed, the list is displayed on list screen 120 (screen for a basis program).

You can also use the following form: LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0. SET PF-STATUS SPACE. WRITE ... LEAVE SCREEN.

When the system exits list processing (user presses F3, or ABAP statement LEAVE LISTPROCESSING), the system carries on processing the program with the screen following the one from which the list processing was started. You can override this by using the AND RETURN TO SCREEN addition in the LEAVE TO LIST-PROCESSING statement.

If you include the ABAP statement SUPPRESS DIALOG in a PBO module, the current screen is not displayed.

If you want to display a list in a dialog box within a transaction, you must call a screen, but include the SUPPRESS DIALOG statement in its PBO processing block.

To return to the calling screen after leaving the list, declare: LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.