SAP TABLE CONTROL2 ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_DYNPRO - Table Control with Modifications
This example demonstrates sorting by columns and how lines are deleted in table controls.

ABAP_SOURCE_CODE
ABAP_EXEC

ABAP_DESCRIPTION
The resizable table control flights is defined. The fields of the table control have been copied from the DEMO_CONN structure in the 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 selection column is assigned to the component MARK, of the type CHAR, length 1, from the structure DEMO_CONN. One column and multiple lines can be selected.
In the flow logic of dynpro 100, one loop is executed at PBO time and another loop is executed at PAI time using the table control flights and the internal table itab of the ABAP program at the same time. During the PBO loop, a 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 lines of the internal table itab before the PBO loop to install the scroll bar of the table control.
During the PAI loop, the lines of the internal table whose line index corresponds to the current line of the table control are overwritten with the content of the work area demo_conn. User input is passed from the input fields of the control to the internal table. A flag is set in the column MARK of the internal table indicating whether the table control line is selected or not.
After the PAI loop, user input is processed in the module user_command_0100. The GUI status SCREEN_100 enables the corresponding function codes.
When the program is called not all fields of 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 greater than two are set to not ready for input using a loop across the table flights-cols. 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 in either ascending or descending order. The static settings of the table control allow only a single column to be selected. The selected column is taken from the internal table flights-cols. The name of the sort criterion in the SORT statement is determined dynamically from the component cols-screen-name. The prefix demo_conn must be cut off by specifying an offset. After the sort, the selection is canceled by assigning a blank character to the component selected in the table flights-cols.
Using the function code DELETE, it is possible to delete selected lines from the internal table itab. First the system checks in flights-cols whether the fields of the table control are ready for input. Then all selected lines are deleted in a loop using the internal table itab. Since the table control is read again from the internal table itab in the PBO loop, the lines on the screen are deleted.