At Line Selection on ALV Grid

Hi guys: I need to double click on a field in the ALV report that should bring up another structure (which I have created) called s_det
s_det has only document number & company code.
Please provide the code for doing this in ALV. I know I cant use At Line Selection. Please give me simple code.
thanks so much
Brian

Hi
take this as an example for ur solution.
In this if we double click on first level display then it opens second level display.Just have a look on the following code.
This is Interactive ALV report of displaying each row with colours and Headers.
TYPE-POOLS SLIS.
TYPES: BEGIN OF I_EKKO,
       EBELN LIKE EKKO-EBELN,
       AEDAT LIKE EKKO-AEDAT,
       BUKRS LIKE EKKO-BUKRS,
       BSART LIKE EKKO-BSART,
       LIFNR LIKE EKKO-LIFNR,
       L_COLOR(4) TYPE C,
       END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
      WA_EKKO TYPE I_EKKO.
TYPES: BEGIN OF I_EKPO,
       EBELN LIKE EKPO-EBELN,
       EBELP LIKE EKPO-EBELP,
       MATNR LIKE EKPO-MATNR,
       MENGE LIKE EKPO-MENGE,
       MEINS LIKE EKPO-MEINS,
       NETPR LIKE EKPO-NETPR,
       L_COLOR1(4) TYPE C,
       END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
      WA_EKPO TYPE I_EKPO.
DATA: V_REPID TYPE SY-REPID,
      I_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
      I_EVENTS TYPE SLIS_T_EVENT,
      WA_EVENT TYPE SLIS_ALV_EVENT,
      GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
      GD_LAYOUT1 TYPE SLIS_LAYOUT_ALV.
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST ALV REPORT',
      I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDARY ALV REPORT'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM FLDCATALOG.
PERFORM CALL_EVENTS.
PERFORM POPULATE_EVENT.
PERFORM BLD_LAYOUT.
PERFORM BLD_LAYOUT1.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM DISPLAY_ALV_REPORT.
FORM FLDCATALOG.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'EBELN'.
WA_FLDCAT-SELTEXT_M = 'PO NUMBER'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'AEDAT'.
WA_FLDCAT-SELTEXT_M = 'DATE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'BUKRS'.
WA_FLDCAT-SELTEXT_M = 'DOCUMENT TYPE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'LIFNR'.
WA_FLDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
ENDFORM.
FORM CALL_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
   I_LIST_TYPE           = 0
IMPORTING
   ET_EVENTS             = I_EVENTS
EXCEPTIONS
  LIST_TYPE_WRONG       = 1
  OTHERS                = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM POPULATE_EVENT.
*READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
*IF SY-SUBRC = 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY I_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-FORM.
*ENDIF.
READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
  WA_EVENT-FORM = 'USER_COMMAND'.
  MODIFY I_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-NAME.
ENDIF.
ENDFORM.
FORM BLD_LAYOUT.
GD_LAYOUT-INFO_FIELDNAME = 'L_COLOR'.
ENDFORM.
FORM DATA_RETRIEVAL.
DATA LN_COLOR(1) TYPE C.
SELECT EBELN AEDAT BUKRS BSART LIFNR
FROM EKKO INTO TABLE IT_EKKO.
LOOP AT IT_EKKO INTO WA_EKKO.
LN_COLOR = LN_COLOR + 1.
IF LN_COLOR = 8.
  LN_COLOR = 1.
ENDIF.
CONCATENATE 'C' LN_COLOR '11' INTO WA_EKKO-L_COLOR.
MODIFY IT_EKKO FROM WA_EKKO.
ENDLOOP.
ENDFORM.
FORM DISPLAY_ALV_REPORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
  I_INTERFACE_CHECK                 = ' '
  I_BYPASSING_BUFFER                = ' '
  I_BUFFER_ACTIVE                   = ' '
   I_CALLBACK_PROGRAM                = V_REPID
  I_CALLBACK_PF_STATUS_SET          = ' '
   I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
   I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
  I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
  I_CALLBACK_HTML_END_OF_LIST       = ' '
  I_STRUCTURE_NAME                  =
  I_BACKGROUND_ID                   = ' '
   I_GRID_TITLE                      = I_TITLE_EKKO
  I_GRID_SETTINGS                   =
   IS_LAYOUT                         = GD_LAYOUT
   IT_FIELDCAT                       = I_FLDCAT[]
  IT_EXCLUDING                      =
  IT_SPECIAL_GROUPS                 =
  IT_SORT                           =
  IT_FILTER                         =
  IS_SEL_HIDE                       =
  I_DEFAULT                         = 'X'
   I_SAVE                            = 'A'
  IS_VARIANT                        =
   IT_EVENTS                         = I_EVENTS
  IT_EVENT_EXIT                     =
  IS_PRINT                          =
  IS_REPREP_ID                      =
  I_SCREEN_START_COLUMN             = 0
  I_SCREEN_START_LINE               = 0
  I_SCREEN_END_COLUMN               = 0
  I_SCREEN_END_LINE                 = 0
  I_HTML_HEIGHT_TOP                 = 0
  I_HTML_HEIGHT_END                 = 0
  IT_ALV_GRAPHICS                   =
  IT_HYPERLINK                      =
  IT_ADD_FIELDCAT                   =
  IT_EXCEPT_QINFO                   =
  IR_SALV_FULLSCREEN_ADAPTER        =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER           =
  ES_EXIT_CAUSED_BY_USER            =
  TABLES
    T_OUTTAB                          = IT_EKKO
EXCEPTIONS
  PROGRAM_ERROR                     = 1
  OTHERS                            = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
      WA_HEADER TYPE SLIS_LISTHEADER.
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'THIS IS MY FIRST ALV'.
APPEND WA_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    IT_LIST_COMMENTARY       = T_HEADER
  I_LOGO                   =
  I_END_OF_LIST_GRID       =
  I_ALV_FORM               =
ENDFORM.
FORM USER_COMMAND USING R_COMM TYPE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
  CASE R_COMM.
    WHEN '&IC1'.
      READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
      PERFORM FLDCAT_EKPO.
      PERFORM CALL_EVENT_EKPO.
     PERFORM POPULATE_EVENT_EKPO.
      PERFORM DATA_RETRIEVAL_EKPO.
      PERFORM DISPLAY_ALV_REPORT_EKPO.
  ENDCASE.
ENDFORM.
FORM FLDCAT_EKPO.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'EBELN'.
WA_FLDCAT-SELTEXT_M = 'PO NUMBER'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_EKPO.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'EBELP'.
WA_FLDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_EKPO.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'MATNR'.
WA_FLDCAT-SELTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'MENGE'.
WA_FLDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'MEINS'.
WA_FLDCAT-SELTEXT_M = 'BASE UNIT OF MEASURE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'NETPR'.
WA_FLDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
ENDFORM.
FORM CALL_EVENT_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
   I_LIST_TYPE           = 0
IMPORTING
   ET_EVENTS             = I_EVENTS
EXCEPTIONS
  LIST_TYPE_WRONG       = 1
  OTHERS                = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
*FORM POPULATE_EVENT_EKPO.
*READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
*IF SY-SUBRC = 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY I_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-FORM.
*ENDIF.
*ENDFORM.
FORM BLD_LAYOUT1.
GD_LAYOUT1-INFO_FIELDNAME = 'L_COLOR1'.
ENDFORM.
FORM DATA_RETRIEVAL_EKPO.
DATA LN_COLOR1(1) TYPE C.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR
INTO TABLE IT_EKPO
FROM EKPO.
LOOP AT IT_EKPO INTO WA_EKPO.
LN_COLOR1 = LN_COLOR1 + 1.
IF LN_COLOR1 = 8.
  LN_COLOR1 = 1.
ENDIF.
CONCATENATE 'C' LN_COLOR1 '11' INTO WA_EKPO-L_COLOR1.
MODIFY IT_EKPO FROM WA_EKPO.
ENDLOOP.
ENDFORM.
FORM DISPLAY_ALV_REPORT_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
  I_INTERFACE_CHECK                 = ' '
  I_BYPASSING_BUFFER                = ' '
  I_BUFFER_ACTIVE                   = ' '
   I_CALLBACK_PROGRAM                = V_REPID
  I_CALLBACK_PF_STATUS_SET          = ' '
  I_CALLBACK_USER_COMMAND           = ' '
   I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE1'
  I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
  I_CALLBACK_HTML_END_OF_LIST       = ' '
  I_STRUCTURE_NAME                  =
  I_BACKGROUND_ID                   = ' '
   I_GRID_TITLE                      = I_TITLE_EKPO
  I_GRID_SETTINGS                   =
   IS_LAYOUT                         = GD_LAYOUT1
   IT_FIELDCAT                       = I_FLDCAT[]
  IT_EXCLUDING                      =
  IT_SPECIAL_GROUPS                 =
  IT_SORT                           =
  IT_FILTER                         =
  IS_SEL_HIDE                       =
  I_DEFAULT                         = 'X'
   I_SAVE                            = 'A'
  IS_VARIANT                        =
   IT_EVENTS                         = I_EVENTS
  IT_EVENT_EXIT                     =
  IS_PRINT                          =
  IS_REPREP_ID                      =
  I_SCREEN_START_COLUMN             = 0
  I_SCREEN_START_LINE               = 0
  I_SCREEN_END_COLUMN               = 0
  I_SCREEN_END_LINE                 = 0
  I_HTML_HEIGHT_TOP                 = 0
  I_HTML_HEIGHT_END                 = 0
  IT_ALV_GRAPHICS                   =
  IT_HYPERLINK                      =
  IT_ADD_FIELDCAT                   =
  IT_EXCEPT_QINFO                   =
  IR_SALV_FULLSCREEN_ADAPTER        =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER           =
  ES_EXIT_CAUSED_BY_USER            =
  TABLES
    T_OUTTAB                          = IT_EKPO
EXCEPTIONS
  PROGRAM_ERROR                     = 1
  OTHERS                            = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM TOP_OF_PAGE1.
DATA: T_HEADER1 TYPE SLIS_T_LISTHEADER,
      WA_HEADER1 TYPE SLIS_LISTHEADER.
WA_HEADER1-TYP = 'H'.
WA_HEADER1-INFO = 'SECONDARY ALV LEVEL'.
APPEND WA_HEADER1 TO T_HEADER1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    IT_LIST_COMMENTARY       = T_HEADER1
  I_LOGO                   =
  I_END_OF_LIST_GRID       =
  I_ALV_FORM               = .
ENDFORM.
reward points,if it is useful.
Thanks,
chandu.

Similar Messages

  • How do I find an event which is triggered on line selection for ALV grid?

    Hi,
    I'm trying to find an event which is triggered when a user selects a row in the ALV grid. I want to add my own code in to add up the total values of selected lines, but can't find any event which will trigger my method.
    I found CLICK_ROW_COL but it's protected so when I try and add a method for it:
      PROTECTED SECTION.
        METHODS:
        select_row
            FOR EVENT click_row_col OF cl_gui_alv_grid.
    I get the syntax error:
    Access to protected event "CLICK_ROW_COL" is not allowed.
    Am I using the right event? Am I implementing it correctly?
    Any help appreciated. Thanks in advance.
    Gill

    I chose to solve this by removing the line select buttons from the ALV and replacing them with a checkbox defined as a hotspot.  I then used EVENT hotspot_click FROM cl_gui_alv_grid to highlight the line and change my totals on a single click.

  • Multi Line Selection with ALV Grid

    Dear all
    what do I have to do to make multiple line selection available in an ALV Grid (Version 4.7)?
    Herbert

    Hi Herbert again,
    Once you displayed your alv output display, then select rows in the alv display.
    then when you click for interactive buttion (ie. like Refresh functionality), In debug mode you can see internal table with Sell field active (i.e. marked "X") which you have selected.
    e.g.
    FORM user_command USING lv_ucomm TYPE sy-ucomm ls_selfield TYPE slis_selfield.
      DATA:
            lv_ref_grid   TYPE REF TO cl_gui_alv_grid.
      CLEAR : gv_tcode.
    *-- to ensure that only new processed data is displayed
      IF lv_ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = lv_ref_grid.
      ENDIF.
      IF NOT lv_ref_grid IS INITIAL.
        CALL METHOD lv_ref_grid->check_changed_data.
      ENDIF.
      CASE lv_ucomm.
        WHEN '&IC1'.
          IF ls_selfield-fieldname = 'MATNR'.
            READ TABLE gt_gi INTO gs_gi INDEX ls_selfield-tabindex.
            IF sy-subrc = 0.
              gv_tcode = 'MMBE'.
              SET PARAMETER ID 'MAT' FIELD gs_gi-matnr.
              CALL TRANSACTION gv_tcode AND SKIP FIRST SCREEN. "#EC CI_CALLTA "MMBE
            ENDIF.
          ENDIF.
        WHEN 'COPY'.
          LOOP AT gt_gi INTO gs_gi WHERE sel = 'X'.
            gs_gi-sel = ' '.
            APPEND gs_gi TO gt_gi.
            CLEAR gs_gi.
          ENDLOOP.
        WHEN 'POST'.
          REFRESH : gt_error[].
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    " USER_COMMAND
    I hope you clear now.
    Feel free to ask any doubts.
    Thanks and regards,
    Vijay

  • How to sense which lines are selected in ALV grid with Reuse FM.

    Hi!;
    with the help of the forum I have developed a ALV grid whose first column is a editable checkbox.
    The user click some of the lines on the ALV grid and I added an additional button on the tooolbar named "ACCEPT".
    When the button ACCEPT is clicked I want to get the lines whose checkbox is checked.
    How can I do that ?
    Making the first column (Checkbox column ) hotspot of no help.
    Would you please help me ?
    Erkan
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Sep 14, 2011 3:05 PM

    hi,
    you can refer the below link:
    /thread/492162 [original link is broken]

  • AT line selection in ALV

    Hi Experts,
    How to apply the below logic in ALV. ( how to apply at line selection in ALV )
    AT LINE-SELECTION.
      DATA NO TYPE I.
      DATA F(16).
      DATA G(16).
      CASE SY-LSIND.
        WHEN 1.
          GET CURSOR FIELD F.
          IF F EQ 'IT_FIRST-MATNR'.
            PERFORM DRILL_DOWN.
          ENDIF.
      ENDCASE.
    FORM DRILL_DOWN.
    LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR
                        AND WERKS = IT_FIRST-WERKS.
    WRITE: /2 IT_EBAN-BANFN,
               15 IT_EBAN-FKZTX,
               35 IT_EBAN-MENGE,
               55 IT_EBAN-MEINS.
      ENDLOOP.
    ENDFORM.

    Hi,
    When an Interactive Report is needed in Classical Display, we go for AT LINE-SELECTION. But when the same is needed in ALV Display, this method won't work. Instead, we need to use other way which is explained below:
    We use REUSE_ALV_GRID_DISPLAY for ALV Display. Now, normally we call that FM in the following way:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = 'PROGRAM_NAME'
    it_fieldcat = tb_fieldcat
    TABLES
    t_outtab = tb_output.
    When it is needed to get an Interactive ALV, call the same FM in the following manner:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = 'ZTEST75599_1'
    it_fieldcat = tb_fieldcat
    i_callback_user_command = 'USER_COMMAND'
    TABLES
    t_outtab = tb_output.
    Now, in the report, create a subroutine with the name USER_COMMAND as follows:
    FORM user_command USING p_ucomm LIKE sy-ucomm
    p_selfield TYPE slis_selfield.
    CASE p_ucomm.
    WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
    Based on the requirement, write the logic *
    ENDCASE.
    ENDFORM.
    No need to call the subroutine as PERFORM user_command. This will be takane care by REUSE_ALV_GRID_DISPLAY. We need to just write the subroutine in the report. That suffices.
    Some more useful points for Interactive ALV:
    1. If Hotspot is needed, then that should be done by declaring hotspot (one field in slis_t_fieldcat_alv) as 'X' in tb_fieldcat which is of type slis_t_fieldcat_alv. When hotspot is active, single click will be enough or else you should double click on the output data.
    2. In Classical Display, when it is needed to read the record on which we double clicked, we do that in following way:
    AT LINE-SELECTION.
    GET CURSOR LINE wf_line. " wf_line gives the line number on which it has been clicked
    READ LINE wf_line OF CURRENT PAGE.
    But this won't work for ALV. Instead, the following logic can be used:
    FORM user_command USING p_ucomm LIKE sy-ucomm
    p_selfield TYPE slis_selfield.
    CASE p_ucomm.
    WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
    READ TABLE tb_output INTO wa_output INDEX p_selfield-tabindex.
    IF sy-subrc EQ 0.
    Based on the requirement, write the logic *
    ENDIF.
    ENDCASE.
    ENDFORM.
    Hope this helps you...

  • At Line-selection in ALV for more than one field.

    How to use At Line-selection in ALV Basic Report where there are more than one field for displaying Secondary Lists.
    Ex: In Basic List there are 3 fields Volume_m Volume_y and Volume_i.When i click on any of the field i need to display the secondary list for that particular field.

    Hi Pavan,
                  Use User-command event of ALV.
    Refer this code :
    form BUILD_EVENTCAT  using    p_i_eventcat TYPE SLIS_T_EVENT.
    DATA: I_EVENT TYPE SLIS_ALV_EVENT.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = P_I_EVENTCAT
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      clear I_event.
      read table p_i_eventcat with key name = slis_ev_user_command into I_event.
      if sy-subrc = 0.
        move 'USER_COMMAND' to I_event-form.
        append I_event to p_i_eventcat.
      endif.
    form USER_COMMAND' using p_ucomm type sy-ucomm
                               p_selfield type slis_selfield.
      case p_ucomm.
      WHEN '&IC1'.                       "&IC1 is the Fcode for double click
    Use  P_ELFIELD-VALUE  for further processing . this  will contain the value on which u will double click
    endcase.
    Reward points if helpful.
    Regards,
    Hemant

  • Select From ALV Grid

    I'm hoping that someone can help.
    I have a program that displays an ALV grid. I want the user to be able to select one or more lines from this grid and then to pop up a box to allow them to input a new date and then update this date via BAPI.
    Could any one please point me in the right direction of how to get the info of the lines selected by the user into another internal table so that I can merge this with my new date info to run the BAPI.
    Thanks

    Which version of ALV technology do you use (REUSE_ALV, OO ALV, SALV ? ) <br />
    <br />
    e.g. for CL_GUI_ALV_GRID<br />
    - Use the <a class="jive-link-external" href="http://help.sap.com/saphelp_erp2004/helpdata/en/ef/a2e9eff88311d2b48d006094192fe3/frameset.htm" target="_newWindow">SEL_MODE</a> field of the layout to enable multiple row selection (also add a check box in internal table)<br />
    - you have method <a class="jive-link-external" href="http://help.sap.com/saphelp_erp2004/helpdata/EN/0a/b55312d30911d2b467006094192fe3/frameset.htm" target="_newWindow">GET_SELECTED_ROWS</a> and CHECK_CHANGED_DATA <br />
    <br />
    <i>Also, don't hesitate to use the search tool.there are sample in wiki like [Capture single and multiple row selction in ALV |http://wiki.sdn.sap.com/wiki/display/Snippets/Capturesingleandmultiplerowselctionin+ALV]</i><br />
    <br />
    Regards,<br />
    Raymond

  • Single row select in ALV Grid

    HI,
    I want to make my ALV Grid only single row select enabled, can some one guide me which variable should be set for the same.
    Thanks and Regards,
    Harsh

    If you are using OO for alv then
      call method grid1->get_selected_rows
        importing
          et_index_rows = i_sel_alvrows[].
      call method cl_gui_cfw=>flush.
      describe table i_sel_alvrows lines v_dbcnt.
      if i_sel_alvrows[] is initial.
    * Info message : Please select a row
        message i176.                        " Please select a row'.
      endif.
      if v_dbcnt gt 1.
    * Info message : Multiple Row Selection not  possible
        message i177.                        " Multiple Row Selection not
        " possible'
      endif.
    or if your using REUSE then
    form user_command using p_ucomm type sy-ucomm
                         rs_selfield type  slis_selfield.
    " Check the rs_selfield-tabindex value here
    " you may get some clue here
    endform.

  • Multilple line selection in alv

    Hi All,
    I am dispalying a simple alv grid report using function module
    reuse_alv_grid_display.i have used check box for selection but it is only applicable for single selection.Could anybody tell me how to select multiple line items at a time without using control key.if somebody provide the sample code it will be more helpful.
    Regards
    Lalit

    Hi,
    Please refer to the standard demo program.
    BCALV_EDIT_05
    or Search as BCALV_EDIT* and press F4.
    OR
    Please refer to the code below:
    *& Report  ZDEMO_ALVGRID_SELROW                                        *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display capture each row a user has *
    *& selected                                                            *
    REPORT  zdemo_alvgrid_selrow                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      SEl,                         "stores which row user has selected
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-box_fieldname     = 'SEL'.
                                     "set field name to store row selection
      gd_layout-edit              = 'X'. "makes whole ALV table editable
      gd_layout-zebra             = 'X'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into corresponding fields of table it_ekko.
    endform.                    " DATA_RETRIEVAL
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
        WHEN '&DATA_SAVE'.  "user presses SAVE
        loop at it_ekko into wa_ekko.
          if wa_ekko-sel EQ 'X'.
    *       Process records that have been selected
          endif.
        endloop.
      ENDCASE.
    ENDFORM.
    Thanks,
    Sriram Ponna
    Edited by: Sriram Ponna on Feb 8, 2008 9:31 PM

  • Multiple Selection in ALV grid

    HI All,
    I am displaying output using ALV grid method. On screen i am selecting multiple rows & based on selection i want process further. How can i determine whcih rows user has selected ?
    Regards,
    Rahul

    Hi,
    In IT_FIELDCAT you can pass one field with attributes of check box.
    for example.
    Declare:
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT.
    Pass the below values.
    FIELDCAT_LN-FIELDNAME = 'CHECK'.
    FIELDCAT_LN-TABNAME = 'ITAB1'.
    FIELDCAT_LN-KEY = ' '. "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT = ' '.
    FIELDCAT_LN-SELTEXT_L = 'Check Box'.
    FIELDCAT_LN-CHECK-BOX = 'X'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    <b>rEWARD IF USEFULL</b>

  • At line selection in alv report

    hi,
    i had developed a code in which at 1st execution the normal output is displayed and if i click on a purticular Itemid it displays the whole of items  and i want to display only that item's data which i had clicked on.
    following is the code which i am using for the at line-selection.
    **BEGIN - TEST CODE FOR LINE SELECTION**
    data: fld LIKE ITAB-ITEMID,
          val LIKE ITAB-ITEMID.
    at line-selection.
      get cursor field fld value val.
      IF fld = 'ITAB-ITEMID'.
            SET PARAMETER ID 'ANR' FIELD val.
            CLEAR ITAB-ITEMID.
      ENDIF.
        PERFORM PRN_SMSTOCK_ALV USING VAL.
        IF SY-SUBRC <> 0.
          MESSAGE 'NO RECORD FOUND' TYPE 'W'.
        ENDIF.
      FORM PRN_SMSTOCK_ALV USING VAL.
    *****END OF TEST CODE FOR LINE SELECTION******
    plzz help me out by providing the solution for this problem.

    Hi,
    You need to add extra piece of code as below:
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'
                I_callback_user_command = 'USER_COMMAND'   "see FORM
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    "For further information please refer the link below :
    http://www.sapdev.co.uk/reporting/alv/alvgrid_ucomm.htm
    Thanks,
    Sriram Ponna.

  • Single selection in ALV Grid Control

    hi,
    I want to enable single row selection only in the alv grid displayed.
    attribute sel_mode of layout doesnt help.
    Can anybody provide me a solution.
    Regards,
    Auro

    Hello,
    Try this:
    DATA:gs_layout type lvc_s_layo.
    gs_layout-NO_ROWMARK = 'X'.
    call method g_grid->set_table_for_first_display
           exporting is_layout             = gs_layout
    Regards,
    Beejal
    **reward if this helps

  • TOP-OF-PAGE During line-selection in alv report

    Hi Expart
    In intractive Alv report u using top-of-page during line-selection . If u using so u give me one example with codeing .
    Regards
    Bhabani

    Hi,
    try this code...
    *& Report  ZCS_PRG8
    REPORT  Z_SJALV__PRG8.
    TYPE-POOLS: SLIS.
    *type declaration for values from ekko
    TYPES: BEGIN OF I_EKKO,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           BUKRS LIKE EKKO-BUKRS,
           BSART LIKE EKKO-BSART,
           LIFNR LIKE EKKO-LIFNR,
           END OF I_EKKO.
    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
          WA_EKKO TYPE I_EKKO.
    *type declaration for values from ekpo
    TYPES: BEGIN OF I_EKPO,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           MENGE LIKE EKPO-MENGE,
           MEINS LIKE EKPO-MEINS,
           NETPR LIKE EKPO-NETPR,
           END OF I_EKPO.
    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
          WA_EKPO TYPE I_EKPO .
    *variable for Report ID
    DATA: V_REPID LIKE SY-REPID .
    *declaration for fieldcatalog
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    declaration for events table where user comand or set PF status will
    be defined
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENT TYPE SLIS_ALV_EVENT.
    declartion for layout
    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    declaration for variant(type of display we want)
    DATA: I_VARIANT TYPE DISVARIANT,
          I_VARIANT1 TYPE DISVARIANT,
          I_SAVE(1) TYPE C.
    *PARAMETERS : p_var TYPE disvariant-variant.
    *Title displayed when the alv list is displayed
    DATA:  I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
    DATA:  I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
    INITIALIZATION.
      V_REPID = SY-REPID.
      PERFORM BUILD_FIELDCATLOG.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATLOG
          Fieldcatalog has all the field details from ekko
    FORM BUILD_FIELDCATLOG.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'AEDAT'.
      WA_FIELDCAT-SELTEXT_M = 'DATE.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'LIFNR'.
      WA_FIELDCAT-NO_OUT    = 'X'.
      WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCATLOG
    *&      Form  EVENT_CALL
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    EXCEPTIONS
       LIST_TYPE_WRONG       = 1
       OTHERS                = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "EVENT_CALL
    *&      Form  POPULATE_EVENT
         Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'USER_COMMAND'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-NAME.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    *&      Form  data_retrieval
      retreiving values from the database table ekko
    FORM DATA_RETRIEVAL.
      SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
    ENDFORM.                    "data_retrieval
    *&      Form  bUild_listheader
          text
         -->I_LISTHEADEtext
    FORM BUILD_LISTHEADER USING IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
      DATA HLINE TYPE SLIS_LISTHEADER.
      HLINE-INFO = 'this is my first alv pgm'.
      HLINE-TYP = 'H'.
    ENDFORM.                    "build_listheader
    *&      Form  display_alv_report
          text
    FORM DISPLAY_ALV_REPORT.
      V_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = V_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
         I_GRID_TITLE                      = I_TITLE_EKKO
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         = ALV_LAYOUT
         IT_FIELDCAT                       = I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
        i_default                         = 'ZLAY1'
         I_SAVE                            = 'A'
        is_variant                        = i_variant
         IT_EVENTS                         = V_EVENTS
        TABLES
          T_OUTTAB                          = IT_EKKO
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_alv_report
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
       i_logo                   =
       I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
          PERFORM BUILD_FIELDCATLOG_EKPO.
          PERFORM EVENT_CALL_EKPO.
          PERFORM POPULATE_EVENT_EKPO.
          PERFORM DATA_RETRIEVAL_EKPO.
          PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
          PERFORM DISPLAY_ALV_EKPO.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  BUILD_FIELDCATLOG_EKPO
          text
    FORM BUILD_FIELDCATLOG_EKPO.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELP'.
      WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MENGE'.
      WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-SELTEXT_M = 'UOM'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'NETPR'.
      WA_FIELDCAT-SELTEXT_M = 'PRICE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCATLOG_EKPO
    *&      Form  event_call_ekpo
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL_EKPO.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "event_call_ekpo
    *&      Form  POPULATE_EVENT
           Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT_EKPO.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
      ENDFORM.                    "POPULATE_EVENT
    *&      Form  TOP_OF_PAGE
          text
    FORM F_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
       i_logo                   =
       I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    *retreiving values from the database table ekko
    FORM DATA_RETRIEVAL_EKPO.
    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
    ENDFORM.
    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    FORM DISPLAY_ALV_EKPO.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = V_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
       I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = I_TITLE_EKPO
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         =
       I_SAVE                            = 'A'
      IS_VARIANT                        =
       IT_EVENTS                         = V_EVENTS
      TABLES
        T_OUTTAB                          = IT_EKPO
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.
    reward if helpful
    regards
    Shashi

  • How to process Line Selection on ALV Table in ABAP WebDynpro

    Hi there,
    I have a view with an ALV table whose context node retrieves its data from a Service Call for a method.
    The method provides certain data of a database table which the ALV displays.
    Now I would like to be able to select one row of that ALV table and after pressing a button or doubleclicking on the row or whatever a different view (as for me it is also ok on the same view) should appear to display the details of that selection.
    I only need to know how to retrieve the selected data.
    Or its index within the internal table.
    I am already looking for hours for a useful thread and actually there is one which obviously is about a similar issue apart from the multiple selection part: 
    How to process multiple row selection in ALV table in Wendynpro ABAP? Help!
    but i am afraid that i don't understand it. Or at least I misunderstand it since it does not work with me.
    The system example mentioned in the thread does not help me either because it somehow does not correspond to my needs, does it?
    It would be GREAT if somebody could help me with that. Please keep it simple for I am not an expert in webdynpro yet (obviously ^^) and also please explain in detail what I have to do with the context nodes since I am not sure whether the selection is stored in my already existing node or whether I need a special one for that.
    Thanks!!
    christina

    Hi Christina,
    If you just want to get one column data of the line that user clicked, use the Web Dynpro Code Wizard to Read Context of attibute you needed, then you will get code as follow:
    * Define data for read attribute
        node_alv TYPE REF TO if_wd_context_node,
        elem_alv TYPE REF TO if_wd_context_element,
        stru_alv TYPE if_view_display=>element_alv ,
        item_column_name  LIKE stru_alv-column_name.
    * navigate from <CONTEXT> to <ALV> via lead selection
      node_alv = wd_context->get_child_node( name = if_view_display=>wdctx_alv ).
    * get element via lead selection
      elem_alv = node_alv->get_element(  ).
    * get single attribute
      elem_alv->get_attribute(
        EXPORTING
          name =  `COLUMN_NAME'
        IMPORTING
          value = item_column_name ).
    The value of column_name is stored in item_column_name.
    If you need the index that the user clicked, try this:
    * Definition of field symbol for index
      FIELD-SYMBOLS : <fs_index> TYPE data.
    * Get the selected index
      ASSIGN r_param->index->* TO <fs_index>.
    The index of clicked line is stored in field symbol <fs_index>.
    Hope it will help.
    Best Regards,
    Stephanie

  • At line selection for ALV

    Hello experts ,
    can anybody plz tell me How to implement the line selection event in alv ? I want to retrieve value of the filed clicked by the user and query another table with that field value and display that data ....

    Hi,
    Below is the sample code.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           I_CALLBACK_PROGRAM = G_REPID
           I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
           IT_FIELDCAT        = i_FCAT[]
         TABLES
           T_OUTTAB           = i_invoice[]
         EXCEPTIONS
           PROGRAM_ERROR      = 1
           OTHERS             = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    FORM user_command USING pv_ucomm    TYPE syucomm
                            ps_selfield TYPE slis_selfield.
    *Handle the specific user-commands.                                    *
      CASE pv_ucomm.
    Or some other GUI-functions                                         *
    Handle double click or hotspot on a specific field.                  *
    These are some examples                                              *
        WHEN gc_double_click.
          CASE ps_selfield-fieldname.
            WHEN 'BELNR'.
              i_invoice-belnr = g_belnr.
              i_invoice-gjahr = g_gjahr.
              READ TABLE i_invoice INDEX ps_selfield-tabindex.
              IF sy-subrc EQ 0 AND NOT i_invoice-belnr IS INITIAL.
                SET PARAMETER ID 'RBN' FIELD i_invoice-belnr.
                SET PARAMETER ID 'GJR' FIELD i_invoice-gjahr.
                CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
              ENDIF.
            WHEN 'EBELN'.
              READ TABLE i_invoice INDEX ps_selfield-tabindex.
              IF sy-subrc EQ 0 AND NOT i_invoice IS INITIAL.
                SET PARAMETER ID 'BES' FIELD i_invoice-ebeln.
                CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
              ENDIF.
          endcase.
      endcase.
    endform.                    "user_command
    Regards,
    Jayanth G

Maybe you are looking for

  • File name issue in mail adapter attachement.

    HI all, i built a scenario proxy to mail in which the data will be sent as attachement to the mail id coming from proxy it self. I added the transform bean and xi mail adapter bean correctly.. The scenario is working fine without errors... however th

  • What are the steps of EBS 11i with database 9i cloning steps in WInd 2003.

    HI, Please provide the any metalink doc or private blog url for clonning the EBS 11i with database 9iR2 in windows 2003 OS. Regards

  • Ability to Queue Rather than "Open" Hundreds of Files

    Problem: I have 500 JPEG files to edit in Photoshop.  I cannot "open" more than 200 files at once for editing. Solution: Make a "Queue" option to allow me to queue as many files as I desire.  Only one file will be open at a time for editing, and when

  • Which classes are inherent in the Java language?

    For some reason I just thought of the question this past 2AM. What classes are significant to the Java compiler? The list I thought of was: Object -- implements wait() and synchronized String -- all those convenience idioms we couldn't live without S

  • Home Hub 2 & https time out issues

    I have had a new HH2 for the last few weeks and have realised that since fitting the Hub, I am having issues with accessing secure sites (https).  I find that as I go through the security that a bank or similar would ask for, there is a long delay be