sitemap
Table Controls
ABAP offers two mechanisms for displaying and using table data in a screen. These mechanisms are table controls and step
loops. Table controls and step loops are types of screen tables you can add to a screen in the Screen Painter. For example,
the following screen contains a table control at the bottom:


This chapter describes how to program the screen flow logic and ABAP code that let you use screen tables. For information
on using screen tables, see:

Table Controls in the Flow Logic

Looping Through an Internal Table
Systemfelder

Datentransports

The following statement loops through an internal table and a screen table in parallel.

LOOP AT <internal table>.

In particular, LOOP AT loops through the portion of the internal table that is currently visible in the screen. You can use this form of
the LOOP statement for both table controls and step loops.

The complete syntax for this form of the LOOP statement is:

LOOP AT <internal table> CURSOR <scroll-var>
                     [WITH CONTROL <table-control> ]
                     [FROM <line1> ]  [TO <line2> ].
...<actions>...
ENDLOOP.

This form of LOOP loops through the internal table, performing <actions> for each row. For each internal table row, the system
transfers the relevant program fields to or from the corresponding screen table row.

When using step loops, omit the CURSOR parameter in the PAI event. The FROM and TO parameters are only possible with step loops.
(For further information, refer to Using Step Loops.) The WITH CONTROL parameter is only for use with table controls.

For further information, refer to the following sections:

How the System Transfers Data Values

Scrolling and the Scroll Variables



Table Controls: Example with Browser


Table Controls: Examples with Scrolling

The following example processes a table control with LOOP without parallel loop using an internal table. In addition to the scroll bar,
the user can also carry out program-controlled scrolling with function codes.



REPORT demo_dynpro_tabcont_loop.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn,
fill TYPE i.

TABLES demo_conn.

DATA: lines TYPE i,
limit TYPE i.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
DESCRIBE TABLE itab LINES fill.
flights-lines = fill.
ENDMODULE.

MODULE fill_table_control OUTPUT.
READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
lines = sy-loopc.
MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'NEXT_LINE'.
flights-top_line = flights-top_line + 1.
limit = fill - lines + 1.
IF flights-top_line > limit.
 flights-top_line = limit.
ENDIF.
WHEN 'PREV_LINE'.
flights-top_line = flights-top_line - 1.
IF flights-top_line < 0.
 flights-top_line = 0.
ENDIF.
WHEN 'NEXT_PAGE'.
flights-top_line = flights-top_line + lines.
limit = fill - lines + 1.
IF flights-top_line > limit.
 flights-top_line = limit.
ENDIF.
WHEN 'PREV_PAGE'.
flights-top_line = flights-top_line - lines.
IF flights-top_line < 0.
 flights-top_line = 0.
ENDIF.
WHEN 'LAST_PAGE'.
flights-top_line =  fill - lines + 1.
WHEN 'FIRST_PAGE'.
flights-top_line = 0.
ENDCASE.
ENDMODULE.



Table Controls: Example with Modifications


Table Controls: Examples with Modifications

The following example processes a table control with LOOP with parallel loop using an internal table. By using function codes you can
sort columns and delete rows from the internal table. The ready for input status of the table control fields is controlled using a
function code.



REPORT demo_dynpro_tabcont_loop_at.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: cols LIKE LINE OF flights-cols,
lines TYPE i.

DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.

TABLES demo_conn.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT flights-cols INTO cols WHERE index GT 2.
cols-screen-input = '0'.
MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
DESCRIBE TABLE itab LINES lines.
flights-lines = lines.
ENDMODULE.

MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'TOGGLE'.
LOOP AT flights-cols INTO cols WHERE index GT 2.
 IF  cols-screen-input = '0'.
   cols-screen-input = '1'.
 ELSEIF  cols-screen-input = '1'.
   cols-screen-input = '0'.
ENDIF.
MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.
WHEN 'SORT_UP'.
READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
IF sy-subrc = 0.
 SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
 cols-selected = ' '.
MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDIF.
WHEN 'SORT_DOWN'.
READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
IF sy-subrc = 0.
 SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
 cols-selected = ' '.
MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDIF.
WHEN 'DELETE'.
READ TABLE flights-cols INTO cols
                       WITH KEY screen-input = '1'.
IF sy-subrc = 0.
 LOOP AT itab INTO demo_conn WHERE mark = 'X'.
   DELETE itab.
ENDLOOP.
ENDIF.
ENDCASE.
ENDMODULE.


A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in
the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, columns headers,
and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to
the selection column. You can select one column and several lines.

It has the following flow logic:

PROCESS BEFORE OUTPUT.
MODULE status_0100.
LOOP AT itab INTO demo_conn WITH CONTROL flights.
ENDLOOP.

PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP AT itab.
MODULE read_table_control.
ENDLOOP.
MODULE user_command_0100.

A loop is executed at PBO and PAI using the table control FLIGHTS and is also executed using the internal table ITAB of the ABAP
program. During the PBO loop, no module is called to fill the table control from table ITAB of the ABAP program. However, during the
PAI loop, a module is called to modify table ITAB.

At PBO the component LINES of control structure FLIGHTS is filled explicitly with the current number of rows of the internal table
before the PBO loop to install the scroll bar of the table control.

During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table,
where the row index corresponds to the current row of the table control.

During the PAI loop, the rows of the internal table, whose row index corresponds to the current row of the table control, are
overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the
internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control
is selected or not.

After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate
function codes.

When the program is called not all of the fields in the table control are ready for input. The static specifications of the table control in
the Screen Painter are modified before CALL SCREEN in the program. The system uses the table COLS in control structure FLIGHTS.
All columns with a column position larger than two are set to not ready for input status in a loop using the table FLIGHT-COLS. By
choosing the function code TOGGLE, you can change the ready for input status of the columns.

The function codes SORT_UP and SORT_DOWN allow you to sort selected columns of the internal table ITAB ascending or
descending. The static settings of the table control allow you to select only a single column. The selected column is derived from the
internal table FLIGHT-COLS. The name of the sort criteria in the SORT statement is determined dynamically from the component
COLS-SCREEN-NAME. The prefix DEMO_CONN- must be removed using an offset specification. After sort the selection is undone, and
the component SELECTED in table FLIGHT-COLS is assigned a blank character.

You can delete selected rows from the internal table ITAB using the function code DELETE. First the system checks whether the fields
of the table control are ready for input. Then all selected rows are deleted in a loop using the internal table ITAB. Since the table
control is read again from the internal table in the PBO loop, the rows on the screen are deleted.






Using the LOOP Statement



Using the LOOP Statement

Screen Painter

The LOOP...ENDLOOP screen command lets you perform looping operations in the flow logic. You can use this statement to loop
through both table controls and step loops. Between a LOOP and its ENDLOOP, you can use the FIELD, MODULE, SELECT, VALUES
and CHAIN screen keywords. Most often, you use the MODULE statement to call an ABAP module.

You must code a LOOP statement in both the PBO and PAI events for each table in your screen. This is because the LOOP statement
causes the screen fields to be copied back and forth between the ABAP program and the screen field. For this reason, at least an
empty LOOP...ENDLOOP must be there.

There are two important forms of the LOOP statement:

LOOP.
This statement loops through screen table rows, transferring the data in each block to and from the corresponding ABAP fields in your
program. The screen table fields may be declared in ABAP as anything (database table, structure or individual fields) except as
internal table fields.

With step loops, if you are implementing your own scrolling (for example, with F21 - F24 ) you must use this statement.

LOOP AT <internal table>.
This statement loops through an internal table and the screen table rows in parallel. The screen table fields often are, but need not be,
declared as internal table fields.

With this LOOP, step loop displays appears with scroll bars. This scrolling is handled automatically by the system.

For more details on the different LOOP statements, see:

Looping Directly Through a Screen Table

Looping Through an Internal Table





Using Step Loops


Appendix: The Step Loop Technique

Table controls are processed using the step loop technique.

Step loops are the predecessors of table controls. They should no longer be used. Existing step loops can be changed to table controls
in the Screen Painter. For the sake of completeness and to explain the technique of data transfer between tables on the screen and
the ABAP program, step loops - and specifically the step loop technique - are explained here.

Like table controls, step loops are screen elements for displaying table-type data on a screen. From a programming standpoint,
especially concerning the data transfer, table controls and step loops are almost identical. Table controls are ultimately an
improvement of step loops, in terms of usability by the end user.

Defining Step Loops

A step loop is defined in the Screen Painter. Screen elements, which unlike table controls can be spread over a number of lines, are
combined into one group that repeats itself several times within the step loop. The attributes of the screen elements of the first group
define the attributes of the whole step loop. The fields of a group only appear once in the field list of the corresponding screen.
Therefore, you only have to create them once in ABAP programs. A screen can have more than one step loop. However, as screen
elements, step loops do not have individual names.

In the Screen Painter, you can define whether the size of a step loop is fixed or variable. The vertical size of variable step loops
changes if the user changes the vertical size of the window. For every screen, you can define any number of fixed step loops but only
one variable step loop. Every vertical size change triggers PAI if a variable step loop is defined on the screen. For fixed step loops the
number of repetition groups is predefined.

Processing Step Loops

When processing step loops (step loop technique), loops are executed in the screen flow logic. The relevant commands in the flow
logic are:

LOOP ...
...
ENDLOOP.

These statements must not be confused with the ABAP statements of the same names. Between LOOP and ENDLOOP, you can use the
other flow logic keywords FIELD, MODULE, SELECT, VALUES, and CHAIN. At least one empty LOOP must exist for every step loop,
both in the PBO and the PAI processing block. During the loops, the contents of the step loop are transported back and forth between
identically-named fields of the ABAP program and the screen. Note that step loop fields defined with Dictionary reference must be
defined in the ABAP program, as before, with TABLES as interface work areas.

The order the step loops are processed in the individual loops of the flow logic depends on the step loop order on the screen. The
order on the screen depends primarily on the lines and secondarily on the rows.

The number of step loop rows displayed can change if the size of the table displayed is variable and the user changes the window
height. In this case, you can transfer different numbers of lines to the ABAP program for individual PAI events.

The same as for table controls applies for the flow of data transport and the cursor position. The system fields SY-STPL and
SY-LOOPC are also filled within the loops.

We differentiate between two loop techniques.

Loop Through the Lines of the Step Loop

The commands in the flow logic are:

LOOP.
...
ENDLOOP.

These statements create a loop pass through the step loop rows displayed on the screen and for PAI transfer the data of each group
into the identically-named fields of the ABAP program, or for PBO from the ABAP program into the step loop fields. In the
LOOP-ENDLOOP loop, you can call modules that process the transferred data and for PBO read from an internal table, or for PAI
place in an internal table.

With this form of processing, the step loop display does not contain scroll bars. If you wish to be able to scroll, this must be specified
in the ABAP program.

Parallel Loops Through Step Loops and an Internal Table

The commands in the flow logic are:

LOOP AT <itab> CURSOR <c> [INTO <wa>] [FROM <n1>] [TO <n2>].
...
ENDLOOP.

These statements create a parallel loop pass through the step loop rows displayed on the screen and an internal table <itab> of the
ABAP program. The additions INTO, CURSOR, and FROM are possible at the time of PBO, but not at PAI.

With this form of processing, the step loop display contains scroll bars. The scroll function is automatically defined by the system. The
step loop rows, between which you can scroll, is copied over from the internal table in the ABAP program. Scrolling triggers the PAI
event.

The CURSOR addition is used to control, at the time of PBO, which internal table row should be the first to appear in the screen
display. <c> is a data object of the ABAP program of type I. Conversely, for every PAI event, <c> is set to the value of the first table
row displayed. This allows you to synchronize the internal table of the ABAP program with the step loop rows displayed. It is
recommended that you place <c> into an auxiliary variable at the start of PBO and do not evaluate it in the loop, because scrolling
changes the value of <c>.

Using the INTO addition, the fields of the internal table <itab> are written to the work area <wa> at the time of PBO and the content
of <wa> is transported line-by-line to the identically-named fields of the step loop on the screen. Without the INTO addition, you
must use an internal table with a header line. Then the content of the header line is transported line-by-line to the identically-named
fields of the step loop on the screen at the time of PBO. A module for filling the step loop rows is therefore not necessary.

Conversely, at the time of PAI, the internal table rows are not automatically filled with the contents of the step loop rows. Instead,
you must call a module that fills the table within the loop. However, you must still specify the addition AT <itab> at the time of PAI,
because otherwise scrolling with the scroll bars does not work.

You can use the FROM and TO additions to limit the display or work area of the internal table in the step loop. <n1> and <n2> are
data objects of the ABAP program with type I. If you do not specify these parameters, the system uses the start and/or end of the
internal table as the display or processing limit. If <c> is outside the limits <n1> and <n2>, the latter take precedence.

The additions CURSOR <c> and FROM <n1> TO <n2> of the LOOP AT statement, which specify the starting line and number of
displayed rows of the internal table for step loops, are possible with Table Controls in the Flow Logic, but not necessary. With TABLE
CONTROLS, the display is controlled by using the structure CXTAB_CONTROL in the ABAP program.

Instead of the CURSOR <c>, you should always use the component TOP_LINE for table controls. This component always contains the
upper-most displayed row.
If you also specify <n1> for table controls, the calculation formula for the component CURRENT_LINE is changed to SY-STEPL +
(TOP_LINE -1) + (<n1> - 1).
Example



REPORT demo_dynpro_step_loop.

TYPES: BEGIN OF t_itab,
  col1 TYPE i,
  col2 TYPE i,
END OF t_itab.

DATA: itab TYPE STANDARD TABLE OF t_itab,
wa   LIKE LINE OF itab,
fill TYPE i.

DATA: idx   TYPE i,
line  TYPE i,
step  TYPE i,
limit TYPE i,
c     TYPE i,
n1    TYPE i VALUE 5,
n2    TYPE i VALUE 25.

DATA:  ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.

START-OF-SELECTION.

DO 40 TIMES.
wa-col1 = sy-index.
wa-col2 = sy-index ** 2.
APPEND wa TO itab.
ENDDO.

DESCRIBE TABLE itab LINES fill.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_100' EXCLUDING 'PREVIOUS'.
ENDMODULE.

MODULE status_0200 OUTPUT.
SET PF-STATUS 'STATUS_200' EXCLUDING 'NEXT'.
ENDMODULE.

MODULE transp_itab_out OUTPUT.
idx = sy-stepl + line.
READ TABLE itab INTO wa INDEX idx.
ENDMODULE.

MODULE transp_itab_in INPUT.
step = sy-loopc.
idx = sy-stepl + line.
MODIFY itab FROM wa INDEX idx.
ENDMODULE.

MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'NEXT_LINE'.
line = line + 1.
limit = fill - step.
IF line > limit.
 line = limit.
ENDIF.
WHEN 'PREV_LINE'.
line = line - 1.
IF line < 0.
 line = 0.
ENDIF.
WHEN 'NEXT_PAGE'.
line = line + step.
limit = fill - step.
IF line > limit.
 line = limit.
ENDIF.
WHEN 'PREV_PAGE'.
line = line - step.
IF line < 0.
 line = 0.
ENDIF.
WHEN 'LAST_PAGE'.
line =  fill - step.
WHEN 'FIRST_PAGE'.
line = 0.
WHEN 'NEXT'.
c = line + 1.
LEAVE TO SCREEN 200.
ENDCASE.
ENDMODULE.

MODULE get_first_line INPUT.
line = c - 1.
ENDMODULE.

MODULE user_command_0200 INPUT.
save_ok = ok_code.
CASE save_ok.
WHEN 'PREVIOUS'.
LEAVE TO SCREEN 100.
ENDCASE.
ENDMODULE.

MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.



A variable step loop with 10 initial repetition groups is defined. The fields of the repetition groups are the components COL1 and
COL2 of the structure WA of the ABAP program.

The flow logic of screen 100 is:

PROCESS BEFORE OUTPUT.
MODULE status_0100.
LOOP.
MODULE transp_itab_out.
ENDLOOP.

PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP.
MODULE transp_itab_in.
ENDLOOP.
MODULE user_command_0100.

In the status STATUS 100, the function codes FIRST_PAGE, PREV_PAGE, PREV_LINE, NEXT_LINE, NEXT_PAGE, LAST_PAGE, and
NEXT have been assigned to pushbuttons on the application toolbar for screen 100.

The layout of screen 200 is the same as that of screen 100, except that step loop is not variable, but fixed.

The flow logic of screen 200 is:

PROCESS BEFORE OUTPUT.
MODULE status_0200.
LOOP AT itab INTO wa CURSOR c FROM n1 TO n2.
ENDLOOP.

PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
MODULE get_first_line.
LOOP AT itab.
MODULE transp_itab_in.
ENDLOOP.
MODULE user_command_0200.

In the status STATUS 200, the function code PREVIOUS is assigned to a pushbutton of the application toolbar for screen 200.

If you execute the program, the system displays a step loop on screen 100, whose line number has been adjusted to fit the height of
the screen but has no vertical scroll bars. On screen 200, the system displays a step loop with a fixed line number of 10 and a
vertical scroll bar.

At the time of PBO, both step loops are filled from the internal table ITAB. For screen 100 the loop is only through the step loop and
for screen 200 it is parallel through the step loop and the internal table. The step loop on screen 200 is restricted to the lines 5 to 25
of the internal table. While for screen 100 a PBO module is called to fill the work area WA, this is not necessary for screen 200.

At the time of PAI, a module is called in both screens within the loops. In this module, the system transfers possible user entries in the
step loop rows to the corresponding rows of the internal table.

For screen 100, the scrolling function of the step loop is programmed in the PAI module USER_COMMAND_100. For this, the number
of rows of the step loop on the screen is buffered in the auxiliary variable STEP, because SY-LOOPC is only filled within the loop. You
do not need to program a scrolling function for screen 200, because it is automatically provided by the system in the form of the scroll
bar.

The synchronization between the internal table and the step loop on screen 200 is dealt with by the variable C, which is used in the
CURSOR addition to the LOOP statement. It is set before the call of screen 200 in correspondence with the display of the table on
screen 100. At the time of PAI of screen 200, C is read to redefine first table row after any scrolling with the scroll bar





Example Transaction: Table Controls

Table Controls in ABAP Programs

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. The statement also declares a deep structure of name <ctl>. The data type
of the structure corresponds to the type CXTAB_CONTROL defined in the type group CXTAB in the ABAP Dictionary.

At runtime the components of the structure contain the attributes of the table control. Several of the initial values are determined in
the Screen Painter. The initial value for the control <ctl> is taken from the screen which is determined using the addition USING.

If you write the statement

REFRESH CONTROL <ctrl> FROM SCREEN <scr>.

you can initialize a table control at any time with the initial value of a screen <scr>. Values that are not taken from the settings in the
Screen Painter, are set to the current status of the table control at PAI.

Structure CXTAB_CONTROL

The deep structure CXTAB_CONTROL contains the general attributes of the table control on the highest level. The component
CXTAB_CONTROL is a table of the structure CXTAB_COLUMN and contains the attributes of a column. The component
CXTAB_CONTROL-COLS-SCREEN is a flat structure of the same type as system table SCREEN and contains the attributes of the
individual screen elements.




Up to component CURRENT_LINE, all attributes of the structure CXTAB_CONTROL in the ABAP program can be set to
change the table control display on the screen.

Components of CXTAB_CONTROL

The structure CXTAB_CONTROL has the following components:

Component
Type (length)
Meaning
In the Screen Painter:

FIXED_COLS
I
Number of lead columns. Transferred from Screen Painter. Can be changed in the ABAP program.
Fixed columns

LINES
I
Controls the scroll bar of the table control. At LOOP without internal table, LINES has the initial value zero and must be set
in the program so that the scroll bar can be used. At LOOP AT <itab> the system sets this component to the number of
rows of the internal table, whenever the table control is processed for the first time. The initialization event of a table control
is not determined uniquely. If the corresponding internal table is not fully created at this event, then the LINES variable
receives an incorrect value. If LINES in the LOOP loop is smaller as the number of rows of the internal table, then the table
control contains blank rows at the end.

Therefore you should always set the LINES component explicitly in the ABAP program, including at LOOP AT <itab>. In this
way you have full control over the dimensions of the vertical scroll bar and so can control the number of rows that are ready
for input. Initialization should usually occur at PBO directly before the LOOP statement for the table control.

TOP_LINE
I
Top row at next PBO. Set at PAI by position of the vertical slider box. Can be changed in the ABAP program.

CURRENT_LINE
I
Current line in the loop. Set automatically in the LOOP loop to the value SY-STEPL +(TOP_LINE-1). No changes allowed in
the ABAP program.

LEFT_COL
I
First displayed horizontal scrollable column after the lead column. Set at PAI by position of the horizontal slider box.
LEFT_COL contains the absolute number of the column independent of any column shift by the user. Can be changed in the
ABAP program.

LINE_SEL_MODE
I
Row selection mode: 0, 1, 2 for none, one or multiple rows can be selected. Transferred from Screen Painter. Can be
changed in the ABAP program.
Row selection

COL_SEL_MODE
I
Column selection mode: 0, 1, 2 for none, one or multiple rows can be selected. Transferred from Screen Painter. Can be
changed in the ABAP program.
Column selection

LINE_SELECTOR
C(1)
Flag (X or blank) for selection column. Transferred from Screen Painter. Can be changed in the ABAP program.
Selection column

H_GRID
C(1)
Flag (X or blank) for horizontal separators. Transferred from Screen Painter. Can be changed in the ABAP program.
Separators

V_GRID
C(1)
Flag (X or blank) for vertical separators. Transferred from Screen Painter. Can be changed in the ABAP program.
Separators

COLS
CXTAB_COLUMN
Control table for single columns (see below).

INVISIBLE
C(1)
Flag (X or blank) for visibility of entire table control.


Internal table CXTAB_COLUMN is a component of the structure CXTAB_CONTROL.

Components of CXTAB_COLUMN

Each column of the table control corresponds to a row of the table CXTAB_COLUMN. The internal table CXTAB_COLUMN has
no header line and the following columns:

Component
Type (length)
Meaning

SCREEN
SCREEN
Structure for the attributes of screen elements of the column (see below).

INDEX
I
Current position of the column in the table control. Transfered with initial value from Screen Painter. At PAI the current
column configuration of the table control is withdrawn. Can be changed in the ABAP program.

SELECTED
C(1)
Flag (X or blank) whether column is selected or not. At PAI the current status of the table control is withdrawn. Can be
changed in the ABAP program.

VISLENGTH
I
Visible length of the column. Transferred from Screen Painter. Can be changed in the ABAP program.

INVISIBLE
C(1)
Flag (X or blank) whether column is visible. Transferred from Screen Painter. Can be changed in the ABAP program.


The structure SCREEN is a column of the table CXTAB_COLUMN.

Components of SCREEN

The structure SCREEN contains the same components as system table SCREEN. The component SCREEN-NAME is the name
of the screen element that creates the column. The initial values of the remaining components correspond to the attributes
of the screen elements in the Screen Painter. The attributes are transferred from here with initial values. They can be
changed directly in the ABAP program. Note that directly set values can be overwritten by modifying these attributes using
MODIFY SCREEN within the loop LOOP AT SCREEN.

Furthermore, note that the attributes of the structure SCREEN are not set with blank characters and X, but are set with 0
and 1 as in the system table SCREEN .

Scrolling in Table Controls

Scrolling with scroll bars is automatically implemented with table controls, and managed by the system. However, the
component <ctl>-LINES must be set to the required row number before editing the table control. This is the case for table
controls with or without parallel loops using an internal table. The component LINES is set implicitly for table controls with
parallel loops using an internal table, although the correct value is not guaranteed (see table above). It is therefore
recommended that in both instances you set the component LINES explicitly to the number of rows in the internal table of
the ABAP program. You can determine this number from the statement DESCRIBE TABLE (see the following example).

The event PAI with an empty function code is triggered when scrolling using scroll bars. When the loops at PAI and PBO are
executed, the system sets the component TOP_LINE of the structure CXTAB_CONTROL before PBO, so that the correct row
is edited at the loop pass.

You can easily implement program-controlled vertical scrolling (line by line, page by page, or goto page) by using the
component of the structure CXTAB_CONTROL. Essentially the component TOP_LINE must be provided with a value. For
page by page scrolling, the number of rows to be scrolled during the loop pass can be taken from the system field
SY-LOOPC. SY-LOOPC contains the number of rows currently display, whereas the component LINES of structure
CXTAB_CONTROL contains the number of all rows in the table control.

Cursor Position on Table Controls

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>.

if you only want 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.
SapMaterial.com  
Original source help.sap.com