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: 

Select a field on ALV Grid

Former Member
0 Kudos

Experts,

This may not be a simple question. I have a simple ALV grid display of an extract of many fields from many tables that is used to validate testing. Is there an easy way to select(mouse click on) a value for a field on the screen and you will navigate to where that value for that field can be found. Any code, references will be appreciated.

Thank-You.

1 REPLY 1

former_member188685
Active Contributor
0 Kudos

Hi,

You need to some thing like this way...

report  ztest_alv_check     message-id zz           .
type-pools: slis.
data: x_fieldcat type slis_fieldcat_alv,
      it_fieldcat type slis_t_fieldcat_alv,
      l_layout type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type slis_t_event.

data: begin of itab occurs 0,
      vbeln like vbak-vbeln,
      posnr like vbap-posnr,
      chk(1),
     end of itab.

select vbeln
       posnr
       from vbap
       up to 20 rows
       into table itab.

x_fieldcat-fieldname = 'CHK'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-checkbox = 'X'.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-hotspot = 'X'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.


l_layout-zebra = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
    i_callback_program       = sy-repid
    is_layout                = l_layout
    i_callback_pf_status_set = 'STATUS'
    i_callback_user_command  = 'USER_COMMAND'
    it_fieldcat              = it_fieldcat
  tables
    t_outtab                 = itab
  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  STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
form status using p_extab type slis_t_extab.
*- Pf status
  set pf-status 'STATUS'.
endform.                 " STATUS

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form user_command using r_ucomm     like sy-ucomm
                               rs_selfield type slis_selfield.

<b>  case r_ucomm.

    when 'BACK' or 'CANC' or 'EXIT'.
      leave to screen 0.
    when '&IC1'.
      if rs_selfield-fieldname = 'VBELN'.
        set parameter id 'AUN' field rs_selfield-value.
        call transaction 'VA03' and skip first screen.
      endif.
  endcase.</b>
endform.                    "USER_COMMAND

Regards

vijay