Application Development 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 double click

Former Member
0 Kudos

hello friends,

i have issue when i double click on row in ALV i have to call transaction with that row data.

suppose i double click on 11 then transaction will be called with data of that row.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

1...


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'                    "#EC *
    EXPORTING
      i_callback_program      = sy-repid
      is_layout               = is_layout
      it_fieldcat             = it_fieldcat
      i_save                  = 'A'
      i_callback_user_command = 'USERCOMMAND'
    TABLES
      t_outtab                = it_mseg_mat
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
 

2...


*&---------------------------------------------------------------------*
*&      Form  usercommand
*&---------------------------------------------------------------------*
*       Handle Double Click on ALV
*----------------------------------------------------------------------*
FORM usercommand USING r_ucomm
                       ls_selfield TYPE slis_selfield.      "#EC CALLED
 
*&---Looking for Double click on ALV
  IF r_ucomm = '&IC1'.
    READ TABLE it_mseg_mat ASSIGNING <mseg> INDEX ls_selfield-tabindex.
    IF sy-subrc = 0.
        SET PARAMETER ID 'BLN' FIELD <mseg>-mblnr.
        SET PARAMETER ID 'BUK' FIELD <mseg>-bukrs.
        SET PARAMETER ID 'GJR' FIELD <mseg>-mjahr.
 
        CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDIF.
ENDFORM.                    "usercommand

8 REPLIES 8

Former Member
0 Kudos

1...


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'                    "#EC *
    EXPORTING
      i_callback_program      = sy-repid
      is_layout               = is_layout
      it_fieldcat             = it_fieldcat
      i_save                  = 'A'
      i_callback_user_command = 'USERCOMMAND'
    TABLES
      t_outtab                = it_mseg_mat
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
 

2...


*&---------------------------------------------------------------------*
*&      Form  usercommand
*&---------------------------------------------------------------------*
*       Handle Double Click on ALV
*----------------------------------------------------------------------*
FORM usercommand USING r_ucomm
                       ls_selfield TYPE slis_selfield.      "#EC CALLED
 
*&---Looking for Double click on ALV
  IF r_ucomm = '&IC1'.
    READ TABLE it_mseg_mat ASSIGNING <mseg> INDEX ls_selfield-tabindex.
    IF sy-subrc = 0.
        SET PARAMETER ID 'BLN' FIELD <mseg>-mblnr.
        SET PARAMETER ID 'BUK' FIELD <mseg>-bukrs.
        SET PARAMETER ID 'GJR' FIELD <mseg>-mjahr.
 
        CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDIF.
ENDFORM.                    "usercommand

0 Kudos

thk for ans ut here problem is that how can i pass selected data to transaction

0 Kudos

Hi,

Follow steps:-

When you double-click on any cell of alv grid, use this code to fetch the data of the line that you currently clicked, its working:-

When you double click on the ALV grid line, you will have sy-ucomm = '&IC1'.

So when you define a i_callback_user_command for the FM reuse_alv_grid_display, and create it as:-


FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
  DATA : ok_code TYPE sy-ucomm.
  ok_code = ucomm.
  CASE ok_code.
    WHEN '&IC1'. "for double click on alv grid line
      " your code
  ENDCASE.
ENDFORM.

As you have used selfield TYPE slis_selfield, the field selfield will hold all the values.

To know on which row you have clicked and to retain that line, use code:-

Suppose you are currently displaying data from internal table itab and corresponding to it you have work area wa.


read table itab into wa index selfield-tabindex. "index value of line you clicked
" now you have the contents of line that you double clicked currently

Now to know the field name that you clicked, use:-


selfield-fieldname " will fetch you the name of field that you clicked

Now using the work-area and the name of field that you clicked, you can easily make out the details of the field i.e., field name and field value and you can code as per your requirement.

Hope this helps you.

Regards,

Tarun

0 Kudos

hi,

use set parameters

SET PARAMETER ID: 'AUN' FIELD p_vbeln,

'MAT' FIELD p_matnr

CALL TRANSACTION 'ZCS21' AND SKIP FIRST SCREEN.

Former Member
0 Kudos

hi,

BCALV_GRID_03

thanks

Former Member
0 Kudos

Hi rajan,

In FM - REUSE_ALV_LIST_DISPLAY

U can use

1. I_CALLBACK_USER_COMMAND =

and pass structure name I_STRUCTURE_NAME .

Further select values using select query for that data.

Thanks

Shrila

Former Member
0 Kudos

Hi Rajan,

You have to write the logic as

FORM user_command USING
     r_ucomm LIKE sy-ucomm
     rs_selfield TYPE slis_selfield.

 CASE r_ucomm.

    WHEN '&IC1'."'ROW'.
      IF rs_selfield-fieldname = 'FIELD1'.
      READ TABLE it_tab INTO wa_tab INDEX rs_selfield-tabindex.
      "Now wa_tab contains the required row
      CALL TRANSACTIOn ...
 ENDCASE.
ENDFORM.

Regards,

Manoj Kumar P

Former Member
0 Kudos

Hi,

Check the below Link

https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action%3fpageid=53583

Hope this helps you.

Regards,

Anki Reddy