capture line selection of a SAP dynpro table control and store which has been selected

The SAP ABAP code below demonstrates how to implement row selection functionality to a dynpro table control so that the user is able to select / highlight a specific row and perform further processing based on this selection.

Using the example of a basic table control as your starting point please implement the following ABAP code changes:

Step 1 - Declare ABAP variable to store line selection indicator. 
    DATA: MARK TYPE C.
Step 2 - Assign created variable to dynpro table control. 
Step 3 - Modify dialog screen Flow logic in-order to capture users line selection. 
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
  module data_retrieval.
  loop at it_ekko into wa_ekko with control TC100.
    module populate_screen.
  endloop.
*
PROCESS AFTER INPUT.
  loop at it_ekko.
       module update_table.
     endloop.
* MODULE USER_COMMAND_0100.
 


To create module update_table please Double click on it and select yes to the next pop-up. Ensure that a new include is created to hold all the PAI modules (default) and Press enter.

Now insert the following ABAP code into this PAI module!

*&---------------------------------------------------------------------*
*&      Module  update_table  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module update_table input.
read table it_ekko into wa_ekko index tc100-CURRENT_LINE.
 if not mark is initial.
   wa_ekko-SEL = 'X'.
   modify it_ekko from wa_ekko index tc100-CURRENT_LINE.
 endif.
endmodule.                 " update_table  INPUT
 

Related Articles

Table Control - Example code and information on various areas of table control development
Create ABAP dialog screen dynpro Table Control within SAP
Manipulating individual abap dynpro table control field attributes