Process documentationD&D Behavior for Special Rows/Cells Locate this document in the navigation structure

 

You can use this process to define a Drag & Drop behavior for special rows or cells of the grid control. Each row or cell can have its own Drag & Drop behavior.

Process

  1. Define the layout structure of type LVC_S_LAYO.

  2. Add a Drag & Drop table of type LVC_T_DRDR to your output table, as shown in the example below:

    Syntax Syntax

    1. DATA: BEGIN OF GT_OUTTAB OCCURS 0.
      	INCLUDE STRUCTURE <DDIC-Struktur>.
      
      DATA: CT TYPE LVC_T_DRDR. "Table for d&d cell behaviour
      
      DATA: END OF GT_OUTTAB.
    End of the code.
  3. Define your Drag & Drop behavior and get its handle with method get_handle of class cl_dragdrop.

  4. Select your data and copy it in the output table.

  5. Read one row of the output table at a time in a loop. A row of the Drag & Drop table has two fields. Assign values to these fields as follows (see also the graphic in the next section):

    • If the entire row should have a Drag & Drop behavior, assign the corresponding handle to field dragdropid. Field fieldname does not receive a value in this case.

    • If only specific columns of the row should have a Drag & Drop behavior, you must append one row for each column to the Drag & Drop table. Assign the name of the desired column to field fieldname, and the corresponding handle to field dragdropid.

  6. Assign the name of the internal table to field s_dragdrop-fieldname of the layout structure (in our case'CT', see step 2).

  7. Pass the layout structure and the output table with method set_table_for_first_display.

    Note Note

    You can also subsequently pass the layout structure with the Drag & Drop behavior using method set_frontend_layout. The ALV Grid Control refreshes this table when method refresh_table_display is called. The instance of the ALV Grid Control and the associated output table must have the same lifetime.

    End of the note.

Example

The following graphic shows an output table where cells b1 and c1 have different Drag & Drop behaviors and the entire second row has the same Drag & Drop behavior as cell c1:

This graphic is explained in the accompanying text.