Online Tutorials & Training Materials |
Register Login

Using a Table control with an internal table

26 Apr 2007 12:19 pm || 0

Table control : TC1
Internal table : it_zsd00003

In the attributes of the table control, select w/SelColumn to get a selection
column on the table control, and give a name (In this example IT_ZSD00003-LINESEL).
Remember to include the field IT_ZSD00003-LINESEL in the
internal table ( linesel(1) type c, ).

When used with an internal table, remember to program
the update functionality of the database tables. Update and
validation can be done when leaving the screen or in PAI using controlname-
current_line (E.g. TC1-current_line ) to indentify the entry in the internal table.

process before output.
module status_0100.
loop at it_zsd00003 with control tc1 cursor tc1-
module tc1_set_field_attr. "Optional

module status_0100 output.
set pf-status 'SCREEN0100'.

* OPTIONAL: If it_zsd00003 hasn't allready been filled with
* data, you can do it the first time PBO is called
module read_data.

* Setting the number of lines of the table control
describe table it_zsd00003 lines tc1-lines.

* Optional: Place the cursor on line g_current_line e.g. after a
* validation error has occured
if not ( g_current_line is initial ).
tc1-top_line = g_current_line.
clear g_current_line.

endmodule. " STATUS_0100 OUTPUT

module read_data.
if flag is initial.
perform read_data.
flag = 1.


module tc1_set_field_attr output.
* Optional: Protect some of the columns on the
* table control
loop at screen.
if screen-group1 = 'X'.
screen-input = 0.
modify screen.
endmodule. " tc1_set_field_attr OUTPUT

process after input.
loop at it_zsd00003.
module modify_tc1.

module user_command_0100.

module modify_tc1 input.

* Modify an existing entry
modify it_zsd00003 index tc1-current_line.

* OR

* Appending a new entry
append it_zsd00003.

endmodule. " modify_tc1 INPUT

Deleting a single line selected with the selection column:

form delete_record.

loop at it_zsd00003.
if it_zsd00003-linesel = 'X'.

delete from zsd00003
where zdriftscenter = it_zsd00003-zdriftscenter