Table Control
March-2005
Objectives
The participants will be able to:
Know the advantages of using a table control Create a table control in the Graphical Screen painter Setting attributes of the Table Control Paint fields for the table control Adding title to a table control Discuss about field selection column of a table control Program the processing of a table control Understand the field transport mechanism in the table control Create table control variants
March-2005
Table Control
Display data in tabular form. User configurable. Change multiple lines of a table together. Vertical/horizontal scrollbars. Choose any number of key (leading) columns to be fixed. Cell attributes can be modified during runtime. Storing and loading of userspecific column layout.
Fixed Leading Columns Change column width Mark columns/rows
3 Table Control | 6.15 March-2005 2005 IBM Corporation
March-2005
March-2005
March-2005
March-2005
March-2005
When creating a table control, the system automatically proposes a selection column. A selection column allows users to choose a line of the table control. The selection column elements behave like a checkbox. The field name must be entered in the attributes of the table control.
10
March-2005
********************************* * INCLUDE SAPMZxxxTOP * ********************************* CONTROLS: ITEMS TYPE TABLEVIEW USING SCREEN '9005'.
Type TABLEVIEW has a complex structure containing individual fields and an internal table
11
March-2005
Screen
Database
PROCESS BEFORE OUTPUT. LOOP WITH CONTROL items. MODULE ctrl_pbo. ENDLOOP. PROCESS AFTER INPUT. LOOP WITH CONTROL items. MODULE ctrl_pai. ENDLOOP.
ble al ta rn Inte
der der hea hea le with l with Tab nal Tab nal Inter Inter
12
March-2005
Declare Table Control To declare table control, use the syntax found below:
CONTROLS <tab_ctrl_name> TYPE TABLEVIEW USING SCREEN <screen_no>.
You can process the screen table using a LOOP statement by: Looping only through the screen table Looping through screen table and an internal table in parallel If you have table control in a screen, you must have LOOP ENDLOOP blocked both in PBO and PAI. SY-STEPL contains the current loop iteration.
2005 IBM Corporation
The FROM .. TO clause is for step loops When using step loops, omit the CURSOR parameter in the PAI event. The FROM and TO parameters are only possible with step loops. The WITH CONTROL parameter is only used with table controls. CURSOR contains the current cursor row
Use TC-CURRENT_LINE as the cursor
2005 IBM Corporation
Pushbutton Processing
Screen Painter
Layout Editor
Object Attributes Object name Object text FctCode button Sort SRTU FctType Element List Object name Type FctCode FctType button ok_code
SAP AG 1999
PROCESS AFTER INPUT. PROCESS AFTER INPUT. ... ... MODULE save_ok_code. MODULE save_ok_code. MODULE user_command_100. MODULE user_command_100. . . . . . .
Screen Painter
SRTU OK
DATA:ok_code LIKE sy-ucomm, DATA:ok_code LIKE sy-ucomm, save_ok LIKE ok_code. save_ok LIKE ok_code. ... ... MODULE user_command_100 INPUT. MODULE user_command_100 INPUT. CASE save_ok. CASE save_ok. WHEN 'SRTU'. WHEN 'SRTU'. SORT it_book by ... . SORT it_book by ... . . . . . . . ENDCASE. ENDCASE. ENDMODULE. ABAP ENDMODULE.
The fields in the table control and the internal table work area needs to have the same structure and names for automatic transport of data between the ABAP program and the screen.
19
March-2005
20
March-2005
21
March-2005
Demonstration
Creating a program to display the data in the YMOVIE table using a table control.
22
March-2005
Practice
Creating a program to display the data in the YMOVIE table using a table control.
23
March-2005
Summary
A table control is an area on the screen where the system displays data in a tabular form. It is processed using a loop. Lines in a table control may contain dictionary table fields, keywords, input/output fields, radio buttons, checkboxes, radio button groups, and pushbuttons. A line can be up to 255 columns wide. Each column may have a title. When creating a table control, the system automatically proposes a selection column. A selection column allows users to choose a line of the table control. When processing a table control in the program, you will also need to declare a CONTROLS statement with type TABLEVIEW (in the TOP INCLUDE of your program).
24
March-2005
Summary (Contd.)
A Table control can be processed with or without an internal table. You can use the Customizing button (in the top right corner) to save the current setting (column widths and column positions) and use it as the initial value for the next call.
25
March-2005
Questions
What is a table control ? Is it mandatory to use an internal table for processing a table control ? What are the primary advantages of using table control ?
26
March-2005