SAP ABAP Table Control with Examples
โก Smart Summary
SAP ABAP Table Control displays an internal table as a scrollable grid on a screen built in the Screen Painter. This page explains its features, the CONTROLS declaration, cursor handling, the PBO and PAI loops, and column attributes.

What is a Table Control in SAP ABAP?
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.
Features of ABAP Table Control
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 use
Table 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
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)
Transaction TZ60 above shows the finished result: a grid with column headers, separator lines, and a selection column. The differences from the older step loop are summarised next.
Table Control vs Step Loop
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). The table below compares the two screen elements.
| Criteria | Table Control | Step Loop |
|---|---|---|
| Row layout | One row is always one screen line | One row may span several screen lines |
| Column handling | Columns can be resized, reordered, and hidden by the user | Fixed column layout defined on the screen |
| Scrolling | Horizontal scrolling by the frontend, vertical scrolling programmed in PAI | Programmed entirely in the ABAP code |
| Declaration | CONTROLS … TYPE TABLEVIEW USING SCREEN | No control structure in the program |
| Display settings | The user can save a personal layout | Not available |
Because the table control is the modern element, the rest of this page programs that one.
How to Create and Program a Table Control
A table control needs a screen element, a control structure in the program, and a loop in both PBO and PAI. The subsections below follow that order.
Declaring the control
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:
CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>
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.
Setting and reading the cursor position
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.
Reading the corresponding internal table line
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
Creating the control in the Screen Painter
To create a table control
- Add a table control element to your screen
- Give a name to the table control. In the ABAP program declare a structure with the same ( CONTROLS <tcl> type TABLEVIEW USING SCREEN <scrn >)
- 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.
Coding the PBO and PAI loops
In the PBO you should have the statement
LOOP at <itab> USING CONTROL <cntrl_name>. ENDLOOP.
In the PAI you should have.
LOOP at <itab>. ENDLOOP.
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
โ ๏ธ Warning: The PBO loop must name the control with USING CONTROL. Without it the control does not know how many lines exist, and vertical scrolling stops working.
Changing column attributes at runtime
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.
๐ก Tip: Loop over <cntrl>-cols in the PBO to hide or protect a column for a given user role, rather than building a second screen.

