BC410 Programming User Dialogs with Classical Screens (Dynpros) . . PARTICIPANT HANDBOOK INSTRUCTOR-LED TRAINING . Course Version: 18 Course Duration: 3 Day(s) e-book Duration: 13 Hours 5 Minutes Material Number: 50148235 SAP Copyrights and Trademarks © 2018 SAP SE or an SAP affiliate company. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/ corporate-en/legal/copyright/index.epx for additional trademark information and notices. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product specifications may vary. These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions. Typographic Conventions American English is the standard used in this handbook. The following typographic conventions are also used. This information is displayed in the instructor’s presentation Demonstration Procedure Warning or Caution Hint Related or Additional Information Facilitated Discussion User interface control Example text Window title Example text © Copyright. All rights reserved. iii © Copyright. All rights reserved. iv Contents vii Course Overview 1 Unit 1: 2 10 16 23 28 33 40 Lesson: Explaining the User Dialog Programming Model Lesson: Introducing Screen Programming Lesson: Creating Screens and Screen Elements Lesson: Modifying Screens at Runtime Lesson: Designing Screen Sequence Lesson: Calling a Dialog Box Dynamically Unit 2: 41 47 61 Unit 3: Unit 4: Unit 5: 110 Unit 6: 170 Tabstrip Controls Lesson: Creating Tabstrip Controls Lesson: Programming Tabstrip Controls Unit 7: 138 147 157 169 Subscreens Lesson: Creating Subscreens 123 129 137 Screen Error Handling Lesson: Handling Errors Using Dialog Messages and Field Input Checks Lesson: Handling Errors Using Navigation and Input Help 101 122 Simple Screen Elements Lesson: Creating Screen Elements for Output Lesson: Creating Input/Output Fields Lesson: Defining Checkboxes and Radio Button Groups Lesson: Creating Pushbuttons 90 109 The Program Interface Lesson: Explaining User Interfaces Lesson: Setting a GUI Title and a GUI Status 62 70 74 79 89 Introduction to Screen Programming Table Controls Lesson: Creating Table Controls Lesson: Modifying Table Controls at Runtime Lesson: Changing Table Controls at Runtime Unit 8: Context Menus Lesson: Implementing Context Menus © Copyright. All rights reserved. v 178 179 Unit 9: Splitter Control Lesson: Implementing Splitter Control © Copyright. All rights reserved. vi Course Overview TARGET AUDIENCE This course is intended for the following audiences: ● Developer ● Development Consultant © Copyright. All rights reserved. vii © Copyright. All rights reserved. viii UNIT 1 Introduction to Screen Programming Lesson 1 Explaining the User Dialog Programming Model 2 Lesson 2 Introducing Screen Programming 10 Lesson 3 Creating Screens and Screen Elements 16 Lesson 4 Modifying Screens at Runtime 23 Lesson 5 Designing Screen Sequence 28 Lesson 6 Calling a Dialog Box Dynamically 33 UNIT OBJECTIVES ● Explain the single-screen transaction model ● Describe ABAP program types ● Describe the concepts related to screen programming ● Create screens and screen elements ● Modify screens at runtime ● Design screen sequences ● Call dialog boxes dynamically © Copyright. All rights reserved. 1 Unit 1 Lesson 1 Explaining the User Dialog Programming Model LESSON OVERVIEW This lesson describes various aspects of single-screen transactions. The lesson also explains the different ABAP program types and the structure of a typical dialog program. Business Example You want to program user dialogs using the different screen elements for the SAP GUI in the SAP system. For this reason, you require the following knowledge: ● An understanding of the single-transaction programming model ● How to organize your program source code with includes LESSON OBJECTIVES After completing this lesson, you will be able to: ● Explain the single-screen transaction model ● Describe ABAP program types User Dialog A user dialog is a form of interaction between the user and the program. User Dialog Examples Examples of user dialog include the following: ● Entering data ● Choosing a menu item ● Clicking a button ● Clicking or double-clicking a list entry © Copyright. All rights reserved. 2 Lesson: Explaining the User Dialog Programming Model Single-Screen Transaction Model Figure 1: SAP Programming Model The current SAP programming model is single-screen transactions. The aim of the current SAP programming model is to replace long, nested screen sequences with single-screen transactions. Single-screen transactions are easy to use and improve navigation in the program. Input and data screens are combined in one window. Combining the screens saves the user from unnecessary navigation and ensures the correct business context. Based on the user's authorizations, single-screen transactions can provide the user the ability to easily switch between different modes, such as, create, change, and display mode. A single-screen transaction allows a user to directly access the objects to be edited and can limit the selection area by using a filter, a tree structure, or the last edited object. After saving data to the database (if changes are made), the user can view the edited object again to check the changes. © Copyright. All rights reserved. 3 Unit 1: Introduction to Screen Programming Example Screen Layout Figure 2: Example Screen Layout The figure shows an example screen layout of transaction FB60, which is redesigned in accordance with the new programming model. The screen is divided into the following sections, each allowing you to perform different functions: ● Object selection: You can select the object you want to edit from a tree structure. ● Object ID: You can edit the key data and attributes of the whole object. ● Details of object: You can select subobjects for editing. ● Application functions: Only a few functions are available on the application toolbar as a result of the new single-screen transactions. These include display functions such as showing and hiding screen areas, creating new objects with templates, or toggling between different sessions of a program. © Copyright. All rights reserved. 4 Lesson: Explaining the User Dialog Programming Model BC410 Screen Exercise Layout Figure 3: BC410 Screen Exercise Layout The figure describes the screen programming exercises of this class. ABAP Program Types Figure 4: ABAP Program Types © Copyright. All rights reserved. 5 Unit 1: Introduction to Screen Programming The ABAP program types are either complete or incomplete. ABAP programs that are complete can be executed and are of the following types: ● Executable program (type 1) You can run executable programs by choosing System → Services → Reporting or directly from ABAP Editor. A set of processing blocks is processed in a predefined order. You can use a standard selection screen. Traditionally, type 1 programs create and display lists. A list is a type of output format, such as a normal list or an interactive list. In modern reports, lists are defined using SAP List Viewer (ALV). ● Module pool (type M) For a type M program to be executable, you must create at least one transaction code in which you specify an initial screen. You can control the subsequent screen sequence either statically in the screen attributes or dynamically in the program code. ABAP programs that are incomplete cannot be executed directly. They serve as containers for modularization units that are called from other programs. The system loads its entire main program into the internal session of the calling program whenever you load a modularization unit. The following types of programs cannot be executed directly: ● Function group (type F) A function group (type F) can contain function modules, local data types, global data objects, and screens. ● Include program (type I) An include program (type I) can contain any ABAP statement. ● Interface pool (type J) An interface pool (type J) contains a global interface which in turn can contain local data types and constants. ● Class pool (type K) A class pool (type K) contains a global class which in turn can contain constants, local data types, local classes and local interfaces. © Copyright. All rights reserved. 6 Lesson: Explaining the User Dialog Programming Model Program Organization Figure 5: Program Organization In the simplest case, your program consists of a single source that has all the necessary processing blocks. However, to make your program code easy to understand and to be able to reuse its parts in other programs, for example, for data declarations, you should use include programs. Whenever you create a program from the Object Navigator, the system prompts you to create it using the With TOP include option. Selecting this option helps you to create a module pool program that has a clearly defined structure. When you create processing blocks, the system automatically prompts you for the include program where the corresponding source code has to be inserted. If you specify an include program that does not exist, the system creates it and inserts a corresponding INCLUDE statement in the main program. © Copyright. All rights reserved. 7 Unit 1: Introduction to Screen Programming Data Model Example Figure 6: Tables of the Flight Data Model in BC410 The figure shows tables of the flight data model used in this course. Data Model for BC410 – Table Fields and Their Meanings The key table fields used in this course are as follows: Table 1: SPFLI Table Fields Table Field Me Meaning aning CARRID Airline code CONNID Flight connection number AIRPFROM, AIRPTO Departure airport, arrival airport CITYTO, CITYFROM Arrival city, departure city Table 2: SFLIGHT Table Fields Table Field Me Meaning aning CARRID, CONNID See SPFLI FLDATE Flight date SEATSMAX, SEATSOCC Maximum capacity, occupied seats (Economy class) PRICE Basic flight price CURRENCY Local currency of airline © Copyright. All rights reserved. 8 Lesson: Explaining the User Dialog Programming Model Table 3: SBOOK Table Fields Table Field Me Meaning aning CARRID, CONNID, FLDATE See SFLIGHT BOOKID Booking number CUSTOMID Customer number Table 4: SAPLANE Table Fields Table Field Me Meaning aning PLANETYPE Plane type SEATSMAX Maximum capacity LESSON SUMMARY You should now be able to: ● Explain the single-screen transaction model ● Describe ABAP program types © Copyright. All rights reserved. 9 Unit 1 Lesson 2 Introducing Screen Programming LESSON OVERVIEW This lesson describes the concepts and principles of screen programming. Business Example A travel agency needs to maintain the flight booking data for customers by using different screens in an SAP application. For this reason, you require the following knowledge: ● An understanding of the principles of screen programming LESSON OBJECTIVES After completing this lesson, you will be able to: ● Describe the concepts related to screen programming Screens Figure 7: Screens Screens are freely definable objects that are used to display or enter information through input/output fields, lists, and so on. Screens are a form of dialog between a user and an ABAP program. © Copyright. All rights reserved. 10 Lesson: Introducing Screen Programming Strengths of Screens Figure 8: Strengths of Screens Screens allow you to enter and display data. You can use screens in combination with the ABAP Dictionary to check the consistency of the data entered by the user, and also, to provide the user with Input Help and Field Help. Screens allow you to create user-friendly dialogs with input/output fields, text fields, checkboxes, radio buttons, pushbuttons, subscreens, tabstrip controls, table controls, and other screen elements. © Copyright. All rights reserved. 11 Unit 1: Introduction to Screen Programming Screens in Dialog Programs Figure 9: Screens in Dialog Programs Consider the example of a simple dialog program with an initial screen and a screen for displaying information for a selected data record. When the program starts, the system loads its program context and prepares space for the program data objects in memory, then the initial screen is displayed. The user enters data on the initial screen and chooses the Execute button. The program requests data from the database and stores it in the target structure defined in the TOP include. The processing logic calls the second screen and its Process Before Output (PBO) is started. The data in the target structure is moved to the structure with identical field names as the screen fields. This structure serves as an interface to the screen. At the end of PBO, data in the fields of this structure is transferred to the fields with identical names on the screen. Any user action on the screen, such as choosing a menu entry, or clicking a pushbutton, returns control to the runtime system. The data on the screen fields is then transported to the structure that serves as an interface between the screen and the program. The runtime system triggers the processing block belonging to the screen, which is called Process After Input (PAI). This block is always processed after a user interaction. © Copyright. All rights reserved. 12 Lesson: Introducing Screen Programming Attributes of Screen Elements Figure 10: Attributes of Screen Elements Screen elements such as text fields, input/output fields, status icons, group boxes, radio buttons, checkboxes, and pushbuttons have general, dictionary, program, and display attributes. The elements subscreen, tabstrip control, and table control have general and special attributes related to the respective type. You can divide the attributes of an element into the following categories: ● Attributes that are defined statically and cannot be changed dynamically ● Attributes that are defined statically and can be changed dynamically ● Attributes that are only set dynamically For complete documentation of the attributes of screen elements, see the online documentation (in the Help Portal, http://help.sap.com/nw75, under Function-Oriented View (Choose Language) → Application → Application Server ABAP → Application Development on AS ABAP → ABAP Workbench - Classic → ABAP Workbench Tools → Screen Painter → Maintaining Attributes for Screen Elements ). © Copyright. All rights reserved. 13 Unit 1: Introduction to Screen Programming Screen Attributes Figure 11: Screen Attributes Each screen has a set of administration attributes specifying its type, size, and the subsequent screen. The screen also has settings that influence other properties of the screen and its components, as shown in the figure. The administration attributes Screen number and Program identify the screen by its number and the program to which it belongs. Screen numbers greater than 9000 are reserved for SAP system customers. Screen numbers 1000 through 1010 are reserved for the maintenance screens of ABAP Dictionary tables and the standard selection screens of executable programs. The screen type identifies the purpose of a screen. The special attributes of a screen and its components depend on the screen type. The Next screen attribute allows you to specify the screen that must be processed after the current screen in a fixed sequence. For a list of screen attributes and their meanings, refer to the online documentation in the Help Portal, http://help.sap.com/nw75, under Function-Oriented View (Choose Language) → Application → Application Server ABAP → Application Development on AS ABAP → ABAP Workbench - Classic → ABAP Workbench Tools → Screen Painter → Creating a Screen → Maintaining Screen Attributes . © Copyright. All rights reserved. 14 Lesson: Introducing Screen Programming Screen Components Figure 12: Defining and Managing Screens A screen consists of a screen image and its flow logic. Flow logic is a program that controls how a screen image is processed. For information about programming screen flow logic, refer to the Help Portal. Screens have several components: the screen mask, the screen attributes, the element list, and the flow logic. Flow logic contains the flow logic code, not ABAP statements. LESSON SUMMARY You should now be able to: ● Describe the concepts related to screen programming © Copyright. All rights reserved. 15 Unit 1 Lesson 3 Creating Screens and Screen Elements LESSON OVERVIEW This lesson explains how to create screens and screen elements. Business Example A travel agency needs to maintain the flight booking data for customers by using screens in an SAP application. For this reason, you require the following knowledge: ● How to create screens LESSON OBJECTIVES After completing this lesson, you will be able to: ● Create screens and screen elements Screen Creation Figure 13: Creating Screens To create a screen, perform the following steps: 1. Set the general screen attributes on the attribute screen. 2. Design the screen layout in the Layout Editor. 3. Set the field attributes in the field list. 4. Write the flow logic in the flow logic editor. © Copyright. All rights reserved. 16 Lesson: Creating Screens and Screen Elements Setting Screen Attributes Figure 14: Setting Screen Attributes To create a screen from the object list in the Object Navigator, perform the following steps: 1. Create a new development object with the type Screen. Open the context menu for a dialog program and choose Create → Screen. In the dialog box, enter a number, for example, 100, in the field Screen Number and press Enter. The Object Navigator opens the Screen Painter . 2. Enter the mandatory screen attributes, such as: short text and screen type. The default screen type is Normal. 3. Specify the number of the next screen in the Next screen field. If you enter 0 (or do not enter any value), the system resumes processing from the point where the screen was called after the screen processing is over. You can also create a screen by typing the statement SET SCREEN nnnn or CALL SCREEN nnnn (where nnnn stands for the screen number) in the ABAP Editor and double-clicking the screen number. © Copyright. All rights reserved. 17 Unit 1: Introduction to Screen Programming Creation of a Screen Layout Figure 15: Creating Screen Layouts You can create screen elements such as input/output fields by referencing field descriptions from database tables or structures defined in the ABAP Dictionary. However, you can also reference fields defined in your program, such as the Top include. To be able to use the fields defined in your program as a reference for the screen fields, you should activate the program containing the definitions first. The Graphical Layout Editor provides an easy way of defining various screen elements, such as input/output fields, text fields, group boxes, pushbuttons, and so on. You simply choose in the toolbar the element you require and position it on the screen using the mouse. To delete a screen element, select it and choose the Delete pushbutton. You can move elements on the screen by dragging them with a mouse. © Copyright. All rights reserved. 18 Lesson: Creating Screens and Screen Elements Maintain Attributes with Element List Figure 16: Maintaining attributes with Element List To set the attributes of all screen elements, the Screen Painter provides the Element List with several views. You can display the attributes of an element from any list. You can also maintain the attributes of an element in the Layout Editor using the Attribute Window icon (F2) function. In the Screen Painter , you normally create the input/output fields by referencing field definitions which are defined already in the ABAP Dictionary or from a program. For fields that do not have any reference, you must enter the data type yourself. This can be done by using the Format attribute and Default Length under General Attributes . The following table lists some of the corresponding ABAP predefined data types for the ABAP Dictionary data types. For example, the following table lists the ABAP data types and data types in the ABAP Dictionary: Table 5: ABAP and ABAP Dictionary Data Types AB ABAP AP Dictionar Dictionary yD Dat ata a Type AB ABAP AP D Dat ata a Type CHAR C NUMC N © Copyright. All rights reserved. 19 Unit 1: Introduction to Screen Programming Flow Logic of Screens Figure 17: Creating Screens – Flow Logic Screens have their own set of keywords that are used in the Process Before Output (PBO) and Process After Input (PAI) events of the flow logic. In the Screen Painter , start the help (CTRL+ F8) and then choose Statements in the Screen Flow Logic . In the flow logic, you execute modules. Modules are modularization units of an ABAP screen program that contain screen logic written in statements. You can create a module by double-clicking a module name in the flow logic editor. You can also create a module from the object list in the Object Navigator. Choose PBO modules or PAI modules and then use the context menu. You can call the same module from more than one screen. If the processing depends on the screen number, you can retrieve the current screen number from the system field SY-DYNNR . The modules you call in the PBO processing block must be defined using the MODULE… OUTPUT statement. Modules that you define using the statement MODULE… INPUT can only be called in the PAI event. © Copyright. All rights reserved. 20 Lesson: Creating Screens and Screen Elements Data Visibility Figure 18: Data Visibility The following software processors are involved in screen processing for a program: ● The ABAP processor controls the program flow in a module. ● The DYNP processor controls the flow logic and prepares data to be displayed on the screen. During screen processing, two sets of data are visible. You work with the global fields of your program within a module and you also have screen fields. You can create these global fields in the TOP include by using declarative statements, such as TABLES or DATA. For a screen and its ABAP program to be able to communicate, the fields on the screen and the corresponding fields in the program must have identical names. The fields that are recognized by the system from the element list are used to support displaying data on the screen, and also to transport data changed by the user. This occurs automatically when you get the field definitions from the ABAP Dictionary or from the program in the Layout Editor. During screen processing, the identically named fields of DYNP and ABAP are compared. © Copyright. All rights reserved. 21 Unit 1: Introduction to Screen Programming Data Exchange Between Screens and ABAP Programs Figure 19: Data Exchange: Screens – ABAP Programs After the system has processed all modules in the PBO processing block, the system copies the contents of the fields in the ABAP work area to their corresponding fields in the screen work area. The screen and its associated ABAP program communicate only if the fields on screen and the corresponding fields in the program have identical names. Before the system processes the first module in the PAI processing block, the system copies the contents of the fields in the screen work area to their corresponding fields in the ABAP work area. Use your own structures, such as SDYN_CONN, for transporting data between the screen and the ABAP program. Using your own structures ensures that the data being transported from the screen to the program, and vice versa, is exactly the data that you want. LESSON SUMMARY You should now be able to: ● Create screens and screen elements © Copyright. All rights reserved. 22 Unit 1 Lesson 4 Modifying Screens at Runtime LESSON OVERVIEW This lesson explains how to dynamically modify screen attributes and how to initialize the system table SCREEN. Business Example A travel agency needs to maintain the flight booking data for the customers by using different screens in an SAP application. These screens should enable you to dynamically modify attributes. For this reason, you require the following knowledge: ● How to modify screen attributes dynamically LESSON OBJECTIVES After completing this lesson, you will be able to: ● Modify screens at runtime Dynamic Screen Modifications Figure 20: Modifying Attributes Dynamically – Example Dynamic changes to the attributes of screen elements are temporary. Using Dynamic screen modification to modify the attributes of a screen element, you can use the same screen to replace long sequences of separate screens that take more time to program and run. For example, using Dynamic screen modification, you can control the attribute of a screen element and decide whether an input/output field is ready for entry. © Copyright. All rights reserved. 23 Unit 1: Introduction to Screen Programming Dynamically Modifiable Static Attributes Figure 21: Dynamically Modifiable Static Attributes At the beginning of Process Before Output (PBO), the runtime system reads the current screen into a system table with the line type SCREEN. This system table contains the statically created and dynamically modifiable attributes of each screen element. SCREEN-NAME is the unique identifier for a screen element on one screen. However, a text element may be called, using the same name as the input element that the text element describes. The following table lists the values that SCREEN-REQUIRED may take: Table 6: SCREEN-REQUIRED Values Value Description 0 User input is not required. 1 User input is required. 2 User input is recommended. For a complete definition of the SCREEN structure, refer to the documentation on LOOP AT SCREEN in the ABAP Editor. The figure shows the assignment of fields in the system table SCREEN to the names of the statically created attributes of screen elements. © Copyright. All rights reserved. 24 Lesson: Modifying Screens at Runtime SCREEN System Table Figure 22: The SCREEN System Table The SCREEN system table is a system table with line type SCREEN. When a screen is processed, the SCREEN system table contains an entry for each element created for that screen in Screen Painter . Initialization of the SCREEN System Table Figure 23: Initializing the SCREEN System Table © Copyright. All rights reserved. 25 Unit 1: Introduction to Screen Programming A system program initializes the SCREEN system table at the start of the PBO event for the current screen. To initialize the SCREEN table, the program copies the statically defined attributes of the screen elements to the table. You c can an then chang change e the dynamic dynamically ally modifiable attribut attribute es o off the sscr creen een element elementss in a module at PB PBO Ob by y using the ffollo ollowing wing ssttat atement ements: s: LOOP AT SCREEN. ... MODIFY SCREEN. ENDLOOP. To change the dynamically modifiable attributes, use the structure SCREEN. The system automatically creates this structure and fills it with the values of each line of the system table in the loop. Set attributes have the value 1 and attributes that are not set have the value 0. To change the system table, use MODIFY SCREEN within the loop. To find the element whose attributes you want to modify, use LOOP on the SCREEN table and query one of these fields: SCREEN-NAME or SCREEN-GROUP1 to SCREEN-GROUP4. Modification Group Attribute Figure 24: The Modification Group Attribute You can simultaneously change the attributes of several screen elements at runtime. Assign all elements that you want to change within a single processing step to a modification group in Screen Painter. To assign the elements to a group, enter a group name for each of the relevant elements in one of the GROUP1 to GROUP4 fields. You can include each element in a maximum of four modification groups and choose any three-character sequence for the group name. You can also assign elements to a modification group either in the element list or the Layout Editor in the Screen Painter . © Copyright. All rights reserved. 26 Lesson: Modifying Screens at Runtime Dynamic Modification of Attributes – Program Figure 25: Modifying Attributes Dynamically – Program Program your screen modifications in a module that is processed during the PBO processing block. Use a loop through the table SCREEN to change the attributes of an element or a group of elements. LOOP AT SCREEN WHERE . . . and READ TABLE SCREEN are not supported. To activate and deactivate attributes, assign the value 1 (active) or 0 (inactive), and save your changes by using the MODIFY SCREEN statement. Note that the elements that you have defined statically in the Screen Painter as invisible cannot be reactivated using the statement SCREEN-ACTIVE = 1. Instead, use the statement SCREEN-INVISIBLE = 0. However, elements that you have statically defined as visible in the Screen Painter can dynamically be made invisible by using the statement SCREENACTIVE = 0. Using this statement has the same result as the three statements SCREENINVISIBLE = 1, SCREEN-INPUT = 0, and SCREEN-OUTPUT = 0. LESSON SUMMARY You should now be able to: ● Modify screens at runtime © Copyright. All rights reserved. 27 Unit 1 Lesson 5 Designing Screen Sequence LESSON OVERVIEW This lesson explains how to define screen sequences for navigation between screens. Business Example A travel agency needs to maintain the flight booking data for customers by using different screens in an SAP application. These screens should enable you to insert screen sequences and make dynamic screen modifications. For this reason, you require the following knowledge: ● An understanding of screen sequences LESSON OBJECTIVES After completing this lesson, you will be able to: ● Design screen sequences Screen Sequence Figure 26: Determining the Next Screen © Copyright. All rights reserved. 28 Lesson: Designing Screen Sequence For complex transactions, you might need to use multiple screens. You specify the initial screen when you create the transaction code. Each screen leads to the next screen according to user input. The next screen is entered statically in the screen attributes. At runtime, you can temporarily override the static Next screen by using the SET SCREEN statement. Static Screen Sequences Figure 27: Static Screen Sequences You can establish a static sequence of screens by entering a value in the Next screen field of the screen attributes. If you enter 0 or do not enter any value in the field, the system resumes processing from the point at which the screen was initiated after the screen processing is finished. © Copyright. All rights reserved. 29 Unit 1: Introduction to Screen Programming Dynamic Screen Sequence Figure 28: Dynamically Setting the Next Screen The SET SCREEN statement temporarily overwrites the value assigned to the Next screen attribute. The screen must belong to the same program. The next screen is processed either when the current screen processing ends or when you terminate processing by using the LEAVE SCREEN statement. To specify the next screen and leave the current screen in one step, use the LEAVE TO SCREEN statement. Insert Screen Sequences Figure 29: Inserting Screen Sequences © Copyright. All rights reserved. 30 Lesson: Designing Screen Sequence You can insert a screen sequence in a program. Adding a screen sequence adds a layer to a stack. You insert a screen sequence by using the CALL SCREEN statement. Note: Layers created in this way must be removed later by statically or dynamically setting the next screen to the initial value (0) at the end of the inserted screen sequence. Insert a Sequence of Screens Dynamically Figure 30: Dynamically Inserting a Sequence of Screens To interrupt processing of the current screen and branch to a new screen or sequence of screens, use the CALL SCREEN statement. The screen must belong to the same program. In the program, the system constructs a stack. To return to the statement following the CALL SCREEN statement, you can use either the statement SET SCREEN 0, LEAVE SCREEN, or the statement LEAVE TO SCREEN 0. The screen that called the other screen is then processed further. If you use these statements outside a call chain, the program terminates and control returns to the point at which the screen was called. You can also terminate a program by using the ABAP statement LEAVE PROGRAM. © Copyright. All rights reserved. 31 Unit 1: Introduction to Screen Programming Cursor Position on Screens Figure 31: Setting the Cursor Position Dynamically When a system displays a screen, it automatically places the cursor in the first input field. If you want the cursor to always appear in a different field, enter the corresponding element name in the cursor position field of the screen attributes. You can also indicate the field where the cursor should be placed in the Process Before Output (PBO) event. Indicating the field in the PBO event makes your application more flexible. To specify the field in which the cursor should appear in the program, use the following ABAP statement: SET CURSOR FIELD <object_name> OFFSET <position>. <object name> can be a unique name of an input field in capital letters enclosed in single quotation marks or a variable containing the object name. To place the cursor at a certain position within a field, use the OFFSET parameter and specify the required position in <position>. The system places the cursor at the corresponding offset position, counting from the beginning of the field. LESSON SUMMARY You should now be able to: ● Design screen sequences © Copyright. All rights reserved. 32 Unit 1 Lesson 6 Calling a Dialog Box Dynamically LESSON OVERVIEW This lesson explains how to dynamically call dialog boxes. Business Example A travel agency needs to maintain the flight booking data for customers using different screens in an SAP application. These screens can be dialog boxes. For this reason, you require the following knowledge: ● How to call a dialog box during runtime. LESSON OBJECTIVES After completing this lesson, you will be able to: ● Call dialog boxes dynamically Dialog Boxes Figure 32: Dynamically Calling a Dialog Box In the CALL SCREEN statement, you can use the STARTING AT and ENDING AT additions to specify the position and size of the screen that you are calling. You must define the screen in the CALL SCREEN statement as a modal dialog box to comply with the ergonomic standards of an SAP system. © Copyright. All rights reserved. 33 Unit 1: Introduction to Screen Programming If you omit the ENDING AT addition, the size used in the screen attributes determines the size of the dialog box. The size of the dialog box is in the Lines/Columns screen attribute. If you use the ENDING AT addition, the system displays as much of the dialog box as will fit into the available space in the screen. If the space is not enough to show the entire dialog box, the dialog box appears with scrollbars. Window Coordinates Figure 33: Window Coordinates The starting position or origin of every window in an SAP system is its top left corner. Use the following statement to specify the coordinates of a window: CALL SCREEN <nnnn> STARTING AT left_col upper_row ENDING AT right_col lower_row. The values that are used for the left_col, upper_row, right_col , and lower_row variables relate to the SAP screen from which you display the second screen by using the CALL SCREEN statement. For example, the figure displays the position from where screen 101 is displayed in screen 100. LESSON SUMMARY You should now be able to: ● Call dialog boxes dynamically © Copyright. All rights reserved. 34 Unit 1 Learning Assessment 1. The current SAP screen programming model is single-screen transactions. Which of the following characteristics best describes this model? Choose the correct answers. X A The input screen and data screen are combined in one window. X B It is easy to switch between Create, Change, and Display mode. X C The system retains context after saving. X D Program coding using one include program is possible. X E Direct access to the objects is possible. 2. A module pool program requires at least one transaction code in which you specify an initial screen. Determine whether this statement is true or false. X True X False 3. Process After Input (PAI) is processed after a user interaction on the screen. Determine whether this statement is true or false. X True X False 4. Call Module statements can be found in the flow logic of a dialog program. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 35 Unit 1: Learning Assessment 5. Which of the following is the processor that controls the flow logic on a screen? Choose the correct answer. X A ABAP X B DYNP 6. Dynamic changes to the attributes of screen elements can be done using the LOOP AT SCREEN ... ENDLOOP block with a MODIFY SCREEN statement in a PBO module. Determine whether this statement is true or false. X True X False 7. Which of the following is the statement used to insert a screen sequence? Choose the correct answer. X A CALL SCREEN X B SET SCREEN X C NEXT SCREEN 8. Which of the following additions in a CALL SCREEN statement can be omitted and the size of the dialog box will be determined by the size used in its screen attribute? Choose the correct answer. X A ENDING AT X B STARTING AT © Copyright. All rights reserved. 36 Unit 1 Learning Assessment - Answers 1. The current SAP screen programming model is single-screen transactions. Which of the following characteristics best describes this model? Choose the correct answers. X A The input screen and data screen are combined in one window. X B It is easy to switch between Create, Change, and Display mode. X C The system retains context after saving. X D Program coding using one include program is possible. X E Direct access to the objects is possible. You are correct! With single-screen transaction programming, the input screen and data screen are combined in one window. It is easy to switch between Create, Change, and Display mode; the system retains context after saving; and direct access to the objects is possible. Read more in the lesson, Explaining the User Dialog Programming Model, Task: Single-Screen Transaction Model, in the course BC410 (Unit 1, Lesson 1) or TAW10 Part II (Unit 11, Lesson 1). 2. A module pool program requires at least one transaction code in which you specify an initial screen. Determine whether this statement is true or false. X True X False You are correct! A module pool program requires at least one transaction code in which you specify an initial screen. Read more in the lesson, Explaining the User Dialog Programming Model, Task: ABAP Program Types, in the course BC410 (Unit 1, Lesson 1) or TAW10 Part II (Unit 11, Lesson 1). © Copyright. All rights reserved. 37 Unit 1: Learning Assessment - Answers 3. Process After Input (PAI) is processed after a user interaction on the screen. Determine whether this statement is true or false. X True X False You are correct! Process After Input (PAI) is always processed after a user interaction. Read more in the lesson, Introducing Screen Programming, Task: Screens in Dialog Programs, in the course BC410 (Unit 1, Lesson 2) or TAW10 Part II (Unit 11, Lesson 2). 4. Call Module statements can be found in the flow logic of a dialog program. Determine whether this statement is true or false. X True X False You are correct! In the flow logic, you execute modules using the MODULE statement. Modules are modularization units of an ABAP screen program that contain screen logic written in statements. Read more in the lesson, Creating Screens and Screen Elements, Task: Flow Logic of Screens, in the course BC410 (Unit 1, Lesson 3) or TAW10 Part II (Unit 11, Lesson 3). 5. Which of the following is the processor that controls the flow logic on a screen? Choose the correct answer. X A ABAP X B DYNP You are correct! The DYNP processor controls the flow logic and prepares data to be displayed on the screen. Read more in the lesson, Creating Screens and Screen Elements, Task: Data visibility, in the course BC410 (Unit 1, Lesson 3) or TAW10 Part II (Unit 11, Lesson 3). 6. Dynamic changes to the attributes of screen elements can be done using the LOOP AT SCREEN ... ENDLOOP block with a MODIFY SCREEN statement in a PBO module. Determine whether this statement is true or false. X True X False You are correct! Dynamic changes to the attributes of screen elements can be done using the LOOP AT SCREEN ... ENDLOOP block with a MODIFY SCREEN statement in a PBO module. Read more in the lesson, Modifying Screens at Runtime, Task: Initialization of the SCREEN System Table, in the course BC410 (Unit 1, Lesson 4) or TAW10 Part II (Unit 11, Lesson 4). © Copyright. All rights reserved. 38 Unit 1: Learning Assessment - Answers 7. Which of the following is the statement used to insert a screen sequence? Choose the correct answer. X A CALL SCREEN X B SET SCREEN X C NEXT SCREEN You are correct! You insert a screen sequence by using the CALL SCREEN statement. Read more in the lesson, Designing Screen Sequence, Task: Insert Screen Sequences, in the course BC410 (Unit 1, Lesson 5) or TAW10 Part II (Unit 11, Lesson 5). 8. Which of the following additions in a CALL SCREEN statement can be omitted and the size of the dialog box will be determined by the size used in its screen attribute? Choose the correct answer. X A ENDING AT X B STARTING AT You are correct! If you omit the ENDING AT addition, the size used in the screen attribute determines the size of a dialog box. Read more in the lesson, Calling a Dialog Box Dynamically, Task: Dialog Boxes, in the course BC410 (Unit 1, Lesson 6) or TAW10 Part II (Unit 11, Lesson 6). © Copyright. All rights reserved. 39 UNIT 2 The Program Interface Lesson 1 Explaining User Interfaces 41 Lesson 2 Setting a GUI Title and a GUI Status 47 UNIT OBJECTIVES ● Explain user interface ● Explain user interface functions ● Create a GUI title ● Create a GUI status © Copyright. All rights reserved. 40 Unit 2 Lesson 1 Explaining User Interfaces LESSON OVERVIEW This lesson explains the user interface of a program that includes GUI titles and GUI statuses. Business Example A travel agency maintains the flight booking data for its customers by using different screens in an SAP application. You need to create a user interface for these screens that includes a GUI title and GUI status. For this reason, you require the following knowledge: ● How to create a GUI title ● How to identify function keys LESSON OBJECTIVES After completing this lesson, you will be able to: ● Explain user interface ● Explain user interface functions User Interface Overview Figure 34: User Interface Overview The GUI titles and GUI statuses of a program form the program’s user interface. Whenever you add a new title or status, you need to regenerate the user interface. © Copyright. All rights reserved. 41 Unit 2: The Program Interface Title bars are known as GUI titles. You should set an appropriate title for each screen in your application. You can add one or more GUI statuses per screen. For example, you may need to add two statuses for an editor program: one for display mode and the other for change mode. A GUI status consists of the following elements: ● Menu bar Menus allow the user to choose functions to be processed by an application program. Menus can also contain submenus. The System and Help menus, which are available on every screen in the SAP system, contain standardized sets of functions that cannot be changed or hidden. ● Standard toolbar The standard toolbar, which is the same on every screen in the SAP system, contains a set of icons. Each icon is assigned to a corresponding function key and is fixed. If a function in the standard toolbar cannot be used on the current screen, the icon appears grayed out. ● Application toolbar An application toolbar contains icons for frequently used functions. To select a function, choose the corresponding icon on the application toolbar. ● Function key settings Use the function key settings to assign functions such as Find, Replace, or Cut to the function keys. GUI Status – Technical View Figure 35: GUI Status – Technical View From a technical point of view, a status refers to a menu bar, certain key assignments, and an application toolbar. A single component, such as a menu bar, can be used by multiple GUI statuses. GUI statuses are ABAP program objects that can be displayed on screens and lists. Set a GUI status for every screen in your application. © Copyright. All rights reserved. 42 Lesson: Explaining User Interfaces Status – Detail Technical View Figure 36: Status - Detail Technical View A menu bar consists of individual menus. Key assignments and application toolbars are subobjects of the function key settings. To create a set of application toolbars for a single key setting, in the Menu Painter, choose Goto → Interface objects; Function key settings → <name> → Pushbutton settings; User interface → Subobject → Create. Before you can assign a function to a pushbutton, you must assign that function to a function key. Each status contains a single application toolbar. All program menus and key assignments refer to the set of all interface functions (function list). Use F4 help to display these interface functions. The application toolbar refers to the functions indirectly through the standard settings. A function in a status can be either active or inactive. © Copyright. All rights reserved. 43 Unit 2: The Program Interface User Interface Functions Overview Figure 37: Functions Functions are identified by their function codes. The attribute Function Type determines the intended purpose of a function. You can use the function types ’ ’ (space), E, and P. The SAP system reserves the function types S and H for internal use. Function type T indicates a transaction code. When a function type T is triggered, the system leaves the calling program and calls a new program. You can create functions with static or dynamic texts. If a function has a static text, you can assign an icon to it using the Icon Name attribute. If you have already assigned a function to an icon, an icon is displayed instead of the static text. The static text is used when you assign a function to a menu entry. The function text is used as quick info text. When the user chooses the function, the contents of the Info. Text attribute appear in the status bar of the screen. To display the text along with the icon, enter the text in the Icon Text attribute. Use the Fastpath attribute to assign letters as shortcuts to choose a function from the menu bar without using the mouse. A function can be connected to a switch. If the switch is on, you can define a reaction. For further information about functions, refer to in the Help Portal, http://help.sap.com/ nw75, under: Function-Oriented View (Choose your language) → Application Server (on left panel) → Application Server ABAP → Application Development on AS ABAP → ABAP Workbench - Classic → ABAP Workbench Tools → Menu Painter → Basic Concepts → Functions. For further information about switches, refer to ABAP Keyword documentation →ABAP – Release-Specific Changes →Changes for Release 7.0 →Switch Framework for Release 7.0 . © Copyright. All rights reserved. 44 Lesson: Explaining User Interfaces Function Key Settings Figure 38: Function Key Settings You can assign functions to individual function keys or buttons. Function key settings consist of a key assignment and a pushbutton in the application toolbar. The type of function key settings (screen or dialog box) determines the technical purpose of the function key settings. You can set options to implement context menus and the help function on lists. Key assignments consist of reserved function keys, recommended function keys, and freely assigned function keys. Reserved functions keys are function keys whose assigned values cannot be changed in the SAP system. You may activate and deactivate their functions, but you cannot change the icons and texts assigned to them. Reserved function keys appear in the standard toolbar on screens and lists. Recommended function keys contain proposals that comply with the ergonomic standards of the SAP system. You can assign functions to pushbuttons in the application toolbar even if they are already assigned to function keys. An application toolbar can contain up to 35 pushbuttons. Insert vertical separators in the application toolbar to group pushbuttons visually. To control whether inactive functions are displayed in the application toolbar, choose Goto →Attributes →Pushbutton assignment… . © Copyright. All rights reserved. 45 Unit 2: The Program Interface Menus and Menu Bars Figure 39: Menus and Menu Bars A menu can contain up to 15 entries, which can be functions, separators, and cascading menus. Menus can contain up to three levels. The third level only contains functions and separators. Menus can be created with static or dynamic text. To use dynamic text, you must assign a field to the menu. The contents of this field appear as the menu text. You can reference menus from other programs. To do that, go to the Menu bar in your user interface in Menu Painter and choose Edit → Insert → Include menu. You have to specify the name of the program and status from which you want to include the menu. Include menus can be accessed only by using the menu bar. A menu bar can contain up to eight menus. You can freely assign a maximum of six menus to a menu bar. The system adds both the System and Help menus to every menu bar automatically. LESSON SUMMARY You should now be able to: ● Explain user interface ● Explain user interface functions © Copyright. All rights reserved. 46 Unit 2 Lesson 2 Setting a GUI Title and a GUI Status LESSON OVERVIEW This lesson demonstrates how to set a GUI Title and a GUI status. Business Example A travel agency needs to maintain the flight booking data for the customers using screens in an SAP application. Therefore, you need to create a GUI status that refers to a menu bar, certain key assignments, and an application toolbar. You also need a GUI title for each screen. For this reason, you require the following knowledge: ● How to create a GUI title ● How to create a GUI status ● How to process the function code LESSON OBJECTIVES After completing this lesson, you will be able to: ● Create a GUI title ● Create a GUI status © Copyright. All rights reserved. 47 Unit 2: The Program Interface GUI Title Figure 40: GUI Title The GUI title is a part of program’s user interface. You can create a GUI title through the following methods: ● The object list in Object Navigator ● The Menu Painter ● Forward navigation from ABAP Editor Set an appropriate GUI title for each screen in your application. To display values in a title bar dynamically, you can use variables in titles by including the ampersand character (&) as a placeholder. At runtime, the ampersand is replaced by a value that you specify in the program. You can use up to nine placeholders. To set a title that contains variables, use the statement: SET TITLEBAR WITH <&1> ... <&9>. A title bar remains in place until you set another one. At runtime, the system variable SYTITLE contains the current title. To Set the GUI Title 1. Double-click on the title name given in the SET TITLEBAR statement in the module. A confirmation message box appears. © Copyright. All rights reserved. 48 Lesson: Setting a GUI Title and a GUI Status 2. In the confirmation message box, choose Yes . 3. In the Create Title dialog box, enter a title name in the Title field. The title name can be up to 20 characters long. Choose OK. 4. Activate the module. The GUI title activates along with the module. GUI Status Creation Figure 41: GUI Status Creation The status type indicates the technical attributes of the GUI status. You can choose between a GUI status for a normal screen (full screen), dialog box (for use with modal dialog boxes), and context menu. Context menus are special collections of functions that display when you right-click on the screen. You can create a GUI status that links to the existing components or create a completely new GUI status. You can also combine the two techniques. For the completely new GUI status, you need to create your own menu bars, menu functions, and other elements. Changes that you make to one GUI status do not affect any other GUI statuses. When you use the reference technique to create GUI statuses, you reuse menu bars, application toolbars, and function key assignments. You can create your own GUI status and refer it to any existing menu bar, application toolbar, and any function key assignment. The Menu Painter stores and maintains these references so that any changes in the menu bar, application toolbar, or function key assignments automatically take effect in all GUI statuses referring to them. To ensure that the user can access functions in the same way regardless of the GUI status set, use the reference technique to establish consistency in the large applications that use several GUI statuses. © Copyright. All rights reserved. 49 Unit 2: The Program Interface Creation of a GUI Status - Function Key Assignment Figure 42: Creating a GUI Status – Function Key Assignment In function key settings, you assign individual functions to function keys and pushbuttons. Function key settings consist of a key assignment and a set of application toolbars. The types of key settings are as follows: ● Screen ● Dialog box ● List ● List in a dialog box When you attach functions to reserved, recommended, and freely assigned function keys, ensure that they conform to the ergonomic standards of the SAP system. You can find these ergonomic standards in the Environment menu in the Menu Painter. Reserved function keys appear in the standard toolbar of SAP GUI. If a function that you already assigned to a function key is important to the application, assign it to a pushbutton in the application toolbar. The application toolbar can contain up to 35 pushbuttons. © Copyright. All rights reserved. 50 Lesson: Setting a GUI Title and a GUI Status Standard Toolbar – Automatic Assignments Figure 43: Standard Toolbar – Automatic Assignments When you assign a function to the standard toolbar, the function is automatically assigned to a reserved function key. To see the function keys that are assigned in the current GUI status, select Information in the Menu Painter. Creation of a GUI Status - Application Toolbar Figure 44: Creating a GUI Status – Application Toolbar To use a function in the application toolbar, you must first assign it to a function key. To select functions, use the F4 help. © Copyright. All rights reserved. 51 Unit 2: The Program Interface If you assign an icon to a function with a static text, the system displays the icon instead of the static text in the application toolbar. The function text belonging to the function is used as the quick info text or tooltip. When the user chooses the function, the contents of the Info. text attribute appear in the status bar of the screen. To display additional text with an icon, enter the additional text in the Icon text attribute. To insert a separator in the application toolbar, use the Edit → Insert menu in the Menu Painter. Creation of a GUI Status – Menu Bar Figure 45: Creating a GUI Status – Menu Bar A menu entry can be a function, a separator, another menu, or a cascading menu. To add a function to a menu, enter its function code in the left-hand column. If the function already exists in the function list and has a text assigned to it, its function code is entered automatically in the text field. If it is not entered automatically, double-click the right-hand field to enter text. To insert a separator, use either the Edit → Insert or context menu, or fill the function text field with minus signs at the appropriate position. To create a submenu, enter its name in the right field of the menu entry. © Copyright. All rights reserved. 52 Lesson: Setting a GUI Title and a GUI Status Display of Standards Figure 46: Displaying Standards To establish consistency throughout the screens, you create and reuse existing menu bars, application toolbars, and key settings, wherever possible. The Menu Painter administers the links you establish between these objects so that any changes apply to all other GUI statuses that use them. You can also use a set of standard menu entries as a template and adapt the settings accordingly. When you assign functions to the reserved function keys in the standard toolbar, adhere to the ergonomic standards of the SAP system. If you adhere to these standards, your program is easier for users to understand and for you to maintain. © Copyright. All rights reserved. 53 Unit 2: The Program Interface Inclusion of Existing Elements Figure 47: Including Existing Elements Using the Menu Painter in a GUI status, you can include key settings, application toolbars, or menu bars that you had defined elsewhere. If you use the Menu Painter, work from the bottom up. If there is more than one application toolbar defined for your key setting, choose the appropriate toolbar. All functions are inactive initially. Activate only those functions that are relevant to the current GUI status. © Copyright. All rights reserved. 54 Lesson: Setting a GUI Title and a GUI Status GUI Status Function Code Processing Figure 48: Processing the Function Code When the user triggers a function with type ’ ’ (space) using a pushbutton, menu entry, or function key, the system places the relevant function code in the OK field of the screen. To process this field in the Process After Input (PAI) event, you must assign a name to the OK field. Usually the field is named OK_CODE. You enter the name in the element list in the Screen Painter. You must create a field in your ABAP program with the same name. During the automatic field transport at the beginning of the PAI event, the function code is passed from the screen to the corresponding field in the program. You then need to implement the logic in a PAI module to evaluate the value in the OK_CODE field and decide the appropriate actions. Typically, the PAI module USER_COMMAND_XXX is used. To prevent the function code from causing unexpected processing steps on the next screen (pressing ENTER does not usually change the command field), you must initialize the identically named ABAP field. Write a Process Before Output (PBO) module with the following line (provided you have named the user command field OK_CODE in the element list): CLEAR OK_CODE LESSON SUMMARY You should now be able to: ● Create a GUI title ● Create a GUI status © Copyright. All rights reserved. 55 Unit 2 Learning Assessment 1. Which of the following make up a GUI status? Choose the correct answers. X A Menu bar X B Standard toolbar X C Application toolbar X D Title bar X E Function key settings 2. You can create functions only with dynamic texts. Determine whether this statement is true or false. X True X False 3. Which of the following types of keys can be found in the function key assignments. Choose the correct answers. X A Reserved function keys X B Recommended function keys X C Fastpath keys X D Freely assigned function keys 4. You can use variables in GUI titles which are set dynamically at runtime by including the "&" symbol. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 56 Unit 2: Learning Assessment 5. Menu bars and application toolbars are independent elements within a program. You can reuse them from a GUI status with which of the following? Choose the correct answer. X A reference technique X B technical attributes X C status bars 6. When the user triggers a function using a button, the relevant function code is transferred into the OK field of the screen. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 57 Unit 2 Learning Assessment - Answers 1. Which of the following make up a GUI status? Choose the correct answers. X A Menu bar X B Standard toolbar X C Application toolbar X D Title bar X E Function key settings You are correct! A menu bar, a standard toolbar, an application toolbar and the function key settings make up a GUI status. Read more in the lesson, Explaining User Interfaces, Task: User Interface Overview, in the course BC410 (Unit 2, Lesson 1) or TAW10 Part II (Unit 12, Lesson 1). 2. You can create functions only with dynamic texts. Determine whether this statement is true or false. X True X False You are correct! Functions can be created with static or dynamic texts. Read more in the lesson, Explaining User Interfaces, Task: User Interface Functions Overview, in the course BC410 (Unit 2, Lesson 1) or TAW10 Part II (Unit 12, Lesson 1). © Copyright. All rights reserved. 58 Unit 2: Learning Assessment - Answers 3. Which of the following types of keys can be found in the function key assignments. Choose the correct answers. X A Reserved function keys X B Recommended function keys X C Fastpath keys X D Freely assigned function keys You are correct! The reserved function keys, recommended function keys, and freely assigned function keys are found in the function key assignments. Read more in the lesson, Explaining User Interfaces, Task: Function Key Settings, in the course BC410 (Unit 2, Lesson 1) or TAW10 Part II (Unit 12, Lesson 1). 4. You can use variables in GUI titles which are set dynamically at runtime by including the "&" symbol. Determine whether this statement is true or false. X True X False You are correct! You can use variables in GUI titles which are set dynamically at runtime by including the "&" symbol. Read more in the lesson, Setting a GUI Title and a GUI Status, Task: GUI Title, in the course BC410 (Unit 2, Lesson 2) or TAW10 Part II (Unit 12, Lesson 2). 5. Menu bars and application toolbars are independent elements within a program. You can reuse them from a GUI status with which of the following? Choose the correct answer. X A reference technique X B technical attributes X C status bars You are correct! Menu bars and application toolbars are independent elements within a program. You can reuse them from a GUI status with reference technique. Read more in the lesson, Setting a GUI Title and a GUI Status, Task: GUI Status Creation, in the course BC410 (Unit 2, Lesson 2) or TAW10 Part II (Unit 12, Lesson 2). © Copyright. All rights reserved. 59 Unit 2: Learning Assessment - Answers 6. When the user triggers a function using a button, the relevant function code is transferred into the OK field of the screen. Determine whether this statement is true or false. X True X False You are correct! When the user triggers a function using a button, the relevant function code is transferred into the OK field of the screen. Read more in the lesson, Setting a GUI Title and a GUI Status, Task: GUI Status Function Code Processing, in the course BC410 (Unit 2, Lesson 2) or TAW10 Part II (Unit 12, Lesson 2). © Copyright. All rights reserved. 60 UNIT 3 Simple Screen Elements Lesson 1 Creating Screen Elements for Output 62 Lesson 2 Creating Input/Output Fields 70 Lesson 3 Defining Checkboxes and Radio Button Groups 74 Lesson 4 Creating Pushbuttons 79 UNIT OBJECTIVES ● Define text fields ● Define status icons ● Define group boxes ● Define input/output fields ● Define dropdown boxes for input/output ● Define checkboxes ● Define buttons ● Define pushbuttons © Copyright. All rights reserved. 61 Unit 3 Lesson 1 Creating Screen Elements for Output LESSON OVERVIEW This lesson explains how to create and use text fields, status icons, and group boxes. Business Example A travel agency needs to maintain the flight booking data for the customers using different screens in an SAP application. On a screen, labels such as flight number or booking number need to be displayed in front of the corresponding fields. For this reason, you require the following knowledge: ● How to create text fields, status icons, and group boxes LESSON OBJECTIVES After completing this lesson, you will be able to: ● Define text fields ● Define status icons ● Define group boxes Text Fields Figure 49: Text Fields 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 are sometimes called keywords, and are for display. The user cannot change these labels at runtime. Text fields are displayed in a fixed position on the screen. © Copyright. All rights reserved. 62 Lesson: Creating Screen Elements for Output Text Field – Attributes Figure 50: Text Field – Attributes Text fields can also contain lines, icons, and other static elements. They can contain any alphanumeric characters, but cannot begin with an underscore (_). If you use text to label a radio button or checkbox, you can specify whether the label is to the left or right of the radio button or checkbox. If your text consists of more than one word, use underscore characters as separators. By using separators, the system recognizes that different words belong to a single text. You can translate text fields so that they appear in the user’s logon language. To do this, choose Goto → Translation in the Screen Painter. © Copyright. All rights reserved. 63 Unit 3: Simple Screen Elements Creation of Text Fields Figure 51: Creation of Text Fields You can create text fields in either of the following ways: ● Place a text field object in the work area and directly enter the text in the Text attribute field in the Layout Editor. ● Use fields from ABAP Dictionary structures to bring in the data element and its corresponding text for the input/output fields on the screen. Status Icons Figure 52: Status Icons © Copyright. All rights reserved. 64 Lesson: Creating Screen Elements for Output Status icons are special output fields that display icons. A status icon is a placeholder, which is set dynamically at runtime. Icons can be used to indicate a status in your application. The status icons are predefined in the system and have two to four characters. For information about the available icons, call report SHOWICON. Status Icons – Attributes Figure 53: Status Icons – Attributes The system sets the status icon as Output field and 2D Display in the attributes and cannot be changed. The default data format is CHAR. However, you can change the Vis. length, Bright, and Invisible attributes of a status icon dynamically. © Copyright. All rights reserved. 65 Unit 3: Simple Screen Elements Creation of Status Icons Figure 54: Creating Status Icons Status icon fields are defined in the graphical layout editor. A status icon field is an output field with an icon. It is used to display icons, which are specified dynamically at runtime. To ensure that you can display a long quick info text, define the field with a defined length of 132 and visible length 2. In the ABAP program, you can define a field with the same name as in the screen icon field using the Text field from the ABAP Dictionary structure ICONS. At runtime, this field contains the name of the icon you want to display. At runtime you can assign the required icon to this field using the ICON_CREATE function module. © Copyright. All rights reserved. 66 Lesson: Creating Screen Elements for Output Filling of a Status Icon Figure 55: Filling a Status Icon To fill a status icon, you need to find the technical name of the icon. You then call a module in the Process Before Output (PBO) event to create the icon by using the ICON_CREATE function module. You must pass the name of the icon you want to display as well as the icon’s display text to the function module. The function module returns the technical value of the status icon field. For further details about this function module, refer to its documentation. Group Boxes Figure 56: Group Boxes © Copyright. All rights reserved. 67 Unit 3: Simple Screen Elements Group boxes enclose a selection of elements that belong together, for example, a group of fields or a radio button group. These are display elements that help the user identify which elements on the screen belong together in a group. You can use group boxes to make sure that all fields in a box have the same context menu assigned to them. Group boxes can also have a title. Group Boxes – Attributes Figure 57: Group Boxes – Attributes You can change the Vis. length and Invisible attributes using the system table SCREEN. A group box can also contain other screen elements. At runtime, if the box contains only invisible elements and the screen attribute Runtime compression is selected, the box is not displayed. Creation of Group Boxes Figure 58: Creating Group Boxes You can define group boxes in the Layout Editor. The group box must have a name and may also have a heading. You can change the group box text dynamically. To do this, you need to activate the Output attribute and create a global data field in the ABAP program with the same name. Because the Screen Painter and the program fields have the same names, any changes to the field © Copyright. All rights reserved. 68 Lesson: Creating Screen Elements for Output contents are immediately visible on the screen, similar to the behavior of the input/output fields. LESSON SUMMARY You should now be able to: ● Define text fields ● Define status icons ● Define group boxes © Copyright. All rights reserved. 69 Unit 3 Lesson 2 Creating Input/Output Fields LESSON OVERVIEW This lesson describes input/output fields and how to create them. It also explains how to help the user with input by using dropdown list boxes that contain possible entries. Business Example A travel agency needs to maintain the flight booking data for the customers using different screens in an SAP application. The application must accept inputs from the user, display the data, and create input and output elements. For this reason, you require the following knowledge: ● How to create input/output fields ● How to create a dropdown box for an input field LESSON OBJECTIVES After completing this lesson, you will be able to: ● Define input/output fields ● Define dropdown boxes for input/output Input/Output Fields Figure 59: Input/Output Fields © Copyright. All rights reserved. 70 Lesson: Creating Input/Output Fields An input field is a rectangular screen element where users enter data. An output field is a rectangular screen element where the system displays text or other data. Input/output fields are also known as templates. Input fields may have the following checks: ● Automatic field input checks Automatic field input checks relate to their data type. For example, date fields allow you to enter a valid date only. ● Data consistency checks Input fields that you create with reference to ABAP Dictionary fields may have built-in data consistency checks, foreign key checks, and value sets. ● Input helps Input fields may have possible value help. Input/Output Field Attributes Figure 60: Input/Output Field Attributes You can temporarily change the object attributes marked in gray by using the system table SCREEN. It may not be possible to activate all possible combinations of attributes. This activation depends on the format of the input/output field. For example, you cannot activate the Leading zeros attribute for a field with the data format CHAR because it is only relevant for numeric fields. © Copyright. All rights reserved. 71 Unit 3: Simple Screen Elements Creation of Input/Output Fields Figure 61: Creating Input/Output Fields You can create input/output fields in the following ways: ● By entering them directly in the Layout Editor The number of underscore characters in the object text attribute determines the size of the field. 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, which is a placeholder for a plus or minus sign. ● By using a template from the ABAP Dictionary Choose the Dictionary/Program fields window. 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. © Copyright. All rights reserved. 72 Lesson: Creating Input/Output Fields Dropdown Boxes Figure 62: Dropdown Boxes Dropdown boxes allow the user to choose an entry from a pull-down list containing possible entries. The user cannot enter values freely, but must choose a value from the list. Perform the following actions in Screen Painter to create a dropdown box for an input field: ● Set the Dropdown attribute to List box or Listbox with key. ● Change the Vis. Length attribute to the displayed length of the descriptive text. ● Set the Value list attribute to ’ ’ (space) to use value help from the ABAP Dictionary. The Listbox with key attribute enforces the display of the key and the text, while List box lets each user decide whether to display the key. If required, set the function code for selection. Similar to a menu entry, this function code triggers the Process After Input (PAI) event. You can interpret the function code using the OK_CODE field. Note that the visible length of the field determines the width of the field including the dropdown button, and the selection list. You must change the width of the field when converting to a dropdown box. The values are filled automatically using the search help assigned to the ABAP Dictionary field. The ABAP Dictionary field must have a search help, a check table with two columns, or a table of fixed values. LESSON SUMMARY You should now be able to: ● Define input/output fields ● Define dropdown boxes for input/output © Copyright. All rights reserved. 73 Unit 3 Lesson 3 Defining Checkboxes and Radio Button Groups LESSON OVERVIEW This lesson explains how to create, use, and change the attributes of checkboxes and radio button groups. It also describes how to assign a function code to a radio button after defining a radio button group. Business Example A travel agency needs to maintain the flight booking data for customers using different screens in an SAP application. The application must enable users to interact with the program, and create checkboxes and radio button groups as screen elements. For this reason, you require the following knowledge: ● How to create checkboxes in your program ● How to create radio button groups LESSON OBJECTIVES After completing this lesson, you will be able to: ● Define checkboxes ● Define buttons Checkboxes and Radio Button Groups Figure 63: Checkboxes and Radio Button Groups Radio buttons allow a user to choose only a single element from a group of fields. Checkboxes allow the user to choose one or more elements from a group of fields. With radio buttons, one selection deselects all other options in the group. © Copyright. All rights reserved. 74 Lesson: Defining Checkboxes and Radio Button Groups Radio Buttons and Checkboxes – Attributes Figure 64: Radio Buttons and Checkboxes – Attributes You must attach a name to checkboxes and radio buttons. In addition to the input/output field, you can display text and icons for them. The text is contained in the Text field in the attributes. To display an icon, enter its name in the Icon name attribute. A quick info for the icon then appears in the appropriate field. You can change the Input and Invisible attributes dynamically by using the system table SCREEN. © Copyright. All rights reserved. 75 Unit 3: Simple Screen Elements Creation of a Checkbox Figure 65: Creating a Checkbox Checkboxes are created in the Layout Editor of the Screen Painter. To do this, choose the checkbox object from the object list, place it on the screen, and assign a name to each checkbox. In the ABAP program, create a field with the same name of type C and length 1. You can find out whether a user has selected a checkbox in the ABAP program by looking in the field contents. If a checkbox is not selected, its field value remains initial (default or previous value). You can assign a function code and a function type to a checkbox. When the user selects the checkbox, the Process After Input (PAI) event is triggered and the function code is placed in the command field, that is, the OK_CODE field. © Copyright. All rights reserved. 76 Lesson: Defining Checkboxes and Radio Button Groups Radio Buttons and Groups Figure 66: Creating a Radio Button Group To create radio buttons in the Layout Editor of the Screen Painter, perform the following steps: 1. Create the radio buttons as individual elements. Choose Radio button from the object list, place it on the screen, and assign it a name. In the ABAP program, create a field with the same name, type C, and a length of 1. To make your programs easier to read and maintain, create a structure associated with each radio button group. 2. Combine a collection of radio buttons into a radio button group. 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 chose by looking in the field contents in the ABAP program. If a radio button is not selected, the field value remains initial. Assign a function code and function type to a radio button group. When the user selects one of the radio buttons, the Process After Input (PAI) event is triggered and the function code is placed in the command field (OK_CODE). © Copyright. All rights reserved. 77 Unit 3: Simple Screen Elements Program Flow for Radio Buttons and Checkboxes Figure 67: Program Flow for Radio Buttons and Checkboxes You can assign a function code to a radio button after you have defined a radio button group; the system will assign the same function code to all radio buttons in the group. LESSON SUMMARY You should now be able to: ● Define checkboxes ● Define buttons © Copyright. All rights reserved. 78 Unit 3 Lesson 4 Creating Pushbuttons LESSON OVERVIEW This lesson explains how to create, use, change, and process pushbuttons. Business Example A travel agency needs to maintain the flight booking data for the customers using different screens in an SAP application. The application must enable users to interact with the program and create pushbuttons as screen elements. For this reason, you require the following knowledge: ● How to define pushbuttons LESSON OBJECTIVES After completing this lesson, you will be able to: ● Define pushbuttons Pushbuttons Figure 68: Pushbuttons Pushbuttons are input fields for the command field OK_CODE. Using the mouse, users can quickly access functions that relate to individual screen elements or groups of screen elements. © Copyright. All rights reserved. 79 Unit 3: Simple Screen Elements Use pushbuttons in the data area of your screen to show or hide further information. If a pushbutton relates to a single field or a small group of fields, make sure that the pushbutton is as close to them as possible. If the function relates to a group, make this clear by using a group box. If pushbuttons relate to a table displayed on the screen, place them underneath the table in a horizontal row, close together, with a blank line between them and the table. When the user chooses a pushbutton, the system tells the program which function is chosen. At this point, control of the program passes back to a work process on the application server, which processes the Process After Input (PAI) processing block. Pushbuttons – Attributes Figure 69: Pushbuttons – Attributes Pushbuttons may contain text (the Text attribute) or an icon, or both. You can specify an icon either statically or dynamically by using the function module ICON_CREATE. You can change the Vis. length, Output field, and Invisible attributes dynamically by using the system table SCREEN. To change the text on a pushbutton dynamically, perform the following steps: 1. Set the Output field attribute in the Screen Painter field to Active. 2. Create a global field with the same name in your ABAP program. Because the Screen Painter and the program fields have the same names, any changes to the field contents are immediately visible on the screen. © Copyright. All rights reserved. 80 Lesson: Creating Pushbuttons Creating and Processing Pushbuttons Figure 70: Creating and Processing Pushbuttons To create a pushbutton, perform the following tasks: ● Create a pushbutton Choose the pushbutton object from the element list of the Screen Painter, place it on the screen, and assign a name to it. You can enter a static text in the Text attribute. Enter a function code for the pushbutton in the Function code attribute. This function code is placed in the OK_CODE field automatically when the user chooses the pushbutton on the screen. ● Activate the command field OK_CODE You must give the field a name in the element list of the Screen Painter, and declare an identically named field in the ABAP program with reference to the system field SY-UCOMM. When a 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 appropriately coded processing block. If the user chooses a pushbutton that has the function type ’ ’ (space), the PAI event is processed. If the user chooses a pushbutton that has the function type E, the system processes a module with the AT EXIT-COMMAND addition. This happens before the automatic field transport and the field input checks. The system places the function code that was triggered into the OK_CODE field, which you can then query in the module. After the AT EXIT-COMMAND addition, the system continues processing the screen normally and then executes field input checks followed by PAI processing. © Copyright. All rights reserved. 81 Unit 3: Simple Screen Elements LESSON SUMMARY You should now be able to: ● Define pushbuttons © Copyright. All rights reserved. 82 Unit 3 Learning Assessment 1. The user can change the labels in text fields at runtime. Determine whether this statement is true or false. X True X False 2. Underscores are interpreted as separators between two words of the same text field. Determine whether this statement is true or false. X True X False 3. Which of the following are the system set attributes for the status icon, attributes that cannot be changed? Choose the correct answers. X A Invisible X B Output field X C Intensified X D 2 Dimensional 4. To change the group box text dynamically, which of the following steps are required? Choose the correct answers. X A Select the Output field attribute of the group box. X B Use text elements. X C Create a global data field in the ABAP program with the same name and assign a value to this global data field. X D Use an '&' in the group box text attribute and assign the text during runtime using a function module. © Copyright. All rights reserved. 83 Unit 3: Learning Assessment 5. Automatic field input checks in an input field are related to their data type. Determine whether this statement is true or false. X True X False 6. The user can enter values freely in dropdown boxes. Determine whether this statement is true or false. X True X False 7. Which of the following, when selected, automatically deselects all other options in the group? Choose the correct answer. X A Checkbox X B Radio button 8. When you assign a function code to a radio button group, the system then assigns the same function code to all the radio buttons in that group. Determine whether this statement is true or false. X True X False 9. When a user chooses a pushbutton, the system can tell which function is chosen by checking the OK_CODE field. Determine whether this statement is true or false. X True X False 10. You can specify an icon for the pushbutton either statically, or dynamically using the function module ICON_CREATE. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 84 Unit 3 Learning Assessment - Answers 1. The user can change the labels in text fields at runtime. Determine whether this statement is true or false. X True X False You are correct! The user cannot change the labels in text fields at runtime. Read more in the lesson, Creating Screen Elements for Output, Task: Text Fields, in the course BC410 (Unit 3, Lesson 1) or TAW10 Part II (Unit 13, Lesson 1). 2. Underscores are interpreted as separators between two words of the same text field. Determine whether this statement is true or false. X True X False You are correct! If your text consists of more than one word, use underscore characters as separators. By using separators, the system recognizes that different words belong to a single text. Read more in the lesson, Creating Screen Elements for Output, Task: Text Field – Attributes, in the course BC410 (Unit 3, Lesson 1) or TAW10 Part II (Unit 13, Lesson 1). 3. Which of the following are the system set attributes for the status icon, attributes that cannot be changed? Choose the correct answers. X A Invisible X B Output field X C Intensified X D 2 Dimensional You are correct! The system sets the status icon as Output field and 2D Display in the attributes and cannot be changed. Read more in the lesson, Creating Screen Elements for Output, Task: Status Icons – Attributes, in the course BC410 (Unit 3, Lesson 1) or TAW10 Part II (Unit 13, Lesson 1). © Copyright. All rights reserved. 85 Unit 3: Learning Assessment - Answers 4. To change the group box text dynamically, which of the following steps are required? Choose the correct answers. X A Select the Output field attribute of the group box. X B Use text elements. X C Create a global data field in the ABAP program with the same name and assign a value to this global data field. X D Use an '&' in the group box text attribute and assign the text during runtime using a function module. You are correct! To change the group box text dynamically, you need to activate the Output attribute of the group box and create a global data field in the ABAP program with the same name. Read more in the lesson, Creating Screen Elements for Output, Task: Creation of Group Boxes, in the course BC410 (Unit 3, Lesson 1) or TAW10 Part II (Unit 13, Lesson 1). 5. Automatic field input checks in an input field are related to their data type. Determine whether this statement is true or false. X True X False You are correct! Automatic field input checks in an input field are related to their data type. For example, date fields allow you to enter a valid date only. Read more in the lesson, Creating Input/Output Fields, Task: Input/Output Fields, in the course BC410 (Unit 3, Lesson 2) or TAW10 Part II (Unit 13, Lesson 2). 6. The user can enter values freely in dropdown boxes. Determine whether this statement is true or false. X True X False You are correct! Dropdown boxes allow the user to choose an entry from a pull-down list containing possible entries. The user cannot enter values freely in dropdown boxes, but must choose a value from a pull-down list. Read more in the lesson, Creating Input/Output Fields, Task: Dropdown Boxes, in the course BC410 (Unit 3, Lesson 2) or TAW10 Part II (Unit 13, Lesson 2). © Copyright. All rights reserved. 86 Unit 3: Learning Assessment - Answers 7. Which of the following, when selected, automatically deselects all other options in the group? Choose the correct answer. X A Checkbox X B Radio button You are correct! Radio buttons allow a user to choose only a single element from a group of fields. With radio buttons, one selection deselects all other options in the group. Read more in the lesson, Defining Checkboxes and Radio Button Groups, Task: Checkboxes and Radio Button Groups, in the course BC410 (Unit 3, Lesson 3) or TAW10 Part II (Unit 13, Lesson 3). 8. When you assign a function code to a radio button group, the system then assigns the same function code to all the radio buttons in that group. Determine whether this statement is true or false. X True X False You are correct! You can assign a function code to a radio button after you have defined a radio button group; the system will assign the same function code to all radio buttons in the group. Read more in the lesson, Defining Checkboxes and Radio Button Groups, Task: Program Flow for Radio Buttons and Checkboxes, in the course BC410 (Unit 3, Lesson 3) or TAW10 Part II (Unit 13, Lesson 3). 9. When a user chooses a pushbutton, the system can tell which function is chosen by checking the OK_CODE field. Determine whether this statement is true or false. X True X False You are correct! When a 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 appropriately coded processing block. Read more in the lesson, Creating Pushbuttons, Task: Creating and Processing Pushbuttons, in the course BC410 (Unit 3, Lesson 4) or TAW10 Part II (Unit 13, Lesson 4). © Copyright. All rights reserved. 87 Unit 3: Learning Assessment - Answers 10. You can specify an icon for the pushbutton either statically, or dynamically using the function module ICON_CREATE. Determine whether this statement is true or false. X True X False You are correct! You can specify an icon either statically or dynamically by using the function module ICON_CREATE. Read more in the lesson, Creating Pushbuttons, Task: Pushbuttons – Attributes, in the course BC410 (Unit 3, Lesson 4) or TAW10 Part II (Unit 13, Lesson 4). © Copyright. All rights reserved. 88 UNIT 4 Screen Error Handling Lesson 1 Handling Errors Using Dialog Messages and Field Input Checks 90 Lesson 2 Handling Errors Using Navigation and Input Help 101 UNIT OBJECTIVES ● Send dialog messages ● Check field values ● Implement field input checks ● Navigate between screens ● Check inputs by using input help © Copyright. All rights reserved. 89 Unit 4 Lesson 1 Handling Errors Using Dialog Messages and Field Input Checks LESSON OVERVIEW This lesson explains how to handle errors by using dialog messages and field input checks. Business Example A travel agency must perform checks to identify errors in the flight booking data of customers. For this reason, you require the following knowledge: ● An understanding of error handling in input/output fields ● An understanding of dialog messages LESSON OBJECTIVES After completing this lesson, you will be able to: ● Send dialog messages ● Check field values ● Implement field input checks SET and GET Parameter Figure 71: Default Values in SAP Memory © Copyright. All rights reserved. 90 Lesson: Handling Errors Using Dialog Messages and Field Input Checks You can save the values of the input/output fields in the SAP memory using a parameter ID. These values are user-session specific, but are available to all internal and external sessions. The SET parameter copies the input/output field contents into the SAP memory in the Process After Input (PAI) processing block. The GET parameter copies the corresponding field contents from the SAP memory at the end of the Process Before Output (PBO) processing block. Definition of SET and GET Parameter Attributes Figure 72: Defining SET and GET Parameter Attributes In the ABAP Dictionary, you can link an input/output field to an area of the SAP memory. When you use an input/output field defined in the ABAP Dictionary, its parameter ID is displayed in the Parameter ID attribute in the Screen Painter. SET and GET parameter attributes, SPA and GPA in the table allow you to enable the SET and GET parameter functions separately. You can define parameter IDs in the ABAP Workbench. © Copyright. All rights reserved. 91 Unit 4: Screen Error Handling Dialog Messages Figure 73: Dialog Message Categories Dialog messages are divided in six categories: A, X, E, W, I, and S. The following table describes each dialog message category: Table 7: Dialog Message Categories Cat Categ egor ory y Text Description A Termination The processing terminates, and the user must restart the transaction. X Exit The processing terminates with short dump MESSAGE_TYPE_X, and the user must restart the transaction. E Error The processing interrupts, and the user must correct the entry. W Warning The processing interrupts, and the user may correct the entries. I Information The processing interrupts, but the user can continue by confirming the message choosing Enter. S Success Information displays on the status bar of the output screen. © Copyright. All rights reserved. 92 Lesson: Handling Errors Using Dialog Messages and Field Input Checks Field Input Checks Figure 74: Automatic Field Input Checks Before processing the PAI modules, the system automatically implements field input checks to check the values that a user enters. The mandatory fields check is the first check to take place and is used to ensure that all required fields are filled. The system can perform a foreign key check only if a screen field refers back to an ABAP Dictionary field for which a check table is defined. The foreign key check attribute must also be set for the check to be performed. During a fixed values check, the help function is active. The system displays all possible entries from which the user can choose. Field Input Checks with Error Dialog Figure 75: Field Input Checks with Error Dialog © Copyright. All rights reserved. 93 Unit 4: Screen Error Handling If the automatic field input checks are insufficient for your requirements, you can program your own checks in the PAI event. To do this, use the FIELD statement with the MODULE addition. The module you specify is processed only for the field that you specify in the FIELD statement. If an error or warning message occurs during the processing of the module, the system throws back the same screen, but without processing the PBO module. When the message is displayed, only the field to which the check was applied is ready for input. Note: The FIELD statement ensures that the field is ready for input. If you use a message in a module that is not called from a FIELD statement, the system displays the message, but does not make the field ready for input again. Check on Groups of Fields Figure 76: Checking Groups of Fields To ensure that more than one field is ready for input following an error dialog, list the relevant fields in the FIELD statement and include the fields and the MODULE statement in a CHAIN ... ENDCHAIN block. You can include individual fields in multiple CHAIN ... ENDCHAIN blocks. Note: Field contents changed during the current PAI processing are visible only if the field in question is also included in the FIELD statement of the current CHAIN block. © Copyright. All rights reserved. 94 Lesson: Handling Errors Using Dialog Messages and Field Input Checks Controlling of Error Dialogs Figure 77: Controlling Error Dialogs If the application sends an error or warning message, the current screen is displayed back to the user, but the PBO module is not processed again. Only the fields to which the module is assigned are ready for input again. After the user enters new values, the PAI module is not completely reprocessed. It is restarted somewhere within the processing block. The system identifies the field that the user has changed and resumes processing at the first corresponding FIELD statement. If the user confirms a warning message without changing the content of the field, the system restarts the PAI processing after the MESSAGE statement where the error was triggered. © Copyright. All rights reserved. 95 Unit 4: Screen Error Handling FIELD Statement Figure 78: FIELD Statement and Data Transport The system transports data from screen fields to ABAP fields with the same name as in the PAI processing block. The system first transports all fields not contained in any FIELD statements. Then, it transports the remaining fields when processing 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 block are automatically transported back to their corresponding screen fields. Conditional Module Calls The following questions regarding checks must be addressed: ● How can I avoid unnecessary field checks? ● How can I leave the screen without any automatic field checks? ● How can I avoid data loss when the user navigates? ● How can I embed checks that are only executed when a switch is on? Field input checks ordinarily require database access. Avoiding these checks where possible improves the performance of your program. If the user remains on a screen, he or she is usually unable to make a consistent set of entries that satisfy the input checks. Therefore, you must enable the user to leave a screen without processing the field checks. © Copyright. All rights reserved. 96 Lesson: Handling Errors Using Dialog Messages and Field Input Checks To protect users from losing entered data if they leave the screen unintentionally, the program security prompts for a confirmation to leave the screen. Execution When Value is not Initial Figure 79: Execution When Value is not Initial When using the ON INPUT addition in a MODULE statement after a FIELD statement, the system calls a module only if the field contents have changed from their initial value. In a CHAIN block, you use the ON CHAIN-INPUT addition. The module is then called if the contents of at least one screen field in the CHAIN block have changed from their initial value. You can use the ON INPUT addition only if a FIELD statement contains the MODULE statement. © Copyright. All rights reserved. 97 Unit 4: Screen Error Handling Execution on Change Figure 80: Execution on Change If you use the ON REQUEST addition in a MODULE statement after a FIELD statement, the module is called only if the user enters a new value in that field. In a CHAIN block, you use the ON CHAIN-REQUEST addition. The module is then called if the user changes the contents of at least one screen field in the CHAIN block. You can use the ON REQUEST addition only if a FIELD statement contains the MODULE statement. © Copyright. All rights reserved. 98 Lesson: Handling Errors Using Dialog Messages and Field Input Checks Avoiding of Field Input Checks Figure 81: Avoiding Field Input Checks The module with the AT EXIT-COMMAND addition is processed before the automatic field input checks, automatic data transport, and all other PAI modules. You can use the AT EXITCOMMAND addition for navigation with one module for each screen. This module may not have an associated FIELD statement. If you do not exit the screen from this module, the automatic field checks are processed after which follows the rest of the PAI event. © Copyright. All rights reserved. 99 Unit 4: Screen Error Handling Switch-Depending Module Call Figure 82: Switch – Depending Module Call When you specify the addition SWITCH, the dialog module is called only if the switch you specified has the ON status. You must specify the switch defined in the repository. If the specified switch does not exist, the dialog module is not called. You cannot specify the addition with the FIELD statement. The switch that is assigned to the Screen field in the Screen Painter applies. LESSON SUMMARY You should now be able to: ● Send dialog messages ● Check field values ● Implement field input checks © Copyright. All rights reserved. 100 Unit 4 Lesson 2 Handling Errors Using Navigation and Input Help LESSON OVERVIEW This lesson explains how to handle errors using navigation and input help. Business Example You work in a travel agency and need to enable the user to navigate between different screens using the Back and Cancel functions, and provide them input help. For this reason, you require the following knowledge: ● An understanding of navigation and input help LESSON OBJECTIVES After completing this lesson, you will be able to: ● Navigate between screens ● Check inputs by using input help Navigation Figure 83: Navigation – Targets © Copyright. All rights reserved. 101 Unit 4: Screen Error Handling The main functions used to navigate between screens include the Back function, Cancel function, and Exit function. When chosen, the Back function leads one logical level backward. This function is used to lead back to the initial screen from screens on the same level, as well as to lead back to the screen that has called the current screen from screens that contain detailed information. The Cancel function is similar to the Back function, except that it differs in its dialog behavior. On the initial screen of a program, the Back, Exit, and Cancel functions lead back to the screen from which the current program was called. Navigation – Single-Screen Transaction Figure 84: Navigation – Single-Screen Transaction Both the Back and Exit functions exit the current transaction and return to the calling program, for example, the Workplace. These functions differ in terms of their dialog behavior to prevent losing input data. The Cancel function displays the screen again with initialized data fields and allows the user to select a new object. © Copyright. All rights reserved. 102 Lesson: Handling Errors Using Navigation and Input Help Navigation Dialog Boxes Figure 85: Navigation – Dialogs If the user enters any data into the screen the filed SY-DATAR is set to X. By checking SYDATAR you can avoid accidental loss of data by sending a predefined security prompt. When using the Exit and Cancel functions, the user receives a dialog box. For the Exit function, the system checks the input on the screen. The functions in question must be function type E. For the Back function, the system carries out the input check before the dialog box is executed. Note that a user may lose unsaved data, for example, when switching from Change to Display mode. If the user does not save new data, the system displays the original data stored in the database. The SAP system contains a series of function modules that you can use for the user dialogs. © Copyright. All rights reserved. 103 Unit 4: Screen Error Handling Input Help Figure 86: Slide 1 Input help (the help function) is a standard function in the SAP system that allows the user to display a list of possible entries for a screen field. The user can select a field ready for input from the list and enter a value in it. If a field has input help, the possible entries pushbutton appears on its right. The pushbutton is visible whenever the cursor is placed in the field. You can start the help function either by choosing the pushbutton or by pressing F4. In addition to the possible entries pushbutton, the input help displays additional information about the entries — especially useful when the field requires a formal key. The input help is a standard function; therefore, it must have the same appearance and behavior throughout the system. Utilities in ABAP Workbench 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 defined in ABAP Dictionary. LESSON SUMMARY You should now be able to: ● Navigate between screens ● Check inputs by using input help © Copyright. All rights reserved. 104 Unit 4 Learning Assessment 1. Developers can define a SET/GET Parameter ID in the ABAP Workbench. Determine whether this statement is true or false. X True X False 2. When will the system implement the automatic field input check with regard to PAI (Process After Input) processing? Choose the correct answer. X A Before X B After X C During 3. The ON INPUT addition is used in a MODULE statement if the module shall only be processed if the value of the field content is initial. Determine whether this statement is true or false. X True X False 4. The Back function differs from the Cancel function in its dialog behavior. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 105 Unit 4: Learning Assessment 5. Which of the following is the function of the single-screen transaction that displays the screen again with initialized data fields, allowing the user to select another object? Choose the correct answer. X A Back X B Exit X C Cancel 6. If a field has input help, the possible entries button appears on its left. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 106 Unit 4 Learning Assessment - Answers 1. Developers can define a SET/GET Parameter ID in the ABAP Workbench. Determine whether this statement is true or false. X True X False You are correct! SET and GET parameter attributes, SPA and GPA in the table allow you to enable the SET and GET parameter functions separately. You can define parameter IDs in the ABAP Workbench. Read more in the lesson, Handling Errors Using Dialog Messages and Field Input Checks, Task: Definition of SET and GET Parameter Attributes, in the course BC410 (Unit 4, Lesson 1) or TAW10 Part II (Unit 14, Lesson 1). 2. When will the system implement the automatic field input check with regard to PAI (Process After Input) processing? Choose the correct answer. X A Before X B After X C During You are correct! Before processing the PAI modules, the system automatically implements field input checks to check the values that a user enters. Read more in the lesson, Handling Errors Using Dialog Messages and Field Input Checks, Task: Field Input Checks, in the course BC410 (Unit 4, Lesson 1) or TAW10 Part II (Unit 14, Lesson 1). 3. The ON INPUT addition is used in a MODULE statement if the module shall only be processed if the value of the field content is initial. Determine whether this statement is true or false. X True X False You are correct! When using the ON INPUT addition in a MODULE statement after a FIELD statement, the system calls a module only if the field contents have changed from their initial value. Read more in the lesson, Handling Errors Using Dialog Messages and Field Input Checks, Task: Execution When Value is not Initial, in the course BC410 (Unit 4, Lesson 1) or TAW10 Part II (Unit 14, Lesson 1). © Copyright. All rights reserved. 107 Unit 4: Learning Assessment - Answers 4. The Back function differs from the Cancel function in its dialog behavior. Determine whether this statement is true or false. X True X False You are correct! When chosen, the Back function leads one logical level backward. The Cancel function is like the Back function, except that it differs in its dialog behavior. Read more in the lesson, Handling Errors Using Navigation and Input Help, Task: Navigation, in the course BC410 (Unit 4, Lesson 2) or TAW10 Part II (Unit 14, Lesson 2). 5. Which of the following is the function of the single-screen transaction that displays the screen again with initialized data fields, allowing the user to select another object? Choose the correct answer. X A Back X B Exit X C Cancel You are correct! In a single-screen transaction, the Cancel function displays the screen again with initialized data fields and allows the user to select a new object. Unit 4, Lesson 2: Handling Errors Using Navigation and Input Help, Task Navigation – Single-Screen Transaction Read more in the lesson, Handling Errors Using Navigation and Input Help, Task: Navigation – Single-Screen Transaction, in the course BC410 (Unit 4, Lesson 2) or TAW10 Part II (Unit 14, Lesson 2). 6. If a field has input help, the possible entries button appears on its left. Determine whether this statement is true or false. X True X False You are correct! If a field has input help, the possible entries button appears on its right. Read more in the lesson, Handling Errors Using Navigation and Input Help, Task: Input Help, in the course BC410 (Unit 4, Lesson 2) or TAW10 Part II (Unit 14, Lesson 2). © Copyright. All rights reserved. 108 UNIT 5 Subscreens Lesson 1 Creating Subscreens 110 UNIT OBJECTIVES ● Define subscreen areas and subscreens ● Process subscreens ● Embed subscreens © Copyright. All rights reserved. 109 Unit 5 Lesson 1 Creating Subscreens LESSON OVERVIEW This lesson explains subscreen areas and their general and subscreen attributes. Business Example A travel agency needs to maintain the flight booking data for the customers using screens in the application. To display additional information on the screens, you need to create and use subscreens. For this reason, you require the following knowledge: ● An understanding of subscreen areas ● How to create and embed subscreens LESSON OBJECTIVES After completing this lesson, you will be able to: ● Define subscreen areas and subscreens ● Process subscreens ● Embed subscreens © Copyright. All rights reserved. 11 110 0 Lesson: Creating Subscreens Subscreen Areas Figure 87: Subscreens I A subscreen area is a reserved rectangular area on a screen in which you place another screen at runtime. Subscreen areas cannot contain any other screen elements. To use a subscreen, you must create a second screen with the type subscreen and display it in the subscreen area that you defined on the main screen. A subscreen is an independent screen, which displays within another screen. You can use a subscreen to perform the following functions: ● To display a group of objects from the main screen ● To display or hide extra fields on the main screen, depending on the entries the user has made © Copyright. All rights reserved. 111 Unit 5: Subscreens Reuse of Subscreens in Different Programs Figure 88: Subscreens II Another advantage of using subscreens is that different programs can use the same subscreens. To configure this setting, you must execute other screen programs within your main program. You can include more than one subscreen in a single main screen. You can also determine which subscreen displays dynamically at runtime. You can use subscreens in the following scenarios: ● Screen enhancements (for example, screen exits) ● Within other screen objects (for example, tabstrip controls) ● Modification Assistant ● Web transactions © Copyright. All rights reserved. 112 Lesson: Creating Subscreens Subscreen Area – Attributes Figure 89: Subscreen Area – Attributes If a subscreen is larger than the subscreen area in which it is called, the system only displays as much data as can fit on the screen, starting at the upper left corner. However, you can use the Scrollable attribute to ensure that the complete subscreen displays. If the screen is too large to fit on the subscreen area, the system displays scrollbars. The Resizable attribute controls whether the size of a subscreen area can be changed vertically or horizontally. You must set these attributes for the size of the subscreen area to change with the size of the main screen. 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. The following restrictions apply to subscreens: ● CALL SUBSCREEN is not allowed between LOOP and ENDLOOP, or between CHAIN and ENDCHAIN. ● ● ● ● A subscreen cannot have an OK_CODE field. Object names must be unique within the set of all subscreens called on a single main screen. Subscreens cannot 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 subscreen modules. © Copyright. All rights reserved. 11 113 3 Unit 5: Subscreens Creating a Subscreen Area Figure 90: Creating a Subscreen Area To create a subscreen area, choose Subscreen Area from the object list in the Screen Painter and place it on the screen. Identify the top left 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. A subscreen name is necessary to identify the area when you call the subscreen. Subscreen Processing Figure 91: Calling a Subscreen © Copyright. All rights reserved. 11 114 4 Lesson: Creating Subscreens 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 commands 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 can program ABAP modules for subscreens in the same way as for screen. Special Case – Visibility of Data Figure 92: Special Case – Visibility of Data The fields that you use within the flow logic are the global fields of your ABAP program. These fields must be declared in the TOP include of your program. © Copyright. All rights reserved. 115 Unit 5: Subscreens Subscreens from External Programs Figure 93: Subscreens from External Programs If a subscreen is not in the same module pool as the main screen, the global data of the main program is not available to the subscreen and the data from the screen cannot be transferred back to the program. You must program the data transfer, for example, using a function module that exports and imports data, with an appropriate MOVE statement in the subscreen coding. © Copyright. All rights reserved. 11 116 6 Lesson: Creating Subscreens Subscreen Embedding Figure 94: Subscreens – Encapsulation in Function Groups To use subscreens in the screens of different programs, you must encapsulate the subscreens in a function group and use function modules to move the data between the programs. You can pass the 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). © Copyright. All rights reserved. 11 117 7 Unit 5: Subscreens Subscreens in Function Groups – Call Sequence Figure 95: Subscreens in Function Groups – Call Sequence You can use function modules to transport the data between the calling program and the function group. You can use a module before the subscreen call to pass the data from the calling program to the subscreen from the function group. This calls for 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 PBO processing block of the subscreen is called. The sequence is reversed in the PAI module of the calling screen. You call the PAI processing block of the subscreen before you call a function module to pass the data from the function group back to the calling program. © Copyright. All rights reserved. 118 Lesson: Creating Subscreens Subscreens in Function Groups – Data Transport Figure 96: Subscreens in Function Groups – Data Transport To make the data from the calling program available globally in the function group, you must transfer the interface parameters from the function module into the global data fields of the function group, and vice versa. LESSON SUMMARY You should now be able to: ● Define subscreen areas and subscreens ● Process subscreens ● Embed subscreens © Copyright. All rights reserved. 11 119 9 Unit 5 Learning Assessment 1. A single main screen includes only one subscreen. Determine whether this statement is true or false. X True X False 2. When using the subscreen, you must call it in what section(s) of the flow logic of the main screen? Choose the correct answer. X A Both Process Before Output (PBO) and Process After Input (PAI) X B Either PBO or PAI 3. When including a subscreen of a function group the subscreen call (at PBO) must occur before the function module call. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 12 120 0 Unit 5 Learning Assessment - Answers 1. A single main screen includes only one subscreen. Determine whether this statement is true or false. X True X False You are correct! You can include more than one subscreen in a single main screen. You can also determine which subscreen displays dynamically at runtime. Read more in the lesson, Creating Subscreens, Task: Reuse of Subscreens in Different Programs, in the course BC410 (Unit 5, Lesson 1) or TAW10 Part II (Unit 15, Lesson 1). 2. When using the subscreen, you must call it in what section(s) of the flow logic of the main screen? Choose the correct answer. X A Both Process Before Output (PBO) and Process After Input (PAI) X B Either PBO or PAI You are correct! To use a subscreen, you must call it in both the PBO and PAI sections of the flow logic of the main screen. Read more in the lesson, Creating Subscreens, Task: Subscreen Processing, in the course BC410 (Unit 5, Lesson 1) or TAW10 Part II (Unit 15, Lesson 1). 3. When including a subscreen of a function group the subscreen call (at PBO) must occur before the function module call. Determine whether this statement is true or false. X True X False You are correct! The function module call must occur before the subscreen call. This ensures that the data is known in the function group before the PBO processing block of the subscreen is called. Read more in the lesson, Creating Subscreens, Task: Subscreens in Function Groups – Call Sequence, in the course BC410 (Unit 5, Lesson 1) or TAW10 Part II (Unit 15, Lesson 1). © Copyright. All rights reserved. 121 UNIT 6 Tabstrip Controls Lesson 1 Creating Tabstrip Controls 123 Lesson 2 Programming Tabstrip Controls 129 UNIT OBJECTIVES ● Describe tabstrip controls ● Define tabstrip controls ● Use local scrolling in Tabstrip Controls ● Use PAI scrolling in Tabstrip Controls ● Create tabstrip controls using the wizard © Copyright. All rights reserved. 122 Unit 6 Lesson 1 Creating Tabstrip Controls LESSON OVERVIEW This lesson explains the creation and use of tabstrip controls. Business Example A travel agency needs to maintain the flight booking data for the customers who use different screens in the SAP application. As a developer, you need to know how to create tabstrip controls to display various components of an application on a single screen. For this reason, you require the following knowledge: ● An understanding of the definition of tabstrip controls ● How to navigate between various components LESSON OBJECTIVES After completing this lesson, you will be able to: ● Describe tabstrip controls ● Define tabstrip controls Tabstrip Controls Figure 97: Screen Elements – Tabstrip Controls Tabstrip controls provide an easy, user-friendly way to display various components of an application on a single screen and allow the user to navigate between them. The intuitive design of tabstrip control makes navigation easier for end users. © Copyright. All rights reserved. 12 123 3 Unit 6: Tabstrip Controls Uses of tabstrip controls are as follows: ● Use tabstrip controls to simplify complex applications. ● Use tabstrip controls wherever you have various components of an application that form a logical unit. For example, you have a set of header data that remains constant and underneath that set of header data you want to display other sets of data. You must not use tabstrip controls in the following circumstances: ● 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 need to be processed in a certain order. Tabstrip controls are designed to allow users to navigate freely between various components. The components are processed dynamically, that is, the user input on one tab page causes other tab pages to appear suddenly. Tabstrip controls are compatible with batch input processing. Tabstrip Elements Figure 98: Tabstrip Elements A tabstrip control consists of individual pages with a tab page and a tab title. A tabstrip control may have only one row of tab titles. If the tabstrip control contains too many pages, it is not possible for all of the tab titles to be displayed at once. In this case, a scrollbar allows you to scroll through the remaining tab pages. In the upper-right corner of the tab, there is a pushbutton. Select this pushbutton and a list of all of the tab titles displays. The active tab title is marked with a checkmark. © Copyright. All rights reserved. 12 124 4 Lesson: Creating Tabstrip Controls Page Elements – Technical View Figure 99: Page Elements – Technical View A page element consists of a tab title, a subscreen area, and a subscreen. Technically, tab titles are treated as pushbuttons. The contents of page elements are displayed using the subscreen technique. Assign a subscreen area to each screen for which you can call a subscreen. Tabstrip Controls – Attributes Figure 100: Tabstrip Controls – Attributes In addition to the general attributes, for example, Object name, Start position, and Size Static, tabstrip controls also have special attributes. © Copyright. All rights reserved. 125 Unit 6: Tabstrip Controls Tabstrip Controls Creation Figure 101: Creating a Tabstrip Control Create a tabstrip control by performing the following steps: 1. Define the tab area. 2. Define the tab titles and, if necessary, add further tab titles. 3. Assign a subscreen area to each page element. Tabstrip Control Creation – Tabstrip Area Figure 102: Creating a Tabstrip Control – Tabstrip Area © Copyright. All rights reserved. 12 126 6 Lesson: Creating Tabstrip Controls Perform the following steps to create a tabstrip control area: 1. Choose Tabstrip control from the object list in the Screen Painter, and place it on the screen. Fix the upper-left corner of the tabstrip control area. Drag the object to the required size. 2. Assign a name to the tabstrip control in the Object name attribute. This name identifies your tabstrip control. 3. In the TOP include of 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 ACTIVETAB field contains the function code of the tab title of the currently active tabstrip. Other fields are reserved for internal use. The default number of tab pages for a tabstrip control is two. Tabstrip Control Creation – Tab Title Figure 103: Creating a Tabstrip Control – Tab Title Technically, tab titles are treated the same way as pushbuttons. A tab title can have various attributes as follows: ● Name ● Text ● Function code ● Function type You can enter these attributes in the Name, Text , FctCode, and FctType fields of the object attributes. A tab title can have the function type ’ ’ (space) or P. If the function type is ’ ’ (space), the Process After Input (PAI) processing block is triggered when the user chooses that tab, and © Copyright. All rights reserved. 12 127 7 Unit 6: Tabstrip Controls the function code of the tab title is placed in the command field. If the function type is P, the user can scroll between different tab pages of the same type at the front end without triggering the PAI processing block. If you want your tabstrip control to have more than two pages, you must create further tab titles. To create further tab titles, choose Pushbutton from the object list in the Screen Painter and place it in the tab title area. Tabstrip Control Creation – Tabstrip Subscreens Figure 104: Creating Tabstrip Control – Tabstrip Subscreens 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. Perform the following steps to assign a subscreen area to one or more tab pages: 1. Choose the relevant tab title in the fullscreen Layout Editor. 2. 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 that subscreen area directly in the Reference field of the attributes of the relevant tab pages. LESSON SUMMARY You should now be able to: ● Describe tabstrip controls ● Define tabstrip controls © Copyright. All rights reserved. 128 Unit 6 Lesson 2 Programming Tabstrip Controls LESSON OVERVIEW This lesson explains how to scroll between the pages of the tabstrip controls. Business Example A travel agency needs to maintain the flight booking data for customers who use different screens in the SAP application. As a developer, you need to know the techniques of programming the tabstrip controls using either local scrolling or PAI scrolling. You also need to know how to create the tabstrip controls using the Wizard. For this reason, you require the following knowledge: ● An understanding of tabstrip controls ● Scrolling in Table Controls LESSON OBJECTIVES After completing this lesson, you will be able to: ● Use local scrolling in Tabstrip Controls ● Use PAI scrolling in Tabstrip Controls ● Create tabstrip controls using the wizard Tabstrip Control Local Scrolling Figure 105: Scrolling Locally in Tabstrip Controls © Copyright. All rights reserved. 129 Unit 6: Tabstrip Controls Assign a different subscreen area to each page element in a tabstrip control and then, you can scroll locally between the pages at the front end. To scroll locally between the pages at front end, you must send all subscreens to the front end when you send the main screen. All tab titles in the tabstrip control must also have the function type P. When you scroll among different page elements, there is no communication between presentation and application servers. When a user chooses a function on the screen that triggers PAI processing, the system processes the PAI blocks of all subscreens as well. All field checks are run and the tabstrip control performs like a single large screen. Therefore, local scrolling in tabstrip controls is more appropriate for displaying transactions. Scrolling Locally in Tabstrip Controls – Programming Figure 106: Scrolling Locally in Tabstrip Controls – Programming Perform the following steps to program a tabstrip control which allows you to scroll locally at the front end: 1. Assign a separate subscreen area to each tab page. A subscreen will be sent to each of these pages when the screen is processed. 2. Call all subscreens from the flow logic. 3. Assign function type P to all tab titles. The system can hide any screen whose subscreen does not contain any elements that can be displayed. If there are no screens containing elements that can be displayed, the system hides the entire tabstrip control. © Copyright. All rights reserved. 130 Lesson: Programming Tabstrip Controls PAI Scrolling in Tabstrip Controls Figure 107: PAI Scrolling in Tabstrip Controls If all page elements share a single subscreen area, the program analyzes the function code of the chosen tab title to determine which screen is displayed. This process of PAI scrolling involves the following steps: 1. In the PAI processing block, the program determines the page element that needs to be active, based on the tab title that the user chooses. 2. In the Process Before Output (PBO) processing block, the program displays the corresponding screen. During this process, the system checks only the fields of the displayed subscreen. © Copyright. All rights reserved. 131 Unit 6: Tabstrip Controls PAI Scrolling in Tabstrip Controls – Programming Figure 108: PAI Scrolling in Tabstrip Controls – Programming To implement the PAI scrolling function in a tabstrip control, the following requirements must be met: ● All tab pages share a common subscreen area. ● All tab titles have the function code type ’ ’ (space). In the flow logic, use a variable to call the screen that displays in the subscreen area. In the PAI block, call a module in which the function code of the ACTIVETAB title is placed in the active tab field of the structure you created with type TABSTRIP . In the figure, this is MY_TAB_STRIP . The PBO processing block must contain a module, before the subscreen is called, in which you place the name of the subscreen in the corresponding variable. Assign an initial value to the subscreen variable so that the screen is processed the first time before the user has a chance to choose a tab title. To hide a tab page at runtime, set the corresponding tab title to inactive by using the system table SCREEN, SCREEN-ACTIVE = 0 . Set that corresponding tab title to inactive before processing the tabstrip control for the first time to ensure that the screen environment remains constant. © Copyright. All rights reserved. 132 Lesson: Programming Tabstrip Controls Create Tabstrip Controls Using the Wizard Figure 109: Create Tabstrip Controls Using the Wizard Use the Tabstrip Control Wizard to create tabstrip controls and insert them on screens in a program. The wizard guides you through the process. You can return to previous settings at any time. Program objects are created on the final screen only upon completion of the process. The wizard creates the tabstrip control as well as the corresponding statements in the flow logic, together with the relevant modules, subroutines, and necessary data definitions. In addition, the following objects are created (if they do not already exist): ● Empty subscreens for the individual tabstrip control pages ● Includes for data definitions, PBO and PAI modules, and INCLUDE statements for these includes All objects are placed in the inactive object list. LESSON SUMMARY You should now be able to: ● Use local scrolling in Tabstrip Controls ● Use PAI scrolling in Tabstrip Controls ● Create tabstrip controls using the wizard © Copyright. All rights reserved. 133 Unit 6 Learning Assessment 1. Tabstrip controls allow users to navigate freely between screens. Determine whether this statement is true or false. X True X False 2. Which of the following should you choose to create more tab titles? Choose the correct answer. X A Pushbutton X B Subscreen 3. Local scrolling in tabstrip controls is appropriate for display transactions. Determine whether this statement is true or false. X True X False 4. Which of the following is the processing block where the program sets the corresponding screen? Choose the correct answer. X A Process Before Output (PBO) X B Process After Input (PAI) 5. Empty subscreens always exist in tabstrip control pages. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 134 Unit 6 Learning Assessment - Answers 1. Tabstrip controls allow users to navigate freely between screens. Determine whether this statement is true or false. X True X False You are correct! Tabstrip controls provide an easy, user-friendly way to display various components of an application on a single screen and allow the user to navigate between them. Read more in the lesson, Creating Tabstrip Controls, Task: Tabstrip Controls, in the course BC410 (Unit 6, Lesson 1) or TAW10 Part II (Unit 16, Lesson 1). 2. Which of the following should you choose to create more tab titles? Choose the correct answer. X A Pushbutton X B Subscreen You are correct! To create further tab titles, choose Pushbutton from the object list in the Screen Painter and place it in the tab title area. Read more in the lesson, Creating Tabstrip Controls, Task: Tabstrip Control Creation – Tab Title, in the course BC410 (Unit 6, Lesson 1) or TAW10 Part II (Unit 16, Lesson 1). 3. Local scrolling in tabstrip controls is appropriate for display transactions. Determine whether this statement is true or false. X True X False You are correct! When a user chooses a function on the screen that triggers PAI processing, all field checks are run and the tabstrip control performs like a single large screen. Therefore, local scrolling in tabstrip controls is more appropriate for displaying transactions. Read more in the lesson, Programming Tabstrip Controls, Task: Tabstrip Control Local Scrolling, in the course BC410 (Unit 6, Lesson 2) or TAW10 Part II (Unit 16, Lesson 2). © Copyright. All rights reserved. 135 Unit 6: Learning Assessment - Answers 4. Which of the following is the processing block where the program sets the corresponding screen? Choose the correct answer. X A Process Before Output (PBO) X B Process After Input (PAI) You are correct! If all page elements share a single subscreen area, the program analyzes the function code of the chosen tab title to determine which screen is displayed. In the Process Before Output (PBO) processing block, the program displays the corresponding screen. Read more in the lesson, Programming Tabstrip Controls, Task: PAI Scrolling in Tabstrip Controls, in the course BC410 (Unit 6, Lesson 2) or TAW10 Part II (Unit 16, Lesson 2). 5. Empty subscreens always exist in tabstrip control pages. Determine whether this statement is true or false. X True X False You are correct! The system can hide any screen whose subscreen does not contain any elements that can be displayed. If there are no screens containing elements that can be displayed, the system hides the entire tabstrip control. Read more in the lesson, Programming Tabstrip Controls, Task: Scrolling Locally in Tabstrip Controls – Programming, in the course BC410 (Unit 6, Lesson 2) or TAW10 Part II (Unit 16, Lesson 2). © Copyright. All rights reserved. 136 UNIT 7 Table Controls Lesson 1 Creating Table Controls 138 Lesson 2 Modifying Table Controls at Runtime 147 Lesson 3 Changing Table Controls at Runtime 157 UNIT OBJECTIVES ● Define table controls ● Create table controls ● Set table control attributes ● Process table controls ● Change table control content at runtime ● Create table controls ● Set table control attributes ● Sort table controls at runtime ● Use table control paging at runtime © Copyright. All rights reserved. 137 Unit 7 Lesson 1 Creating Table Controls LESSON OVERVIEW This lesson explains how to create a table control and use it to display data in tabular form. Business Example A travel agency needs to maintain flight booking data for its customers. The application requires a table control to display data in tabular form. For this reason, you require the following knowledge: ● How to define table controls ● How to set table control attributes LESSON OBJECTIVES After completing this lesson, you will be able to: ● Define table controls ● Create table controls ● Set table control attributes Table Controls Figure 110: Table Controls A table control is an area on the screen in which the system displays data in tabular form. Updates to table controls are processed in a loop. The top line of a table control is the header line, and is separated by a gray separator. Within a table control, you can use table elements, keywords, templates, checkboxes, radio buttons, radio button groups, and pushbuttons. A line may have up to 255 columns, and each column may have a title. You can display or enter single structured lines of data using a table control. © Copyright. All rights reserved. 138 Lesson: Creating Table Controls Table Controls – Features Figure 111: Table Controls – Features The benefits of using a table control are as follows: ● The table designer can create resizable tables for displaying and editing data. ● ● ● The user or program can change column widths and positions, save the changes, and reload the changes later. The user can mark lines with the help of a selection column. Marked lines are highlighted in a different color. The table designer can choose any of several line selection options: single lines, multiple lines, all lines, and deselection. ● Column headings can be used as pushbuttons for marking columns. ● The table designer can include scrollbars for horizontal and vertical scrolling. ● The table designer can set any number of key (leading) columns. ● Cell attributes are variable at runtime. © Copyright. All rights reserved. 139 Unit 7: Table Controls Table Controls – Table Settings Figure 112: Table Controls – Table Settings Users can save display variants for table controls. Users can save these variants along with the basic settings, as the current display settings or as the default display settings. Actions in Table Controls Figure 113: Actions in Table Controls The table control contains the following series of actions that are controlled entirely at the presentation server: ● Horizontal scrolling using the scrollbar in the table control ● Swapping columns ● Changing column widths ● Selecting columns © Copyright. All rights reserved. 140 Lesson: Creating Table Controls ● Selecting lines The Process After Input (PAI) processing block is triggered when you scroll vertically in the table control or save the user configuration. Table Control Attributes Figure 114: Slide 1 In addition to standard attributes, such as Name, Start position, and Size, table controls also have special attributes. The special attributes determine the display options for a table control and whether the table control can be configured by the user. The stepl and loopc fields of the global structure SYST contain information about the loop processing used with table controls. © Copyright. All rights reserved. 141 Unit 7: Table Controls Table Controls Creation Figure 115: Creating Table Controls When you create a table control, you must create a table control area and table control fields. Creating a Table Control – Table Control Area Figure 116: Slide 1 Perform the following steps to create a table control area: ● Choose Table control from the object list in the Screen Painter and place it in the screen work area. © Copyright. All rights reserved. 142 Lesson: Creating Table Controls ● Fix the upper-left corner of the table control area and then drag the object to the required size. In the 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 can 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 <ctrl> FROM SCREEN <scr>. Here, <scr> may be the number of any screen on which a table control with name <ctrl> is defined. Fields Figure 117: Creating Table Controls – Fields You can create fields in a table control using the Dictionary/Program fields function with the following steps: 1. Enter the name of the structure whose fields you want to use in the table control and choose Enter. 2. Choose the fields that you want to use in the field list and choose OK. 3. Click the table control area. The system places all the selected fields in the table control. If the fields have text elements, the system uses these as column headings. © Copyright. All rights reserved. 143 Unit 7: Table Controls Alternatively, you can position individual input/output fields in the table control area. Each field generates a single column. Selection Column Figure 118: Creating Table Controls – Selection Column When you create a table control, the system automatically initializes a selection column. The selection column behaves like a checkbox. It must 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 identifying whether a row is selected or not between the screen and the ABAP program. © Copyright. All rights reserved. 144 Lesson: Creating Table Controls Table Control Attributes at Runtime Figure 119: Table Control Attributes at Runtime The table control attributes can be saved at runtime in the structure that you declared in the CONTROLS statement. Table control attributes can be divided into the following categories: ● General attributes The general attributes contain information about the properties of the entire table control, such as the number of fixed columns. ● Column attributes The column attributes are saved in an internal table (one entry for each column). Each column consists of the attributes from the SCREEN structure, along with the column position, selection indicator, visibility indicator, and visible width of the column. © Copyright. All rights reserved. 145 Unit 7: Table Controls Table Control Attributes – Structure Figure 120: Slide 1 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 the user interaction with the table control. For example, you can use the selected field to determine whether the user has selected a particular column. Note: For further details about the table control attributes structure and their precise meanings, refer to the ABAP keyword documentation from the ABAP editor for the CONTROLS statement. Choose Declaration of table control and then CXTAB_CONTROL . LESSON SUMMARY You should now be able to: ● Define table controls ● Create table controls ● Set table control attributes © Copyright. All rights reserved. 146 Unit 7 Lesson 2 Modifying Table Controls at Runtime LESSON OVERVIEW This lesson explains how to modify table controls at runtime. Business Example A travel agency needs to maintain the flight booking data for its customers. In the table control created for this purpose, the application should allow users to change the table control content. For this reason, you require the following knowledge: ● How to display buffered data from the internal table in the table control ● How to change the contents of a table control LESSON OBJECTIVES After completing this lesson, you will be able to: ● Process table controls ● Change table control content at runtime ● Create table controls Table Control Processing Figure 121: Processing a Table Control (Principle) © Copyright. All rights reserved. 147 Unit 7: Table Controls For optimum performance, the data for the table control should be read once from the database at runtime and stored in an internal table. The system fills the table control lines from this internal table. Table Controls – Applications (Principle) Figure 122: Table Controls – Applications (Principle) You must fill the table before you can display data from an internal table in a table control. Make sure that you do not fill the internal table in every Process Before Output (PBO) event, but only when the key fields change. In order to process the table control, the system needs to know how far the user can scroll vertically. You can use the LINES function to find out the number of entries in the internal table and save this number 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 Process After Input (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. 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 modules, you must distinguish between those modules that should apply only to individual lines of a table control and those modules that should apply to the entire screen that contains the table control. © Copyright. All rights reserved. 148 Lesson: Modifying Table Controls at Runtime Filling a Table Control Figure 123: Filling a Table Control The steps for displaying buffered data from the internal table in a table control are as follows: 1. The system loops through the lines of the table control on the screen. The lines of the screen table are processed one by one. 2. The system places the current line of the internal table in the work area of the internal table for each line. 3. The system copies the data from the work area of the internal table to the relevant line of the table control for each line. © Copyright. All rights reserved. 149 Unit 7: Table Controls Code – Filling a Table Control Figure 124: Code – Filling a Table Control In the flow logic, the loop statement LOOP AT <itab> INTO <wa_itab> WITH CONTROL <tc_name>. 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 <wa_itab>. <itab> is the name of the internal table containing the data, <wa_itab> is the name of the work area for the internal table, and <tc_name> 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 <wa_itab>, the system can transport data between the ABAP program and the screen automatically. 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 <wa_itab> into the screen fields. ( MOVE-CORRESPONDING <wa_itab> TO <wa_screen>., where <wa_screen> should be defined with a TABLES statement). The system calculates the value of <ctrl>-TOP_LINE when you scroll. © Copyright. All rights reserved. 150 Lesson: Modifying Table Controls at Runtime Table Controls – Field Transport in the PBO Figure 125: Table Controls – Field Transport in the PBO When you use table controls on a screen, the automatic 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. © Copyright. All rights reserved. 151 Unit 7: Table Controls Table Content Changes Figure 126: Changing the Contents of a Table Control You must perform the following steps to transfer changed values from the table control back to the internal table: 1. Program the transport of data from the table control to the TABLES structure by looping the lines of the table control. 2. Program the transport of the contents of the TABLES structure to the work area of the internal table if not using the TABLES structure. 3. Program the transport of the contents of the work area into the corresponding line of the internal table. © Copyright. All rights reserved. 152 Lesson: Modifying Table Controls at Runtime Code – Changing the Contents of Table Control Figure 127: Code – Changing the Contents of Table Control The LOOP AT <itab>. ... 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 work area of the internal table to the body of the table itself. Use the <control>-current_line field to do this. 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 work area of the internal table. You can then copy the data back to the internal table itself. You can also use the <control>-current_line field to do this. © Copyright. All rights reserved. 153 Unit 7: Table Controls Table Controls – Field Transport in the PAI Figure 128: Table Controls – Field Transport in the PAI 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. As usual, the fields that occur in FIELD statements are transported directly before that statement. © Copyright. All rights reserved. 154 Lesson: Modifying Table Controls at Runtime Field Transports for Formatted Fields Figure 129: Field Transports for Formatted Fields A system program for currency amounts executes additional formatting for each currency during the automatic data transport from the screen to ABAP. The program refers to the contents of the corresponding reference field. The program also refers to the contents of the ABAP field. Errors occur when the reference field does not contain the respective currency. The sequence of the data transport is dependent on the position of the fields on the screen. It is not necessary to consider the exclusively technical aspects of the data transport since the screen layout is extremely user friendly. You must ensure that in the flow logic programming, the fields are transported in the correct order so that the reference fields are followed by the amounts. To do this, delay the data transport of the quantity fields using a corresponding FIELD statement. © Copyright. All rights reserved. 155 Unit 7: Table Controls Table Control Creation Using the Wizard Figure 130: Creating Table Controls Using the Wizard You can use the Table Control Wizard to help you create table controls and insert them on screens in a program. The Wizard guides you through the process. You can return to the previous settings at any time. Program objects are created on the final screen only upon completion of the process. The Wizard creates not only the table control but also the corresponding statements in the screen flow logic, together with the relevant modules, subroutines, and necessary data definitions. If necessary, programs or includes are generated and concatenated using INCLUDE statements. You can also implement the scrolling function for the table control. All objects are placed in the inactive object list. LESSON SUMMARY You should now be able to: ● Process table controls ● Change table control content at runtime ● Create table controls © Copyright. All rights reserved. 156 Unit 7 Lesson 3 Changing Table Controls at Runtime LESSON OVERVIEW This lesson explains how to change the attributes of a table control at runtime. Business Example A travel agency needs to maintain flight booking data for its customers. In the table control created for this purpose, the application should allow users to change the attributes by overwriting the field contents of the structure created in the CONTROLS statement. For this reason, you require the following knowledge: ● How to change the attributes of a table control at runtime LESSON OBJECTIVES After completing this lesson, you will be able to: ● Set table control attributes ● Sort table controls at runtime ● Use table control paging at runtime Table Control Attributes Figure 131: Changing a Table Control © Copyright. All rights reserved. 15 157 7 Unit 7: Table Controls You can modify the attributes of a table control by overwriting the field contents of the structure created in the CONTROLS statement. To temporarily change the attributes of individual cells, change the SCREEN table in a PBO module that you process between LOOP and ENDLOOP in the flow logic coding and that uses LOOP AT SCREEN, MODIFY SCREEN in the ABAP coding. In the loop, the runtime system initializes the attributes set statically for the table control in the Screen Painter . You can change these attributes only in a module called from a loop through the table control. Changing the Attributes of Table Control I Figure 132: Changing the Attributes of Table Control I You can dynamically change a table control by modifying the contents of the fields of its structure. © Copyright. All rights reserved. 158 Lesson: Changing Table Controls at Runtime Changing the Attributes of Table Control II Figure 133: Changing the Attributes of Table Control II If you want to change the attributes of the columns in a table control, you must change the respective entries in the <control> -cols table. Note: The table has no header lines, which means you have to create an explicit work area. 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. © Copyright. All rights reserved. 15 159 9 Unit 7: Table Controls Table Control Field Attributes Figure 134: Table Controls – Field Attributes During the loop processing of the table control at Process Before Output (PBO), a system program copies some of the column attributes from the table control structure to the SCREEN system table. The program copies the parts of the COLS line structure that are also called SCREEN-<fname>. Attributes are copied for all fields of a table control line. Table Controls – Changing Field Attributes Temporarily Figure 135: Table Controls – Changing Field Attributes Temporarily © Copyright. All rights reserved. 160 Lesson: Changing Table Controls at Runtime It is possible to temporarily change the attributes of table control fields. These changes are effective only when the current screen is being processed. To temporarily change the attributes, call a module from within the table control loop in the PBO 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. Table Control Sorting Figure 136: Sorting Table Controls (Example) You can easily sort the table control display for a particular column using the table control attributes, <wa_cols> -selected and <wa_cols>-screen-name. You can define the sort criteria using string processing. Ensure that the <wa_cols>-screenname field contains the name of the screen field and not the column name of the internal table. Line Counters and Cursor Position A table control can utilize the following variables as line counters: Table 8: Table Control Line Counter Variables Line C Count ounter er Description SY-LOOPC At PBO: How many lines can be displayed in the table control? At PAI: How many lines are actually displayed? © Copyright. All rights reserved. 161 Unit 7: Table Controls Line C Count ounter er Description SY-STEPL Loop counter - counts during LOOP ... ENDLOOP of the flow logic. Which line of the table control is being processed? The statement GET CURSOR LINE refers to SY-STEPL . <TC>-CURRENT_LINE Loop counter - counts during LOOP ... ENDLOOP of the flow logic. Which line of the internal table is being processed? <TC>-TOP_LINE Which line of the internal table is momentarily at the top of the table control? <TC>-LINES How many lines does the internal table contain? Table Controls – Cursor Position Figure 137: Table Controls – Cursor Position (Example) The LINE parameter in the GET or SET statement refers to the sy-stepl system field, the special loop index in the flow logic. Calculate the internal table line that corresponds to the selected table control line as follows: line = <control>-top_line + cursor position - 1. The GET CURSOR statement sets the return code as follows: sy-subrc = 0: cursor was on a field. sy-subrc = 4: cursor was not on a field. If you use a table control on your screen, you can place the cursor on a particular element within the table control. To do this, use the LINE parameter and enter the line on which the cursor should be positioned: SET CURSOR FIELD <field_name> LINE <line>. © Copyright. All rights reserved. 162 Lesson: Changing Table Controls at Runtime You can also use the OFFSET and LINE parameters together. LESSON SUMMARY You should now be able to: ● Set table control attributes ● Sort table controls at runtime ● Use table control paging at runtime © Copyright. All rights reserved. 163 Unit 7 Learning Assessment 1. Which of the following actions will trigger the Process After Input (PAI)? Choose the correct answer. X A Vertical scrolling X B Horizontal scrolling 2. Which of the following are the attributes maintained in the Screen Painter? Choose the correct answer. X A Static X B Dynamic X C Special 3. General attributes include information about table control properties. Determine whether this statement is true or false. X True X False 4. What should you do if you are not using the same structure for the table control fields and the work? area of the internal table, Choose the correct answer. X A You must call a module between LOOP and ENDLOOP that moves the data from the work area <wa_itab> into the screen fields X B The system can transport data between the ABAP program and the screen automatically © Copyright. All rights reserved. 164 Unit 7: Learning Assessment 5. When changing the content of the table control you might need to copy the data transported from the screen fields into the work area of the internal table. When will this action become necessary? Choose the correct answer. X A If the fields on your screen have the same names as the fields in the internal table and if the internal table has a header line. X B If the fields on your screen do not have the same names as the fields in the internal table. 6. The only function of the Wizard is to create a table control. Determine whether this statement is true or false. X True X False 7. Any change of attributes of an individual cell in a table control is possible only in a module called from a LOOP through the table control. Determine whether this statement is true or false. X True X False 8. Temporary change in the attributes of table control fields is not possible. Determine whether this statement is true or false. X True X False 9. OFFSET and LINE parameters cannot be used together in a table control. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 165 Unit 7 Learning Assessment - Answers 1. Which of the following actions will trigger the Process After Input (PAI)? Choose the correct answer. X A Vertical scrolling X B Horizontal scrolling You are correct! The Process After Input (PAI) processing block is triggered when you scroll vertically in the table control or save the user configuration. Read more in the lesson, Creating Table Controls, Task: Actions in Table Controls, in the course BC410 (Unit 7, Lesson 1). 2. Which of the following are the attributes maintained in the Screen Painter? Choose the correct answer. X A Static X B Dynamic X C Special You are correct! You can maintain the initial values (static attributes) in the Screen Painter. Read more in the lesson, Creating Table Controls, Task: Creating a Table Control – Table Control Area, in the course BC410 (Unit 7, Lesson 1). 3. General attributes include information about table control properties. Determine whether this statement is true or false. X True X False You are correct! The general attributes contain information about the properties of the entire table control, such as the number of fixed columns. Read more in the lesson, Creating Table Controls, Task: Table Control Attributes at Runtime, in the course BC410 (Unit 7, Lesson 1). © Copyright. All rights reserved. 166 Unit 7: Learning Assessment - Answers 4. What should you do if you are not using the same structure for the table control fields and the work? area of the internal table, Choose the correct answer. X A You must call a module between LOOP and ENDLOOP that moves the data from the work area <wa_itab> into the screen fields X B The system can transport data between the ABAP program and the screen automatically You are correct! 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 <wa_itab> into the screen fields. (MOVECORRESPONDING <wa_itab> TO <wa_screen>., where <wa_screen> should be defined with a TABLES statement). Read more in the lesson, Modifying Table Controls at Runtime, Task: Code – Filling a Table Control, in the course BC410 (Unit 7, Lesson 2). 5. When changing the content of the table control you might need to copy the data transported from the screen fields into the work area of the internal table. When will this action become necessary? Choose the correct answer. X A If the fields on your screen have the same names as the fields in the internal table and if the internal table has a header line. X B If the fields on your screen do not have the same names as the fields in the internal table. You are correct! 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 work area of the internal table. Read more in the lesson, Modifying Table Controls at Runtime, Task: Code – Changing the Contents of Table Control, in the course BC410 (Unit 7, Lesson 2). 6. The only function of the Wizard is to create a table control. Determine whether this statement is true or false. X True X False You are correct! The Wizard creates not only the table control but also the corresponding statements in the screen flow logic, together with the relevant modules, subroutines, and the necessary data definitions. If necessary, programs or includes are generated and concatenated using INCLUDE statements. Read more in the lesson, Modifying Table Controls at Runtime, Task: Table Control Creation Using the Wizard, in the course BC410 (Unit 7, Lesson 2). © Copyright. All rights reserved. 167 Unit 7: Learning Assessment - Answers 7. Any change of attributes of an individual cell in a table control is possible only in a module called from a LOOP through the table control. Determine whether this statement is true or false. X True X False You are correct! To temporarily change the attributes of individual cells, change the SCREEN table in a PBO module that you process between LOOP and ENDLOOP in the flow logic coding and that uses LOOP AT SCREEN, MODIFY SCREEN in the ABAP coding. Read more in the lesson, Changing Table Controls at Runtime, Task: Table Control Attributes, in the course BC410 (Unit 7, Lesson 3). 8. Temporary change in the attributes of table control fields is not possible. Determine whether this statement is true or false. X True X False You are correct! You can modify the attributes of a table control by overwriting the field contents of the structure created in the CONTROLS statement. Read more in the lesson, Changing Table Controls at Runtime, Task: Creating a Table Control – Table Control Attributes, in the course BC410 (Unit 7, Lesson 3). 9. OFFSET and LINE parameters cannot be used together in a table control. Determine whether this statement is true or false. X True X False You are correct! You can use the OFFSET and LINE parameters together. Read more in the lesson, Changing Table Controls at Runtime, Task: Table Controls – Cursor Position, in the course BC410 (Unit 7, Lesson 3). © Copyright. All rights reserved. 168 UNIT 8 Context Menus Lesson 1 Implementing Context Menus 170 UNIT OBJECTIVES ● Implement context menus © Copyright. All rights reserved. 169 Unit 8 Lesson 1 Implementing Context Menus LESSON OVERVIEW This lesson explains how context menus are created, used, and modified. Business Example A travel agency needs to maintain the flight booking data for customers using different screens in the SAP application. You need to create context menus for the frequently used functions. For this reason, you require the following knowledge: ● How to create context menus in your programs LESSON OBJECTIVES After completing this lesson, you will be able to: ● Implement context menus Context Menus Figure 138: Context Menus If context menus are set up, users can see the menu when they right-click on the screen or press SHIFT + F10. These menus are shortcuts for frequently used functions. © Copyright. All rights reserved. 170 Lesson: Implementing Context Menus Use context menus to display context-sensitive menus. The context is defined by the position at which the user right-clicks to call the context menu. The user can select the functions that are relevant for the current context using the context menu. Determine whether you need to offer a context menu when creating screen objects, screens, input fields, table controls, boxes, and other objects. When the user selects a context menu on an object, an event mechanism (as understood by ABAP objects) calls up and delivers a menu reference to a subroutine in the application program. You can use menus defined with the Menu Painter and dynamic menus. The program uses the menu reference to build the display menu. Context menus are assigned to input/output fields. When you assign a context menu to a box, table control, or screen (normal or subscreen), the subordinate input/output fields without a context menu inherit that context menu. Context Menu Creation Figure 139: Creating a Context Menu Create context menus from the object list of the Object Navigator. Right-click GUI status. The Object Navigator automatically opens the Menu Painter. Alternatively, 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 the Context menu status type. © Copyright. All rights reserved. 171 Unit 8: Context Menus Assignment of Functions Figure 140: Creating a Context Menu – Assigning Functions You can link any function codes and texts in a context menu. For input help, use the functions provided in the interface. The link technique ensures consistent context menus in large applications. Consider the following rules when designing context menus: ● Do not use any function that cannot be found elsewhere in the system. ● 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 visually. ● Place object-specific statements at the beginning of the menu. © Copyright. All rights reserved. 172 Lesson: Implementing Context Menus Linking of Screen Objects Figure 141: Linking Screen Objects When you right-click on screen, a callback routine is triggered in your program. Create the respective callback routines in your application program. They are named as ON_CTMENU_<arbitrarily>. Determine which callback routine is called in the Screen Painter, either in the screen attributes or in the general attributes of a screen element. 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. Although a callback routine is assigned to a table control, it is triggered for all fields of the table control that do not have their own callback routine. In the e exxample sho shown wn in the figur figure e, the c callb allback ack rroutine outine ttak ake es the ffollo ollowing wing fform: orm: FORM ON_CTMENU_USING p_menu TYPE REF TO cl_ctmenu. ENDFORM. Create the structure of the context menu by loading a statically defined menu or by adding entries dynamically with methods of class CL_CTMENU. © Copyright. All rights reserved. 173 Unit 8: Context Menus Use of the Context Menu Figure 142: Using the Context Menu When you right-click on an output field, the corresponding callback routine is triggered. Use the static method LOAD_GUI_STATUS of class CL_CTMENU to load a context menu that was predefined in the Menu Painter. In addition to the static method, the class CL_CTMENU provides a number of methods that enable you to completely rebuild the context menu or modify a loaded menu. If a user triggers a function in the context menu, the corresponding function code is placed in the command field and triggered. Dynamic Modification of Context Menus The following table lists the methods you can use to modify context menus dynamically: Table 9: Methods Use to Modify Context Menus Dynamically CALL METHOD <instance> -> <name> EXPORTING ... Method Me Meaning aning ADD_FUNCTION Add a function ADD_SEPARATOR Add a separator HIDE_FUNCTIONS Hide functions SHOW_FUNCTIONS Show functions DISABLE_FUNCTIONS Disable functions ENABLE_FUNCTIONS Enable functions © Copyright. All rights reserved. 174 Lesson: Implementing Context Menus Use the other methods of class CL_CTMENU to adjust the context menu at runtime, for example, adjusting the context menu depending on the values in data fields. The corresponding methods are called in the callback routine. For more information, see the documentation for class CL_CTMENU in the Class Builder. LESSON SUMMARY You should now be able to: ● Implement context menus © Copyright. All rights reserved. 175 Unit 8 Learning Assessment 1. To which of the following UI elements can you assign a context menu? Choose the correct answer. X A Input/output X B Special hidden 2. Context menus can be modified dynamically. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 176 Unit 8 Learning Assessment - Answers 1. To which of the following UI elements can you assign a context menu? Choose the correct answer. X A Input/output X B Special hidden You are correct! Context menus are assigned to input and output fields. When you assign a context menu to a box, table control, or screen (normal or subscreen), the subordinate input or output fields without a context menu inherit that context menu. Read more in the lesson, Implementing Context Menus, Task: Context Menus, in the course BC410 (Unit 8, Lesson 1). 2. Context menus can be modified dynamically. Determine whether this statement is true or false. X True X False You are correct! Dynamic Modification of Context Menus can be done with methods of class CL_MENU. Read more in the lesson, Implementing Context Menus, Task: Dynamic Modification of Context Menus, in the course BC410 (Unit 8, Lesson 1). © Copyright. All rights reserved. 177 UNIT 9 Splitter Control Lesson 1 Implementing Splitter Control 179 UNIT OBJECTIVES ● Implement splitter control © Copyright. All rights reserved. 178 Unit 9 Lesson 1 Implementing Splitter Control LESSON OVERVIEW This lesson explains how splitter controls are created, used, and modified. Business Example A travel agency needs to maintain the flight booking data for its customers by using screens in the application. To display additional information on the screens, you need to create and use a screen that is split into two parts, for example, you can display all the flights on one side and the detail of each flight on the other side. For this reason, you require the following knowledge: ● An understanding of how the screen area can be split ● How to create and use splitter control LESSON OBJECTIVES After completing this lesson, you will be able to: ● Implement splitter control Splitter Control A splitter control is a screen element that divides an area into two subscreen areas, either horizontally beside each other, or vertically, one above the other. The division is made by a sash. Figure 143: Using Sashes to Divide a Screen © Copyright. All rights reserved. 179 Unit 9: Splitter Control The horizontal or vertical position of the sash is specified statically in the definition of the splitter control. It can be set to PBO in the ABAP program and changed by the user while the screen is being displayed. Attributes of Splitter Control You can set the position of the sash line in General Attributes . The sash position is specified as a percentage and refers to the width or height of the splitter control. You can also define the orientation of the split as horizontal or vertical in Splitter Attributes. The two cells can be resized if you define the resize attribute. Figure 144: Splitter Control Attributes Subscreen Creation In each cell you define a subscreen (splitter cell left/top and splitter cell right/bottom). Inserting subscreen dynpros into both subscreen areas takes place in exactly the same way as direct insertion using the CALL SUBSCREEN statement in the dynpro flow logic. Any subscreens can be inserted, particularly those that contain splitter controls again. A splitter control can have a function code assigned to it, which can be used to react to changes to the sash position made by the user in ABAP programs. © Copyright. All rights reserved. 180 Lesson: Implementing Splitter Control Figure 145: Create Two Subscreens Splitter Control Configuration A splitter control can only be created in the Alphanumeric Screen Painter . For this reason it should only be used in cases when the functionality offered is required on classic dynpros. The Screen Painter has a Layout Editor with two modes: ● Graphical mode (available only on Windows platforms) ● Alphanumeric mode Both modes offer the same functions but use different interfaces. In the graphical mode, you use a drag and drop interface similar to a drawing tool. In the alphanumeric mode, you use your keyboard and menus. To activate the alphanumeric mode, in the Screen Painter choose Utilities → Settings → Graphical layout editor . © Copyright. All rights reserved. 181 Unit 9: Splitter Control Figure 146: Setting the Layout Editor Mode The Alphanumeric Fullscreen Editor uses alphanumeric characters to display graphical elements. It has the same functions as the Graphical Layout Editor . The difference between the two is in the way you create graphical elements and in the way they are displayed on the screen. Note: You normally use the Alphanumeric Layout Editor in cases when it is not possible to use the Graphical Layout Editor , that is, when you use a non-Windows platform, a non-Windows SAP GUI, an outdated SAP GUI for Windows, or SAP systems protected by a firewall. The CL_DYNPRO_SPLITTER Class In ABAP programs, the position of the sash of a splitter control is controlled using an instance of the CL_DYNPRO_SPLITTER class. © Copyright. All rights reserved. 182 Lesson: Implementing Splitter Control Figure 147: Create Object Reference with CL_DYNPRO_SPLITTER CL_DYNPRO_SPLITTER Class Methods Important methods of the class are as follows: ● GET_GUISASH For PAI, GET_GUISASH sets the sash position of the object to the current value of the bound splitter control. ● SET_SASH If no value is passed at the POSITION parameter, the method for PBO sets the sash position of the bound splitter control to the value of the object. If a value is passed at the POSITION parameter, the method for PBO sets the attribute of the object and the sash position of the bound splitter control to this value. For PAI, only the attribute of the object is set. ● GET_SASH GET_SASH gets the sash position of the bound splitter control for PBO and PAI. © Copyright. All rights reserved. 183 Unit 9: Splitter Control Figure 148: Create PBO and PAI Module for SET_SASH LESSON SUMMARY You should now be able to: ● Implement splitter control © Copyright. All rights reserved. 184 Unit 9 Learning Assessment 1. You can define the orientation of splitting by setting it to horizontal or vertical in the element list of the screen. Determine whether this statement is true or false. X True X False 2. A splitter control can only be created in the alphanumeric Screen Painter. Determine whether this statement is true or false. X True X False 3. In ABAP programs, the position of the sash of a splitter control is controlled using an instance of the CL_DYNPRO_SPLITTER class. Determine whether this statement is true or false. X True X False © Copyright. All rights reserved. 18 185 5 Unit 9 Learning Assessment - Answers 1. You can define the orientation of splitting by setting it to horizontal or vertical in the element list of the screen. Determine whether this statement is true or false. X True X False You are correct! A splitter control is a screen element that divides an area into two subscreen areas, either horizontally beside each other, or vertically, one above the other. The division is made by a sash. The horizontal or vertical position of the sash is specified statically in the definition of the splitter control. It can be set to PBO in the ABAP program and changed by the user while the screen is being displayed. Read more in the lesson, Implementing Splitter Control, Task: Splitter Control, in the course BC410 (Unit 9, Lesson 1). 2. A splitter control can only be created in the alphanumeric Screen Painter. Determine whether this statement is true or false. X True X False You are correct! A splitter control can only be created in the Alphanumeric Screen Painter. Read more in the lesson, Implementing Splitter Control, Task: Splitter Control Configuration, in the course BC410 (Unit 9, Lesson 1). 3. In ABAP programs, the position of the sash of a splitter control is controlled using an instance of the CL_DYNPRO_SPLITTER class. Determine whether this statement is true or false. X True X False You are correct! In ABAP programs, the position of the sash of a splitter control is controlled using an instance of the CL_DYNPRO_SPLITTER class. Read more in the lesson, Implementing Splitter Control, Task: The CL_DYNPRO_SPLITTER Class, in the course BC410 (Unit 9, Lesson 1). © Copyright. All rights reserved. 186