Skip to Content
0
Jun 09, 2009 at 01:47 PM

ALV line selection

526 Views

Hi,

I have created an ALV grid which displays the data for me (see code below).

FORM create_alv .
  FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE,
                 <fcat> TYPE lvc_s_fcat.
  CHECK gv_alv_obj-defined IS INITIAL.
  gv_alv_obj-selection = gv_main_selection.
  CREATE OBJECT gv_alv_obj-container
    EXPORTING
      container_name = 'ALV_CONTAINER'.
  CREATE OBJECT gv_alv_obj-grid
    EXPORTING
      i_parent = gv_alv_obj-container.
  ASSIGN gt_outtab->* TO <outtab>.
  REFRESH gv_alv_obj-fcat.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = gv_alv_obj-structure_name
    CHANGING
      ct_fieldcat            = gv_alv_obj-fcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  READ TABLE gv_alv_obj-fcat ASSIGNING <fcat> WITH KEY fieldname = 'SPRAS'.
  IF sy-subrc = 0.    " found it so hide it.
    <fcat>-no_out = 'X'.
  ENDIF.
  gv_alv_obj-layout-no_toolbar = 'X'.
  gv_alv_obj-layout-zebra = 'X'.
  gv_alv_obj-layout-cwidth_opt = 'X'.
  gv_alv_obj-layout-no_merging = 'X'.
  gv_alv_obj-layout-sgl_clk_hd = 'X'.
  CALL METHOD gv_alv_obj-grid->set_table_for_first_display
    EXPORTING
      is_layout                     = gv_alv_obj-layout
    CHANGING
      it_outtab                     = <outtab>
      it_fieldcatalog               = gv_alv_obj-fcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
* Once the ALV has been defined set the defined flag.
  gv_alv_obj-defined = 'X'.
ENDFORM.                    " CREATE_ALV

On my main toolbar menu (not the ALV toolbar) I have a few icons.

1) Delete - think this is ok as when I delete a line the cursor moves to the 1st line of the

ALV grid; is this ok or should the cursor go somewhere else? how do I position it to particular row?

2) Copy - Details are copied to a new line I want to move to the copied line and highlight it ? how

3) Display/Modify - Goes to subscreen on exit of subscreen want to be at line where I entered