ABAP | Table Controls

Table controls and step loops are objects for screen table display that you add to a screen in the Screen Painter.

From a programming standpoint, table controls and step loops are almost exactly the same. Table controls are simply improved step loops that display data with the look and feel associated with tables in desktop applications.

With table controls, the user can:

  • Scroll through the table vertically and horizontally
  • Re-size the width of a column
  • Scroll within a field (when field contents are wider than the field)
  • Select table rows or columns
  • Re-order the sequence of columns
  • Save the current display settings for future useTable controls also offer special formatting features (some automatic, some optional) that make tables easier to look at and use. Table Control provides –
  • automatic table resizing (vertical and horizontal) when the user resizes the window
  • separator lines between rows and between columns (vertical and horizontal)
  • column header fields for all columns
    One feature of step loops is that their table rows can span more than one line on the screen. A row of a table control, on the other hand, must always be contained in a single line (although scrolling is possible).

In general, many of the features provided by the table control are handled locally by your system’s SAPgui frontend, so you do not need to program them yourself. The only notable exception to this is vertical scrolling.

Example (Transaction TZ60)

ABAP | Table Controls


To handle table controls in ABAP programs, you must declare a control in the declaration part of the program for each table control using the following statement:


where <ctrl> is the name of the table control on a screen in the ABAP program. The control allows the ABAP program to read the attributes of the table control and to influence the control .Here, <scr> is the screen number where the initial values of the table are loaded.

Cursor Position for a table control can be set in following ways:

At PBO you can set the cursor on a specific field of a specific row of a table control.

  • SET CURSOR FIELD <f> LINE <lin> [OFFSET <off>]

Using the optional addition OFFSET, you can enter the offset of the cursor in the field as described under Setting the Cursor Position.

At PAI you can read the current cursor position.

  • GET CURSOR FIELD <f> LINE <lin> …

In addition to the information given under Finding Out the Cursor Position, field <lin> contains information on which row of the table control the cursor is currently on. You can also use

  • GET CURSOR LINE <lin>.

to determine the row of the table control. SY-SUBRC allows you to check if the cursor is placed in a row of a table control.

For getting the corresponding line of the internal table :

  • GET CURSOR line <lin>.
  • ind = <table_control>-top_line + <lin> – 1.
  • Read table <itab> index ind.

The system variable stepl – contains the current table line index in a loop … endloop. Loopc – contains number of lines visible in the table

To create a table control

1. Add a table control element to your screen

2. Give a name to the table control. In the ABAP program declare a structure with the same ( CONTROLS <tcl> type TABLEVIEW USING SCREEN <scrn >)

3. To create fields go to the Dict./Program fields function.

  • Enter the name of the structure whose fields you want. (If you want it to pick it from dictionary of your program click the relevant puhbutton).
  • In the field list choose the fields you want and choose ok.
  • Click in the table control area
    If you want a selection column , check the appropriate check box in the attributes and give it a name. Create the field in the ABAP program.

In the PBO you should have the statement

  • LOOP at <itab> USING CONTROL <cntrl_name>.

In the PAI you should have.

  • LOOP at <itab>.

It is within the loops that data transfer happens between the screen and the internal table.When you populate the internal table use DESCRIBE TABLE <itab> LINES <cntrl_name>-lines, to store the total number of lines in the control.The FIELD statement can be used to control when the data transfer happens

To change the attributes of individual cells temporarily change the SCREEN table in the PBO. You can change the attributes of the structure created by the CONTROLS statement

  • <cntrl>-fixed_cols etc are the attributes of the control
  • <cntrl>-cols-index etc are the attributes of the columns.
  • <cntrl>-cols-screen-invisible etc are the screen attributes of each column.