Control Framework and GUI Controls

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

A classic dynpro is made of simple screen elements: input fields, checkboxes, pushbuttons and tables that SAP GUI draws for you. Some things cannot be drawn that way: a sortable grid with a toolbar, a tree that opens and closes, a multi-line text editor, a small web browser. SAP solved this with GUI controls. A GUI control is a ready-made piece of user interface that lives in SAP GUI on the user’s own PC, while your ABAP program, which runs on the application server, tells it what to show through ordinary ABAP objects. The part of the system that carries these instructions from the server to the PC and the user’s clicks back is called the Control Framework. After reading this page you can explain how a control is created and where its parts run, put an ALV grid in a container on a screen, handle a double click and a context menu, avoid the timing mistakes that the buffering of method calls causes, and tell when none of this applies. The page is written against Standard ABAP release 8.16 and the SAP Control Framework documentation of ABAP Platform 2025 (SAP S/4HANA 2025 FPS02). GUI controls exist only in classic ABAP with SAP GUI, in S/4HANA on premise and Private Edition and in older systems. They are not available in ABAP for Cloud Development (release 9.20, 2608), in the Public Edition of SAP S/4HANA Cloud or in Fiori apps, which use Fiori elements and RAP instead. Every listing needs an SAP system with SAP GUI, so each one is labelled as not run here.

Before you read

  • Dynpros, Module Pools and Transactions: screens, PBO and PAI, dialog modules, the OK field and the Screen Painter, which you use to reserve the area of a control.

  • Classes and Objects: every control is an object that you create with CREATE OBJECT or NEW and whose methods you call.

  • Events: a control tells your program about a click through an object event and SET HANDLER.

  • Internal Tables: the grid, the text editor and the tree exchange their data with internal tables.

  • ALV (SAP List Viewer): the object model CL_SALV_TABLE that SAP recommends instead of the ALV grid control that this page uses as its main example.

Key terms

  • Control Framework: the set of ABAP classes and front-end services that create GUI controls, call their methods and pass their events to your program.

  • GUI control: a user interface element that runs in SAP GUI on the user’s PC and that your program drives from the application server.

  • Container control: a control whose job is to hold other controls and to give them an area on the screen, for example the custom container.

  • Automation queue: the buffer in which the Control Framework collects method calls and sends them to the PC in one go.

  • System event: a control event that is passed to its handler at once, before field checks and without PAI and PBO.

  • Application event: a control event whose handler is called later, when you call cl_gui_cfw=>dispatch in a PAI module.

  • ALV: the SAP List Viewer, which shows an internal table as an interactive table; its grid control is the best known GUI control.

Screen elements and GUI controls

A normal screen element, such as an input field, belongs to the dynpro. SAP GUI draws it and the dynpro mechanism of PBO and PAI moves its value between the screen and your program. A GUI control is different in three ways. It is not a field of the dynpro, but a separate piece of software on the PC, which the SAP documentation calls an automation server. It is not filled through field names but through method calls on an object. And its data are not transported by PAI: you pass data into it with a method and fetch data out of it with another one.

The SAP documentation describes the arrangement like this. The application logic runs on the application server and acts as the automation client. It drives the custom control, the automation server, at the front end. Depending on the SAP GUI in use, a control is an ActiveX control or a JavaBean. The classes CL_GUI_CFW, CL_GUI_OBJECT and CL_GUI_CONTROL let ABAP create and destroy controls, set and read their attributes and call their methods. Everything that travels between the server and the PC passes two central parts, the Automation Controller at the front end and the ABAP Objects Control Framework at the back end.

flowchart LR subgraph AS[Application server] P[Your ABAP program
PBO and PAI modules] W[Control wrapper class
for example CL_GUI_ALV_GRID] F[ABAP Objects
Control Framework] Q[Automation queue
buffered method calls] P --> W --> F --> Q end subgraph PC[User's PC with SAP GUI] A[Automation Controller] C[GUI control
grid, tree, editor] A --> C end Q -- "sent at a synchronization point" --> A C -- "events that you registered" --> F

Read the diagram from left to right. Your program never talks to the PC directly. It calls a method of a wrapper object, the Control Framework notes the call in the automation queue, and only at a synchronization point is the queue sent to the PC in a single step. The reverse way is the event: an action of the user in the control reaches the Automation Controller, which ignores it unless your program registered that event, and otherwise forwards it so that a handler method of your program runs. A control therefore exists in two places at once, as an object in the program and as a visible element on the PC. Many of the typical mistakes below come from forgetting this.

The SAP documentation lists the standard controls. This page treats those that a newcomer meets most often.

Control Class What it is for

ALV grid

CL_GUI_ALV_GRID

A table with sorting, filtering and a toolbar.

Tree

CL_GUI_SIMPLE_TREE, CL_GUI_COLUMN_TREE, CL_GUI_LIST_TREE

A hierarchy of nodes that opens and closes.

Text editor

CL_GUI_TEXTEDIT

A multi-line editor, also usable as a code editor.

HTML viewer

CL_GUI_HTML_VIEWER

Shows HTML pages and pictures using the browser component of the PC.

Picture

CL_GUI_PICTURE

Shows a graphic.

Toolbar

CL_GUI_TOOLBAR

A row of pushbuttons and menus.

Containers: where a control lives

Every control needs a place on the screen, and the place is given by a container, which is itself a control. A container holds other controls, manages them as a collection and provides the physical area in which they are drawn. The container is the parent of the controls inside it, and containers can be nested. All containers derive from one basic class, so they have the same object interface. The SAP documentation names five kinds.

Container Class Where the controls appear

Custom container

CL_GUI_CUSTOM_CONTAINER

In an area that you reserve on a normal dynpro with the Screen Painter.

Docking container

CL_GUI_DOCKING_CONTAINER

At one of the four edges of the screen, as an area that the user can resize and detach.

Dialog box container

CL_GUI_DIALOGBOX_CONTAINER

In a modeless dialog box or on the full screen.

Splitter container

CL_GUI_SPLITTER_CONTAINER

In the cells of a grid of cells that divides an area.

Easy splitter container

CL_GUI_EASY_SPLITTER_CONTAINER

In the two cells of an area divided in two.

The two you need first are the custom container and the docking container.

The custom container. In the graphical Screen Painter you draw a custom control area on the dynpro, the icon marked with the letter C, and give it a name, for example CC_CLAIMS in the layout of the running example. In your program you create the container with that name in the parameter container_name. The name in the program and the name in the Screen Painter must be identical, or the creation fails at run time. The area has a fixed place and size in the layout of the screen, so it behaves like any other screen element.

The docking container. A docking container needs no area in the layout. It attaches to the left, top, bottom or right edge of the screen and makes the screen smaller to give itself room. You choose the edge with a constant of the class, for example dock_at_bottom, and the user can detach the container so that it floats as its own window and attach it again. The documentation notes that docking containers attach from the inside out: the second container attaches to the edge and pushes the first one outwards. Technically you may attach any number, but too many make the application confusing.

A control placed in a container is as large as its container by default. A container that you create without a parent is placed on the current dialog level, which the documentation calls a top-level container, screen0 to screen9, and it can be shown only at the dialog level to which it belongs. When the system leaves that level, it destroys all controls of that level. To show or hide a control dynamically, call set_visible; the children of an invisible parent are invisible too.

Creating a control: the standard pattern

The documentation describes one process that applies to every control. First you declare reference variables for the container and the control. Then you create the container, which needs the area of the Screen Painter for a custom container, and then the control with the container as its parent. You do this once, in the PBO of the screen, guarded by a test that the container does not yet exist, because PBO runs again after every user action and you must not create a second grid on top of the first.

The running example is a screen 0200 that shows the claims of the claim dialog in an ALV grid. The screen has a custom control area CC_CLAIMS and its flow logic calls two modules:

PROCESS BEFORE OUTPUT.
  MODULE status_0200.

PROCESS AFTER INPUT.
  MODULE exit_0200 AT EXIT-COMMAND.
  MODULE user_command_0200.

Requires an SAP system; not run here. The flow logic is typed in the Screen Painter, not in an editor of the program.

The program creates the container and the grid in the PBO module and passes the table to the grid:

REPORT zexp_claim_list.

DATA: gt_claims    TYPE STANDARD TABLE OF zexp_claim WITH EMPTY KEY,
      go_container TYPE REF TO cl_gui_custom_container,
      go_grid      TYPE REF TO cl_gui_alv_grid,
      ok_code      TYPE sy-ucomm.

START-OF-SELECTION.
  SELECT * FROM zexp_claim INTO TABLE @gt_claims.
  CALL SCREEN 0200.

MODULE status_0200 OUTPUT.
  SET PF-STATUS 'MAIN'.
  SET TITLEBAR 'T200'.

  IF go_container IS INITIAL.
    go_container = NEW #( container_name = 'CC_CLAIMS' ).
    go_grid = NEW #( i_parent = go_container ).
    go_grid->set_table_for_first_display(
      EXPORTING i_structure_name = 'ZEXP_CLAIM'
      CHANGING  it_outtab        = gt_claims ).
  ENDIF.
ENDMODULE.

MODULE exit_0200 INPUT.
  LEAVE TO SCREEN 0.
ENDMODULE.

MODULE user_command_0200 INPUT.
  DATA(save_ok) = ok_code.
  CLEAR ok_code.

  CASE save_ok.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
    WHEN 'REFRESH'.
      SELECT * FROM zexp_claim INTO TABLE @gt_claims.
      go_grid->refresh_table_display( ).
  ENDCASE.
ENDMODULE.

Requires an SAP system; not run here. It needs the table ZEXP_CLAIM, the screen 0200 with the area CC_CLAIMS and a GUI status MAIN with the function codes BACK and REFRESH, and it needs SAP GUI to draw the grid.

Four details of the listing come from the SAP documentation. The parameter i_parent makes the container the parent of the grid. The test IS INITIAL makes the creation run once. set_table_for_first_display receives the output table and either a reference structure of the ABAP Dictionary, here i_structure_name = 'ZEXP_CLAIM', from which the grid builds its column description, or a field catalog. The method must be called only once after the grid is created, and a second time only if the structure of the table changes; for new data you call refresh_table_display, as the REFRESH function does. The output table must be global or a public attribute of a class, because the grid keeps a reference to it for as long as it works. Finally, you did not call anything to make the grid appear: the Control Framework synchronizes automatically at the end of PBO, as the next sections explain.

Controls are destroyed by lifetime management when their lifetime ends, so the listing frees nothing. If you want to destroy a control yourself, call free on the control first and then on its container, and then delete the references. Destroying a container destroys the controls in it, and destroying a control twice raises an error, which you can avoid by asking is_alive first.

Lifetime of a control

When you create a control you decide how long it lives, with the parameter lifetime. The SAP documentation names three settings:

  • lifetime_imode: the control lives as long as the internal session, that is until a statement such as LEAVE PROGRAM ends it. Afterwards the method finalize is called.

  • lifetime_dynpro: the control lives as long as the dynpro instance, meaning as long as it is in the dynpro stack. Afterwards the method free is called. This mode also controls visibility: the control is visible only while the dynpro on which it was created is active.

  • lifetime_default: a control in a container inherits the lifetime of the container; a control without a container gets lifetime_imode.

The lifetime of a control may be shorter than that of its container, never longer. The default is the right choice in most programs. Keep one consequence in mind: when the system leaves a dialog level, lifetime management destroys the controls of that level, but your global reference variables still hold their old values. A program that comes back to a screen therefore asks is_alive before it reuses a control, or it frees the control and clears the references when it leaves the screen, so that the test IS INITIAL creates everything again.

The automation queue and flush

Sending a message from the server to the PC for every method call would make a screen slow. The Control Framework therefore collects the calls in the automation queue and sends them together at a synchronization point. The number of synchronization points is critical for the speed of the application. The system synchronizes automatically at the end of every PBO event and after a handler method for a system event has run. You can synchronize at any time with the static method cl_gui_cfw=>flush.

The queue has one consequence that surprises beginners. A method that returns a value does not return it at once. The address of your variable is noted in the queue, and the value is written into it at the synchronization. So after you call a method such as get_text_as_r3table, the variable is still empty until a flush has happened:

DATA lt_text TYPE STANDARD TABLE OF text72 WITH EMPTY KEY.

go_editor->get_text_as_r3table( IMPORTING table = lt_text ).
cl_gui_cfw=>flush( ).

" Only here does lt_text hold the text of the editor.
DATA(line_count) = lines( lt_text ).

Requires an SAP system; not run here. go_editor is the text editor control of the section below, and TEXT72 is a Dictionary data element of 72 characters.

The documentation adds a rule of thumb. Group the calls of one PBO or PAI step in two parts: first buffered calls that get the attributes you need, one synchronization, then your processing, then buffered calls that set attributes, and a second synchronization. Two synchronizations then serve all controls of the screen. The variables that receive values must still exist at the synchronization: a local variable of a subroutine that has ended no longer exists, and the resulting runtime error does not show up in the debugger, so use global variables or attributes of an object for such calls.

Events: system events and application events

A user action in a control, for example a double click, is an event of the control. The Control Framework passes it to your program only when you registered it. The SAP documentation describes two ways of processing a registered event, and the choice is part of the registration.

System event Application event

When the handler runs

At once, before automatic field checks and before field transport

At the end of PAI, or at the point where you call cl_gui_cfw=>dispatch

PAI and PBO

Not triggered

Triggered, so all fields are checked and transported

Values the user just typed

Not available

Available

Changes you make on the screen

Not shown, because there is no field transport

Shown after the next PBO

sequenceDiagram participant U as User at the PC participant C as GUI control participant A as Automation Controller participant F as Control Framework participant H as Handler method U->>C: double click C->>A: event alt event not registered A-->>C: ignored else registered as system event A->>F: OK code of the event F->>H: called at once H-->>F: may set a new OK code else registered as application event A->>F: OK code of the event Note over F: PAI runs, fields are checked F->>H: called by cl_gui_cfw=>dispatch end

To process an event you do four things. You create a handler method as a method of a local class, either static or instance based, and give it a FOR EVENT declaration. You register the event with the Control Framework by filling an internal table of the type cntl_simple_events with the event id and the flag appl_event, and by calling set_registered_events. You register the handler with SET HANDLER. For application events you finally call cl_gui_cfw=>dispatch in a PAI module, and it can be called only once per event, because the OK code of the event is used up by the call. The handler receives the parameter sender, the control that raised the event.

The ALV grid simplifies this. It is a wrapper around the grid control, and it registers all its events itself as system events when you create it, so you only need SET HANDLER. If you want all events as application events, pass the parameter i_appl_events and call cl_gui_cfw=>dispatch in PAI. The next listing reacts to a double click on a line of the grid. Because a system event does not run PAI, the handler cannot read the screen. It stores the selected claim in a global variable and asks the Control Framework to set the OK code SHOW, which makes the system run PAI and PBO as if the user had pressed a function key.

CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS on_double_click
      FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row e_column.
ENDCLASS.

DATA gs_selected TYPE zexp_claim.

CLASS lcl_handler IMPLEMENTATION.
  METHOD on_double_click.
    READ TABLE gt_claims INDEX e_row-index INTO gs_selected.
    IF sy-subrc = 0.
      cl_gui_cfw=>set_new_ok_code( new_code = 'SHOW' ).
    ENDIF.
  ENDMETHOD.
ENDCLASS.

Requires an SAP system; not run here. The class stands before the PBO module of the earlier listing. The handler is registered once, right after the grid is created, with the statement SET HANDLER lcl_handler=>on_double_click FOR go_grid. inside the IS INITIAL block. The OK code SHOW is then evaluated like any other function code in user_command_0200.

The events of the grid class that you will use most are double_click, hotspot_click for columns that you marked in advance, button_click for cells shown as pushbuttons, toolbar to change the toolbar, user_command for your own function codes, menu_button and context_menu_request.

The ALV grid control in more detail

The ALV grid control puts a toolbar, a title and a table on the screen. The user can sort, filter and rearrange without any code from you, and you adapt the behaviour with parameters of set_table_for_first_display. The SAP documentation lists among them a layout structure of the type LVC_S_LAYO for the properties of the grid, the table it_toolbar_excluding with the function codes of toolbar buttons to hide, a variant with the settings for saving layouts, and the changing parameters it_fieldcatalog, it_sort and it_filter. The function codes are constants of the class with the prefix MC_FC_.

DATA(ls_layout) = VALUE lvc_s_layo( zebra = 'X' cwidth_opt = 'X' ).
DATA(lt_exclude) = VALUE ui_functions(
  ( cl_gui_alv_grid=>mc_fc_help )
  ( cl_gui_alv_grid=>mc_fc_col_optimize ) ).

go_grid->set_table_for_first_display(
  EXPORTING i_structure_name   = 'ZEXP_CLAIM'
            is_layout          = ls_layout
            it_toolbar_excluding = lt_exclude
  CHANGING  it_outtab          = gt_claims ).

Requires an SAP system; not run here. It replaces the call in the IS INITIAL block of the earlier listing; zebra shades every second row and cwidth_opt sizes the columns to their content. The two function codes appear in the documentation of the context menu; the full list is in the class CL_GUI_ALV_GRID.

Context menus

The grid uses a context menu, opened with the right mouse button, and puts its standard functions in it. When the user opens it, the grid raises the event context_menu_request. Its parameter e_object holds the standard menu as an object of the class CL_CTMENU. You add your own entries with add_function, and you disable or hide standard entries by passing a table of function codes to disable_functions or hide_functions. You read the function code of one of your own entries in the event user_command.

CLASS lcl_menu_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_context_menu_request
        FOR EVENT context_menu_request OF cl_gui_alv_grid
        IMPORTING e_object,
      on_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
        IMPORTING e_ucomm.
ENDCLASS.

CLASS lcl_menu_handler IMPLEMENTATION.
  METHOD on_context_menu_request.
    e_object->add_function( fcode = 'APPROVE' text = 'Approve claim' ).
    e_object->disable_functions( fcodes = VALUE ui_functions( ( cl_gui_alv_grid=>mc_fc_help ) ) ).
  ENDMETHOD.

  METHOD on_user_command.
    IF e_ucomm = 'APPROVE'.
      MESSAGE 'Approve was chosen' TYPE 'S'.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

Requires an SAP system; not run here. The two handlers are registered with SET HANDLER lcl_menu_handler=>on_context_menu_request FOR go_grid. and the matching statement for on_user_command. The text of the entry is a literal only to keep the example short; a real program uses a text symbol, see Text Elements and Translation.

When not to use the grid control

The SAP documentation says plainly that it is no longer recommended to use the ALV grid control. SAP recommends the object model of the SAP List Viewer (class CL_SALV_TABLE) instead, because all functions of the grid control are available in it. You should use the grid control only if the object model cannot be used for technical reasons. The documentation also states two limits of the grid control: it cannot show block lists or hierarchical lists, and it cannot use tables that contain object references. A newcomer who needs a table on a screen therefore starts with the ALV object model; the grid control matters because a large number of existing programs use it, and you have to read and maintain them. Older books show it as the normal way to build a list screen. For a program that is being written today, they are outdated on this point.

Dropdown boxes on a dynpro

A dropdown box offers the user a predefined list of values from which to choose, instead of free typing. On a dynpro it is not a GUI control but a property of an ordinary input and output field, which makes it a good contrast to the controls above. You set the attribute Dropdown of the field in the Screen Painter to the value L (list box). The user then cannot type in the field, and cannot use the input help key, because a field with a dropdown box has no input help. A list box has one column of texts with at most 80 characters, and each text has an internal key of at most 40 characters. When the user chooses a line, the text appears in the field, and the key is passed to the dynpro field, so the two are not necessarily equal. If you assign a function code to the field, choosing a value raises PAI at once.

The attribute Value list of the screen element says where the lines come from. The recommended way, with an empty value list, uses the input help of the field: the first column supplies the texts, the second column the keys, so the search help should have two columns. The other way, with the value A, fills the list in a PBO module with the function module VRM_SET_VALUES. The documentation marks this way as not recommended, but it is common in old programs:

MODULE init_status_list OUTPUT.
  DATA(lt_values) = VALUE vrm_values(
    ( key = 'N' text = 'New' )
    ( key = 'S' text = 'Submitted' )
    ( key = 'A' text = 'Approved' ) ).

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = 'ZEXP_CLAIM-STATUS'
      values = lt_values.
ENDMODULE.

Requires an SAP system; not run here. The module is called in the PBO flow logic of a screen whose field ZEXP_CLAIM-STATUS has the dropdown attribute L and the value list attribute A. The three values are the status codes of the running example.

Tree, text editor and HTML viewer

The tree. The SAP Tree control shows hierarchies. It is a basic tree that SAP developed and that has not been adapted for specific applications. The documentation distinguishes three kinds: the simple tree, in which a node has a folder or leaf symbol and one text; the list tree, in which a node has several entries shown from left to right; and the column tree, in which the entries of a node are arranged in columns below headings. The matching classes are CL_GUI_SIMPLE_TREE, CL_GUI_LIST_TREE and CL_GUI_COLUMN_TREE, and the demonstration programs SAPSIMPLE_TREE_CONTROL_DEMO, SAPTLIST_TREE_CONTROL_DEMO and SAPCOLUMN_TREE_CONTROL_DEMO show each one in an SAP system. The point to remember is that the tree object holds no data of its own. You keep the tree structure in your program, and when an event arrives, the control passes only administrative data, such as the key of the node that was clicked. For this reason SAP also offers tree model classes (CL_SIMPLE_TREE_MODEL, CL_LIST_TREE_MODEL and CL_COLUMN_TREE_MODEL), which keep the node data in the program for you.

The text editor. CL_GUI_TEXTEDIT is an editor for several lines, with an optional toolbar and status bar. It can be used as a simple text editor or as an editor for ABAP code, and it supports find and replace, undo and redo, and import and export of local files. You pass text to and from the control with internal tables. The methods with the ending AS_R3TABLE work without line break information, the methods with AS_STREAM include it. The documentation warns that a table with shorter lines than the editor loses the rest of each line, so the line type must be as long as the editor lines. The next listing puts the editor in a docking container at the bottom of the screen, so that the claim handler can type a comment:

TYPES ty_line TYPE c LENGTH 72.

DATA: go_docking TYPE REF TO cl_gui_docking_container,
      go_editor  TYPE REF TO cl_gui_textedit,
      gt_comment TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.

MODULE init_editor OUTPUT.
  IF go_docking IS INITIAL.
    go_docking = NEW #( side      = cl_gui_docking_container=>dock_at_bottom
                        extension = 150 ).
    go_editor  = NEW #( parent             = go_docking
                        wordwrap_mode      = cl_gui_textedit=>wordwrap_at_fixed_position
                        wordwrap_position  = 72 ).
    go_editor->set_text_as_r3table( table = gt_comment ).
  ENDIF.
ENDMODULE.

Requires an SAP system; not run here. dock_at_bottom is a documented constant of the docking container with the value 4; the parameter extension is the height in pixels. To read the text after the user pressed Save, the program calls get_text_as_r3table followed by cl_gui_cfw=>flush, as in the listing of the automation queue.

The HTML viewer. CL_GUI_HTML_VIEWER shows HTML pages and graphics inside a screen. SAP has no browser of its own: the control uses the browser component of the PC. In SAP GUI for Windows that is a browser control such as the Internet Explorer control or the WebView2 control, which makes the look of a page depend on the PC. You create the viewer with a container as its parent, load an HTML page or a part of it with load_html_document or load_mime_object, and display it with show_url. Two events matter: SAPEVENT, raised when the user clicks a special link that is meant to call your program, and NAVIGATE_COMPLETE, raised when a page has loaded completely.

DATA: go_html_container TYPE REF TO cl_gui_custom_container,
      go_html           TYPE REF TO cl_gui_html_viewer.

MODULE init_help OUTPUT.
  IF go_html IS INITIAL.
    go_html_container = NEW #( container_name = 'CC_HELP' ).
    go_html = NEW #( parent = go_html_container ).
    go_html->show_url( url = 'https://help.sap.com' ).
  ENDIF.
ENDMODULE.

Requires an SAP system; not run here, and the PC also needs access to the address. The custom control area CC_HELP is an invented name of a second area in the screen layout.

Where GUI controls do not work

A control needs a PC with SAP GUI that can run it. This puts limits on its use.

  • SAP GUI for HTML. The documentation says certain methods and events of controls are not supported in SAP GUI for HTML, and others only in limited form. For example, in the list of events of the ALV grid, drag and drop and context_menu_request are marked as not usable there, and a number of methods of the HTML viewer, among them go_back, go_forward and get_current_url, are not available. Read the section of each control before you rely on a feature in a browser-based session.

  • SAP GUI for Java. Some functions of a control may not work there or may work with restrictions; the documentation of SAP GUI for Java lists them.

  • ABAP Cloud and the Public Edition. There are no dynpros and no SAP GUI controls in ABAP for Cloud Development. The same tasks are done with Fiori elements: a list report shows a table, and an object page shows the details of one entry. The RAP pages of this section describe how they are built.

  • Fiori and web interfaces. A control cannot be used in a Fiori app, because the control is a program of the PC and not part of the browser. A new user interface that must run in a browser uses SAPUI5 or Fiori elements, or, in older systems, Web Dynpro ABAP.

Common mistakes

  • Creating the control in every PBO. PBO runs after every action. Without the test IS INITIAL the program creates a second container and a second grid each time. Always guard the creation.

  • Using a different name for the custom control area. The name in container_name must match the area of the Screen Painter exactly.

  • Reading a value without a flush. After a getting method, the variable holds the value only after a synchronization. Call cl_gui_cfw=>flush before you use it.

  • Passing local variables to buffered calls. A variable that no longer exists at the synchronization causes a runtime error that the debugger does not show.

  • Reading the screen in a system event handler. A system event runs before field checks and field transport, so the values just typed are not available. Use an application event or set an OK code with set_new_ok_code and continue in PAI.

  • Calling set_table_for_first_display again for new data. Use refresh_table_display. The first method is for a changed structure only.

  • Giving a control a longer lifetime than its container. It is not allowed; use the default.

  • Starting a new program with the ALV grid control. SAP recommends CL_SALV_TABLE.

Summary

  • A GUI control is a piece of user interface that runs in SAP GUI on the PC; your ABAP program on the application server drives it through the Control Framework.

  • A control lives in a container: a custom container in an area of the Screen Painter, a docking container at a screen edge, and splitter or dialog box containers for other layouts. Create the container and the control once, in PBO, behind an IS INITIAL test.

  • Method calls are buffered in the automation queue and sent at synchronization points, which are the end of PBO, the end of a system event handler and a call of cl_gui_cfw=>flush; values that a method returns arrive only then.

  • Events must be registered, as system or application events. A system event runs at once without PAI; an application event runs with PAI and sees the screen values. The ALV grid registers its events as system events by itself.

  • The ALV grid control still exists in many programs but is no longer recommended; use the ALV object model for new code. Dropdown boxes are a property of a dynpro field, not a control.

  • GUI controls need SAP GUI, work with limits in SAP GUI for HTML and Java, and do not exist in ABAP Cloud or in Fiori.