Skip to Content
author's profile photo Former Member
Former Member

double click alv

Hi Experts,

I have a requirement, On an alv grid, when user double clicks on a particular field, i want to raise a popup, that popup basically lists certains values of that row selected and I want those fields to be editable in that popup.

Is it feasible ?

My concerns are:

1. How can i transfer the selected row to the next pop up

2. Would it be easy to create that pop up as a screen or just an additional ALV ?

3. If I chose to create it as ALV, how can i get the labels for that field

thanks,

AJ

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 02:41 PM

    If you're using OO ALV.. then this can help for Double Clicking

    DATA:
      g_container        TYPE scrfname VALUE 'CC_ALV',
      g_grid             TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container,
      gs_layout          TYPE lvc_s_layo,
      lt_exclude         TYPE ui_functions,
      gs_fieldcat        TYPE lvc_t_fcat,
      gs_sort            TYPE lvc_t_sort,
      g_save                     TYPE c.
    
    *---------------------------------------------------------------------*
    *       CLASS LCL_EVENT_RECEIVER DEFINITION
    *---------------------------------------------------------------------*
    CLASS lcl_event_receiver DEFINITION.
    
      PUBLIC SECTION.
    
        METHODS:
    
        handle_double_click
          FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row
                    e_column
                    es_row_no.
    
    
    * PRIVATE SECTION.
    
    *   data: error_in_data TYPE c.
    
    
    ENDCLASS.
    *---------------------------------------------------------------------*
    *       CLASS lcl_event_receiver IMPLEMENTATION
    *---------------------------------------------------------------------*
    CLASS lcl_event_receiver IMPLEMENTATION.
    
      METHOD handle_double_click.
        DATA: l_itab LIKE LINE OF it_all_reps.
    
        READ TABLE it_all_reps INTO l_itab INDEX es_row_no-row_id.
        CHECK sy-subrc EQ 0.
    
        zlot_email-branch = l_itab-branch.
        CLEAR sv_branch.
    
        PERFORM validate_branch.
    
        CALL SCREEN 200 starting at  5  5
                        ending   at 110 20.
    
      ENDMETHOD.
    
    

    Initialization looks like this

    PROCESS BEFORE OUTPUT.
    " PBO
      module build_alv_grid.
    

    *&---------------------------------------------------------------------*
    *&      Module  build_alv_grid  OUTPUT
    *&---------------------------------------------------------------------*
    MODULE build_alv_grid OUTPUT.
    
      CREATE OBJECT g_custom_container
             EXPORTING container_name = g_container.
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    
      CREATE OBJECT g_event_receiver.
    
      PERFORM exclude_tb_functions CHANGING lt_exclude.
      PERFORM build_sel_fieldcat CHANGING gs_fieldcat.
    
      gs_layout-zebra = 'X'.
      gs_layout-cwidth_opt = 'X'.
      gs_layout-sel_mode = 'A'.
    
      CALL METHOD g_grid->set_table_for_first_display
          EXPORTING is_layout             = gs_layout
                    it_toolbar_excluding  = lt_exclude
          CHANGING  it_fieldcatalog       = gs_fieldcat
                    it_outtab             = it_all_reps[].
    
      CREATE OBJECT g_event_receiver.
    *  SET HANDLER g_event_receiver->handle_user_command FOR g_grid.
    *  SET HANDLER g_event_receiver->handle_toolbar FOR g_grid.
    *  SET HANDLER g_event_receiver->handle_hotspot_click FOR g_grid.
      SET HANDLER g_event_receiver->handle_double_click FOR g_grid.
    
    ENDMODULE.                 " build_alv_grid  OUTPUT
    
    *&---------------------------------------------------------------------*
    *&      Form  exclude_tb_functions
    *&---------------------------------------------------------------------*
    *      <--P_LT_EXCLUDE  text
    *----------------------------------------------------------------------*
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
    
      DATA ls_exclude TYPE ui_func.
    
      REFRESH pt_exclude.
      CLEAR pt_exclude.
    
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_sum.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_filter.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_view_crystal.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_detail.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_info.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_refresh.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_check.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pt_exclude.
    
    ENDFORM.                    " exclude_tb_functions
    
    *&---------------------------------------------------------------------*
    *&      Form  build_sel_fieldcat
    *&---------------------------------------------------------------------*
    *      <--P_GS_FIELDCAT  text
    *----------------------------------------------------------------------*
    FORM build_sel_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
    
      DATA sfieldcat TYPE lvc_s_fcat.
    
      REFRESH pt_fieldcat.
    
    * BRCH
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'BRANCH'.
      sfieldcat-key           = 'X'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-outputlen     = '000004'.
      sfieldcat-scrtext_s     = 'Brch'.
      sfieldcat-scrtext_m     = 'Branch'.
      sfieldcat-scrtext_l     = 'Branch'.
      APPEND sfieldcat TO pt_fieldcat.
    * BRANCH NAM
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'BRTEXT'.
      sfieldcat-key           = 'X'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-scrtext_s     = 'Brch Name'.
      sfieldcat-scrtext_m     = 'Branch Name'.
      sfieldcat-scrtext_l     = 'Branch Name'.
      APPEND sfieldcat TO pt_fieldcat.
    * POSITION
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'POS_TYPE'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-no_out        = 'X'.
      sfieldcat-scrtext_s     = 'Position'.
      sfieldcat-scrtext_m     = 'Position'.
      sfieldcat-scrtext_l     = 'Position'.
      APPEND sfieldcat TO pt_fieldcat.
    * TITLE
      CLEAR sfieldcat.
      sfieldcat-outputlen     = '000025'.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'TITLE'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-scrtext_s     = 'Title'.
      sfieldcat-scrtext_m     = 'Title'.
      sfieldcat-scrtext_l     = 'Title'.
      APPEND sfieldcat TO pt_fieldcat.
    * EMP NO
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'EMPNO'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-no_out        = 'X'.
      sfieldcat-scrtext_s     = 'Employee #'.
      sfieldcat-scrtext_m     = 'Employee #'.
      sfieldcat-scrtext_l     = 'Employee #'.
      APPEND sfieldcat TO pt_fieldcat.
    * EMAIL
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'EMAIL'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-outputlen     = '000030'.
      sfieldcat-scrtext_s     = 'Email'.
      sfieldcat-scrtext_m     = 'Email Address'.
      sfieldcat-scrtext_l     = 'Email Address'.
      APPEND sfieldcat TO pt_fieldcat.
    * FIRST NAME
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'FNAME'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-scrtext_s     = 'First name'.
      sfieldcat-scrtext_m     = 'First name'.
      sfieldcat-scrtext_l     = 'First name'.
      APPEND sfieldcat TO pt_fieldcat.
    * LAST NAME
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'LNAME'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-scrtext_s     = 'Last name'.
      sfieldcat-scrtext_m     = 'Last name'.
      sfieldcat-scrtext_l     = 'Last name'.
      APPEND sfieldcat TO pt_fieldcat.
    * EMP STATUS
      CLEAR sfieldcat.
      sfieldcat-tabname       = 'IT_ALL_REPS'.
      sfieldcat-fieldname     = 'STATUS'.
    *  sfieldcat-hotspot       = 'X'.
      sfieldcat-scrtext_s     = 'Emp Status'.
      sfieldcat-scrtext_m     = 'Emp Status'.
      sfieldcat-scrtext_l     = 'Emp Status'.
      APPEND sfieldcat TO pt_fieldcat.
    
    
    ENDFORM.                    " build_sel_fieldcat
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 02:29 PM

    hi, it can be done easily.

    one option is create a dialog program in which in 1st screen u will get alv displayed and other screen as model dialog box and u have to handle all the button clicks

    second is create 2 reports call the second one from the first on the click event.

    for this in the method of hotspot or d-click event u can get all the data on what u had clicked than pass the those values with submit statement to cal the report.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 02:29 PM

    hi,

    check example program bcalv_grid_03. please search forums before posting as there are lot of examples avilable. you will get answers for all your questions.

    follwoing is the code for interactive alv.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = i_repid

    i_callback_user_command = 'USER_COMMAND_PERNR'

    it_fieldcat = header

    is_layout = gt_layout

    i_callback_top_of_page = 'TOP-OF-PAGE1'

    i_grid_title = text-t06

    it_sort = gt_sort[]

    i_default = 'X'

    i_save = 'U'

    is_variant = gt_variant

    it_events = gt_events

    TABLES

    t_outtab = ITAB.

    clear itab.

    endif.

    -


    FORM USER_COMMAND_PERNR

    -


    FORM USER_COMMAND_PERNR USING u_ucomm LIKE sy-ucomm

    us_selfield TYPE slis_selfield."#EC CALLED

    CASE u_ucomm.

    when '&IC1'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = i_repid

    it_fieldcat = header2

    is_layout = gt_layout2

    i_callback_top_of_page = 'TOP-OF-PAGE2'

    i_grid_title = text-t06

    i_default = 'X'

    i_save = 'U'

    is_variant = gt_variant2

    it_events = gt_events2

    TABLES

    t_outtab = ITAB2.

    ENDCASE.

    ENDFORM. " USER_COMMAND_PERNR

    Thanks.

    anupama.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 02:31 PM

    I used hot spots and handle it in the USER_COMMAND event.

    Something like this

    FORM user_command
            USING p_ucomm LIKE sy-ucomm
                  p_selfield TYPE slis_selfield.
    *
      IF p_selfield-value NE space.
        CASE p_selfield-tabname.
          WHEN 'IT_REPORT'.
            READ TABLE it_report INDEX p_selfield-tabindex 
                     "  with this read you have the entire row.
                      INTO rpt_rec.
          WHEN OTHERS.
            EXIT.
        ENDCASE.
      ELSE.
        EXIT.
      ENDIF.
    *
      CHECK sy-subrc = 0.
    *
      CASE p_selfield-fieldname.   " This gives you the ability to break it down by what field they 
                                                " clicked on
    *    WHEN 'QUOTE'.
    *      SET PARAMETER ID 'AGN' FIELD p_selfield-value.
    *      CALL TRANSACTION 'VA23' AND SKIP FIRST SCREEN.
    *    WHEN 'SALESORD'.
    *      SET PARAMETER ID 'AUN' FIELD p_selfield-value.
    *      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    *    WHEN 'NAME1'.
    *      SET PARAMETER ID 'KUN' FIELD RPT_REC-kunnr.
    *      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    *    WHEN 'LOTEVAL'.
    *      SET PARAMETER ID 'ZLOTNUM' FIELD p_selfield-value.
    *      SET PARAMETER ID 'KUN' FIELD RPT_REC-kunnr.
    *      CALL TRANSACTION 'ZLOT' AND SKIP FIRST SCREEN.
    *    WHEN 'CREDITAPP'.
    *      SET PARAMETER ID 'ZCRDNUM' FIELD p_selfield-value.
    *      SET PARAMETER ID 'KUN' FIELD RPT_REC-kunnr.
    *      CALL TRANSACTION 'ZCRD' AND SKIP FIRST SCREEN.
    *    WHEN 'PROJECT'.
    *      SET PARAMETER ID 'PSP' FIELD RPT_REC-project.
    *      CALL TRANSACTION 'CJ20N' AND SKIP FIRST SCREEN.
        WHEN 'ACCNO'.
          SET PARAMETER ID 'ZREO' FIELD p_selfield-value.
          CALL TRANSACTION 'ZREO' AND SKIP FIRST SCREEN.
    *    WHEN 'LEADID'.
    *      SET PARAMETER ID 'LEAD' FIELD rpt_rec-leadid.
    *      SET PARAMETER ID 'LMSMENU' FIELD 'N'.
    *      CALL TRANSACTION 'ZLM02' AND SKIP FIRST SCREEN.
    *
        WHEN OTHERS.
          EXIT.
      ENDCASE.
    *
    ENDFORM.                    "user_command
    

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 15, 2009 at 02:38 PM

    Is it feasible ? ==> Yes

    1.How can i transfer the selected row to the next pop up==>

      DATA: va_rows         TYPE lvc_t_row,
                va_row_no      TYPE lvc_t_roid.
    
    * Get selected row
      CALL METHOD gr_alvgrid->get_selected_rows
        IMPORTING
          et_index_rows = va_rows
          et_row_no       = va_row_no.
    
    *  Count rows
      DESCRIBE TABLE va_row_no LINES va_lines.
    

    2. Would it be easy to create that pop up as a screen or just an additional ALV ?

    Yes, create a screen with an ALV on it

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 16, 2009 at 04:49 AM

    Hi Ashish,

    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 solves your problem.

    Thanks & Regards,

    Tarun Gambhir

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.