ARTIClE
Table Control with Modifications
This example demonstrates sorting by columns and deleting rows in table
controls.
ABAP_SOURCE_CODE
ABAP_EXEC
ABAP_DESCRIPTION
The table control flights is defined and can be resized .
The fields of the table control are copied from the DEMO_CONN
structure in the ABAP Dictionary. The first two columns are lead
columns. The corresponding fields are output fields. A title list,
column headers and a selection column are created. The component
MARK , of type CHAR , length 1, from the structure
DEMO_CONN is assigned to the
selection column. One column and multiple rows can be selected.
In the flow logic of screen 100, one loop is executed during PBO
and another during PAI using the table control flights and
the internal table itab of the ABAP program in parallel. In the
PBO loop, no modules are called to fill the table control from
the table itab of the ABAP program. However, in the PAI loop a
module is called to modify the table itab .
During PBO , the component lines of the control structure
flights is explicitly filled with the current number of rows in
internal table itab to set up the scroll bar of the table control
before the PBO loop.
In the PAI loop, the rows of the internal table with row indexes
corresponding to the current table control rows are overwritten with the
contents of the work area demo_conn . In this way, user inputs in
the input fields of the control are transferred to the internal table. A
flag is set in the internal table column MARK indicating whether
the table control row is selected or not.
After the PAI loop, the user inputs are processed in the
user_command_0100 module. The GUI status SCREEN_100 enables
the corresponding function codes.
The fields of the table control are not ready for input when the program
is called. The static settings of the control table in the screen
painter are modified before CALL SCREEN in the program. The table
cols in the control structure flights is used. All
columns with a column position greater than two are set to not ready for
input using a loop through the flights-cols table. By selecting
the function code TOGGLE , the input readiness of these fields can
be switched on and off.
Using the function codes "SORT_UP" and "SORT_DOWN" , it is
possible to sort the columns of the internal table itab into
either ascending or descending order. Due to the static settings of the
table control, it is only possible to select one column at a time. The
selected column is removed from the internal table flights-cols .
The name of the sort criteria in the SORT statement is
dynamically assigned from the component cols-screen-name . The
prefix demo_conn - must be removed using an offset specification.
After sorting, the selection is reversed by assigning an empty character
to the component selected in the table flights-cols .
Using the function code "DELETE" it is possible to delete
selected rows from the internal table itab . First,
flights-cols is checked to establish whether the fields in the table
control are ready for input. Then all the selected rows are deleted
using a loop through the internal table itab . As the table
control is completely repopulated during the PBO loop from the
internal table itab , the rows are also deleted from the screen.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved