CONTROLS (ABAP Keyword)

CONTROLS (ABAP Keyword) introduction & Details

CONTROLS

Basic
form
CONTROLS ctrl TYPE ctrl_type.

Effect
Defines a
control

A control defines an ABAP/4 runtime object which displays data in
a particular visual format, depending on the type. It offers the user standard
processing options.

At present, the following types of control are
supported:

ABAP/4 table control

Basic
form
CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.

Effect
Creates
a table control ctrl of the type TABLEVIEW . The reference screen for the
initialization is the screen scr .

Area of use

The table control
(referred to here as TC ) facilitates the display and entry of one-line, tabular
data in dialog transactions.
The functional scope has been defined so that
you can implement many typical set operations usually handled by an elementary
STEP-LOOP with the standard methods of a TC .

Functional
scope

Resizeable table grid for displaying and editing data.
Column
width and column position modifiable by user and by program.
Storing and
loading of user-specific column layout.
Selection column for line selection
with color selection display.
Variable column headers as pushbuttons for
column selection.
Simple selection, multiple selection, Select/deselect
all.
Scrolling functions (horizontal and vertical) via scroll bar.
Fixing
of any number of key columns.
Setting attributes for each cell at
runtime.

Programming

The data exchange between the application and
the SAPgui is achieved with a STEP-LOOP , i.e. an ABAP/4 module is called to
transfer data for each page.

Example
Processing without an internal
table

PROCESS BEFORE OUTPUT.
LOOP WITH CONTROL ctrl.
MODULE
ctrl_pbo.
ENDLOOP.

PROCESS AFTER INPUT.
LOOP WITH CONTROL
ctrl.
MODULE ctrl_pai.
ENDLOOP.

In this case, the module
ctrl_pbo OUTPUT is called once for each output line before the screen is
displayed, in order to fill the output fields.
After the user has entered
data on the screen, the module ctrl_pai INPUT is executed to check the input and
copy the new contents.

Example
Processing with an internal
table

PROCESS BEFORE OUTPUT.
LOOP AT itab WITH CONTROL ctrl CURSOR
ctrl-CURRENT_LINE.
ENDLOOP.

PROCESS AFTER INPUT.
LOOP AT itab WITH
CONTROL ctrl.
MODULE ctrl_pai.
ENDLOOP.

Here, the system fills
the output fields before displaying the screen by reading the internal table
itab .
When the user has entered data, the module ctrl_pai INPUT must be
executed to check the input and to refresh the contents of the internal
table.
Vertical scrolling with the scroll bar is followed by the event PAI
for the displayed page. Then, cntl-TOP_LINE is increased and PBO is processed
for the next page.
Program-driven scrolling and the most of the functionality
described above is achieved by manipulating the control
attributes.
Attributes

The CONTROLS statement creates a complex data
object of the type CXTAB_CONTROL with the name of the control.

You
maintain the initial values in the Screen Painter and assign the screen with the
initial values for a control using the addition USING SCREEN
.

Initialization is achieved automatically in the “1st access to the
control” (setting or reading values).

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.

All the
initial values can be overwritten by the program using the MOVE … TO TC
attributes statement.

Example
ctrl-fixed_cols = 2. “2 columns
fixed
The contents of the SCREEN structure (table Cols ) acts as a default
value for each line of this column, but within LOOP … ENDLOOP (flow logic), it
can be overwritten by LOOP AT SCREEN / MODIFY SCREEN .

With the
attributes listed below, you should be aware of the following:
LINES This
must always be set as the only attribute if you are not using LOOP AT itab
.
TOP_LINE Also set by the SAPgui through the vertical scroll bar
slider.
CURRENT_LINE Read only, set by the system ( TOP_LINE + SY-STEPL – 1
)
LEFT_COL Also set by the SAPgui through the horizontal scroll bar
slider.
COLS-INDEX Also set by the SAPgui after moving
columns.
COLS-SELECTED Also set by the SAPgui after column selection.
When
displaying the control, the system uses the current contents when the event DCO
occurs (i.e. after all PBO modules have run). The modified values (brought about
by the user making changes on the screen) are set immediately after DCI (i.e.
before the first PAI module runs).