DYNPRO

Double-Click in SAP Table Control

This article demonstrates how to implement a double-click interaction on a material number inside a classic SAP Dynpro Table Control. The solution seamlessly combines screen interaction with the GET CURSOR statement, parameter passing, and automated transaction forwarding.

Problem Description and Implementation Decision

A question arose in a Telegram developer group regarding how to open a document directly in its corresponding transaction by double-clicking the document number within a Table Control. In response, a compact demo report was created to demonstrate this behavior using the material number from table MARA as an example: Double-clicking the material number opens the material directly in transaction MM03.

Implementation

Creating the Report

Create a report in SE38 or SE80 and paste the following ABAP code into it.

Report Code (96 lines)
REPORT zstkeos_table_control.
 
TABLES mara.
 
TYPES:
  BEGIN OF ts_mara,
    matnr TYPE mara-matnr,
    ersda TYPE mara-ersda,
    ernam TYPE mara-ernam,
    laeda TYPE mara-laeda,
    aenam TYPE mara-aenam,
    vpsta TYPE mara-vpsta,
    pstat TYPE mara-pstat,
    lvorm TYPE mara-lvorm,
  END OF ts_mara.
 
DATA gv_ucomm TYPE syucomm.
DATA gv_initialization TYPE char1.
DATA gv_field TYPE char128.
DATA gv_line TYPE systepl.
 
DATA gs_mara TYPE ts_mara.
 
DATA gt_mara TYPE TABLE OF ty_mara.
 
CONTROLS tc_mara TYPE tableview USING SCREEN 0100.
 
CALL SCREEN 100.
 
*&---------------------------------------------------------------------*
*&      Module  TEST_INIT  OUTPUT
*&---------------------------------------------------------------------*
MODULE tc_init OUTPUT.
  IF gv_initialization IS INITIAL.
    SELECT FROM mara INTO TABLE gt_mara
           FIELDS matnr,
                  ersda,
                  ernam,
                  laeda,
                  aenam,
                  vpsta,
                  pstat,
                  lvorm
           UP TO 100 ROWS.
    gv_initialization = 'X'.
    REFRESH CONTROL 'TC_MARA' FROM SCREEN '0100'.
  ENDIF.
  IF gv_line IS NOT INITIAL.
    SET CURSOR FIELD gv_field LINE gv_line.
  ENDIF.
ENDMODULE.
 
*&---------------------------------------------------------------------*
*&      Module  TEST_MOVE  OUTPUT
*&---------------------------------------------------------------------*
MODULE test_move OUTPUT.
  MOVE-CORRESPONDING gs_mara TO mara.
ENDMODULE.
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS '0100'.
  SET TITLEBAR '0100'.
ENDMODULE.
 
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  DATA lv_itab_line TYPE i.
  DATA lv_matnr TYPE matnr.
 
  gv_ucomm = sy-ucomm.
  CLEAR sy-ucomm.
  CASE gv_ucomm.
    WHEN    'BACK'
         OR 'EXIT'
         OR 'CANC'.
      LEAVE PROGRAM.
    WHEN 'MARA'.
      GET CURSOR FIELD gv_field LINE gv_line.
      CASE gv_field.
        WHEN 'MARA-MATNR'.
          lv_itab_line = tc_mara-top_line + gv_line - 1.
 
          READ TABLE gt_mara INTO gs_mara INDEX lv_itab_line.
          IF sy-subrc EQ 0.
            lv_matnr = gs_mara-matnr.
            SET PARAMETER ID 'MAT' FIELD lv_matnr.
            CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
  ENDCASE.
ENDMODULE.

Creating Screen 100

Create Screen 100 and copy the following code into the screen's Flow Logic.

Flow Logic (15 lines)
PROCESS BEFORE OUTPUT.
  MODULE tc_init.
 
  LOOP AT gt_mara INTO gs_mara WITH CONTROL tc_mara
       CURSOR tc_mara-current_line.
    MODULE test_move.
  ENDLOOP.
 
  MODULE status_0100.
 
PROCESS AFTER INPUT.
  LOOP AT gt_mara.
  ENDLOOP.
 
  MODULE user_command_0100.

Configuration of Dynpro Objects

Creating PF-Status 0100

Create PF-Status 0100 as illustrated below. The PF-Status defines the function codes available on the screen, which are evaluated in the module USER_COMMAND_0100.

Figure 1: Custom PF-Status configuration in SAP GUI for handling the F2 / double-click event.
  1. BACK – Return to the previous level
  2. EXIT – Exit the program
  3. CANC – Cancel processing
  4. MARA – Navigation to transaction MM03 (triggered by double-clicking the material number, function code 4)

Creating Title 0100

Create Title 0100 as illustrated below.

Figure 2: Dynamic titlebar definition for the main data selection interface.

Placing the Table Control on Screen 100

Place the Table Control on Screen 100 according to the following steps:

Figure 3: Place the Table Control on Screen 100 according to the following steps.
  1. Use a standard Table Control – do not use the Table Control Wizard.
  2. Fill the screen area completely with the Table Control object.

Inserting Fields from the Dictionary:

Figure 4: Structural layout mapping inside the Screen Painter wizard.
  1. Open the 'Dictionary/Program Fields' window.
  2. Enter the table name 'MARA'.
  3. Click on Get From Dictionary.
  4. Select the desired fields and confirm with OK.

Place the selected fields in the gray area directly above the Table Control.

Figure 5: Verifying output fields and data binding attributes.

Configuring Fields as Output Only:

Figure 6: Configuring table column properties for line selection tracking.
  1. Double-click each field directly below the column header.
  2. Deactivate the Input Field option for all fields.

Activating Double-Click for the First Column:

Figure 7: Finalizing runtime modifications for the main collection structure.
  1. Activate the Responds to double-click option for the first column.

Test and Result

Activate all created objects and execute the report. Double-clicking a material number in the 'Material' column opens the material directly in transaction MM03.

Figure 8: Initial data processing layout screen rendering live table arrays.
Figure 9: Successful double-click interaction triggering direct transaction forward route.

Download Source Code on GitHub

Select the appropriate variant matching your SAP release version.

Minimum Release GitHub
SAP_BASIS 700 Open Repository
SAP_BASIS 702 Open Repository
SAP_BASIS 740 Open Repository
SAP_BASIS 740SP08 Open Repository

Import GitHub Repo via abapGit

You can also import the source code directly into your system using abapGit. You can find a step-by-step guide for importing from a GitHub repository in the linked blog post.

Open instructions for importing with abapGit

Repository URL zum Kopieren

https://github.com/stekoester/double_click_in_table_control

Back to Blog Overview