Anda di halaman 1dari 26

IBM Global Services

Table Control

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

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

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

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

Change/save table settings Automatic horizontal/vertical scrolling

IBM Global Services

Table Control (Contd.)


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
4 Table Control | 6.15 March-2005 2005 IBM Corporation

Change/save table settings Automatic horizontal/vertical scrolling

IBM Global Services

Creating a Table Control

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Creating a Table Control


In the Screen Element Attributes window, assign a name to the table control and set initial (static) attributes. Some attributes are With column headers, Resizing, Separators, With title, Line selection column, No of fixed columns etc.

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Creating Table Control Fields

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Creating Table Control Fields (Contd.)

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Adding a table title

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Creating Table Control: Fields Selection Column

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

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Creating Table Control


Declare CONTROLS statement with type TABLEVIEW. The user can modify the Table Control attributes at runtime. Use REFRESH CONTROL <table control> FROM SCREEN <screen> to reset a table control to its initial attributes.

********************************* * INCLUDE SAPMZxxxTOP * ********************************* CONTROLS: ITEMS TYPE TABLEVIEW USING SCREEN '9005'.

Type TABLEVIEW has a complex structure containing individual fields and an internal table

11

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Processing Table Control


A Table control can be processed with or without an internal table:

*Processing without an internal table*

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

der hea with

12

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Defining Elements of a Table Control


ABAP Dictionary fields Fields from a program New table column

2005 IBM Corporation

IBM Global Services

Declare Table Control To declare table control, use the syntax found below:
CONTROLS <tab_ctrl_name> TYPE TABLEVIEW USING SCREEN <screen_no>.

2005 IBM Corporation

IBM Global Services

Processing Table Control Through Loop Endloop

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

IBM Global Services

Using LOOP Statements


Syntax:
LOOP AT <itab> CURSOR <scroll-var> [WITH CONTROL <table-control> ] [FROM <line1> ] [TO <line2> ]. <action> ENDLOOP.

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

IBM Global Services

Fields in a Table Control

2005 IBM Corporation

IBM Global Services

Process Table Control with Other Screen Elements


Sort

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.

2005 IBM Corporation

IBM Global Services

Processing Table Control (Contd.)


*Processing with an internal table* PROCESS BEFORE OUTPUT. LOOP AT itab WITH CONTROL items CURSOR items-CURRENT_LINE. ENDLOOP. PROCESS AFTER INPUT. LOOP AT itab WITH CONTROL items. MODULE ctrl_pai. ENDLOOP.

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

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Field Transport in Table Controls


PBO Transport ABAP table control fields to screen fields Transport remaining ABAP fields to screen fields PAI Transport all fields except table control and FIELD statement fields Transport table control fields Transport fields in FIELD statements

20

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Creating Table Control Variants

21

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Demonstration
Creating a program to display the data in the YMOVIE table using a table control.

22

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

Practice
Creating a program to display the data in the YMOVIE table using a table control.

23

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

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

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

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

Table Control | 6.15

March-2005

2005 IBM Corporation

IBM Global Services

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

Table Control | 6.15

March-2005

2005 IBM Corporation

Anda mungkin juga menyukai