Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV CLASS-METHODS on_double_click

Former Member
0 Kudos
562

Hello experts,

I have implemented:

CLASS-METHODS on_double_click " DOUBLE_CLICK

FOR EVENT if_salv_events_actions_table~double_click

OF cl_salv_events_table

IMPORTING row

column.

But how do I get the the selected field?

Like the equivalent to the non oop:

rs_selfield TYPE slis_selfield

I know I got column and row, but I need the cell where the user doubleclicked.

/Kenneth

8 REPLIES 8

Former Member
0 Kudos
360

Check for get_selected_cells methode or something like that...

Here you go:

DATA: w_text TYPE char100.
  CALL METHOD o_ref_grid->get_selected_cells
    IMPORTING
      et_cell = i_sel_cell.
  READ TABLE i_sel_cell INDEX 1 INTO s_sel_cell.
  CONCATENATE 'Row - Column' ' ' s_sel_cell-row_id '-' s_sel_cell-col_id INTO w_text RESPECTING BLANKS.
  MESSAGE w_text TYPE 'I'.
  CALL METHOD o_ref_grid->refresh_table_display.

0 Kudos
360

So is o_ref_grid my alv ?

/Kenneth

0 Kudos
360

Please go through below code

DATA : lv_count TYPE i VALUE 0.

Getting Selected rows into internal table gt_rowid.

CALL METHOD gcl_grid->get_selected_rows

IMPORTING

et_index_rows = gt_rowid

  • ET_ROW_NO =

.

DESCRIBE TABLE gt_rowid LINES lv_count.

IF lv_count IS INITIAL.

MESSAGE text-001 TYPE 'E'.

ENDIF.

SORT gt_rowid DESCENDING BY index.

LOOP AT gt_rowid INTO gs_rowid.

READ TABLE gt_final

INDEX gs_rowid-index

INTO gs_final.

gs_purch-matnr = gs_final-matnr.

gs_purch-werks = gs_final-werks.

gs_purch-matkl = gs_final-matkl.

APPEND gs_purch TO p_gt_purch.

ENDLOOP.

If it is help give me reward points

Edited by: Suhas Saha on Mar 1, 2012 4:33 PM

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
360

Hello Kenneth,

The example provided above is not relevant in your case (since you're using the SALV technique).

Just like you use the standard i/face of the user-command callback routine( I_CALLBACK_USER_COMMAND ) of the REUSE* FMs, you've to use the i/face of the class event viz., DOUBLE_CLICK which are - ROW & COLUMN.

BR,

Suhas

PS: Refer to the demo program SALV_DEMO_TABLE_EVENTS to get an idea on how to handle these events.

0 Kudos
360

Thanks Suhas,

I looked in the sample program.

Here i implented this:

method on_double_click.

perform show_cell_info using row column.

endmethod. "on_double_click

But i still cant see how to get cell data.

So do i then have to loop on my itab and then get the data my self using row and column?

Or can i directly get the value in the selected cell?

/Kenneth

0 Kudos
360

Ahh,

solved it with:

READ TABLE <MYTAB> INDEX i_row INTO <MYSTRUCT>.

CASE i_column.

WHEN '<COLUMN>'.

...

WHEN OTHERS.

ENDCASE.

Thanks

0 Kudos
360

May be you can avoid 'CASE' statement

DATA : lv_col TYPE string.
FIELD-SYMBOLS : <fs_col> TYPE ANY.

READ TABLE <MYTAB> into <MYSTRUCT> INDEX row
IF sy-subrc eq 0.
      CONCATENATE '<MYSTRUCT>-' column INTO lv_col.
      ASSIGN (lv_col) TO <fs_col>.
ENDIF.

Field symbol <fs_col> will return the value of current cell.

Regards, Vinod

Former Member
0 Kudos
360

SAP Demonstration program SALV_DEMO_TABLE_EVENTS shows how this is handled. There are a variety of these and they are excellent for seeing how SALV is written.

Substitute your logic for the " perform show_cell_info using row column text-i07."