<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ALV line selection in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722393#M1298310</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;To place your cursor on a particular field use the method 'SET_SELECTED_CELLS'&lt;/P&gt;&lt;P&gt;of the grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Jun 2009 13:53:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-09T13:53:57Z</dc:date>
    <item>
      <title>ALV line selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722392#M1298309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have created an ALV grid which displays the data for me (see code below).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM create_alv .
  FIELD-SYMBOLS: &amp;lt;outtab&amp;gt; TYPE STANDARD TABLE,
                 &amp;lt;fcat&amp;gt; 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-&amp;gt;* TO &amp;lt;outtab&amp;gt;.
  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 &amp;lt;&amp;gt; 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 &amp;lt;fcat&amp;gt; WITH KEY fieldname = 'SPRAS'.
  IF sy-subrc = 0.    " found it so hide it.
    &amp;lt;fcat&amp;gt;-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-&amp;gt;set_table_for_first_display
    EXPORTING
      is_layout                     = gv_alv_obj-layout
    CHANGING
      it_outtab                     = &amp;lt;outtab&amp;gt;
      it_fieldcatalog               = gv_alv_obj-fcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc &amp;lt;&amp;gt; 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
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;On my main toolbar menu (not the ALV toolbar) I have a few icons. &lt;/P&gt;&lt;P&gt;1) Delete - think this is ok as when I delete a line the cursor moves to the 1st line of the &lt;/P&gt;&lt;P&gt;   ALV grid; is this ok or should the cursor go somewhere else? how do I position it to particular row?&lt;/P&gt;&lt;P&gt;2) Copy - Details are copied to a new line I want to move to the copied line and highlight it ? how&lt;/P&gt;&lt;P&gt;3) Display/Modify - Goes to subscreen on exit of subscreen want to be at line where I entered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2009 13:47:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722392#M1298309</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-09T13:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV line selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722393#M1298310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;To place your cursor on a particular field use the method 'SET_SELECTED_CELLS'&lt;/P&gt;&lt;P&gt;of the grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2009 13:53:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722393#M1298310</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-09T13:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: ALV line selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722394#M1298311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Managed to do it via the following:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  SET_SELECTED_ROW
*&amp;amp;---------------------------------------------------------------------*
FORM set_selected_row .

* This defines a section of memory.
  FIELD-SYMBOLS: &amp;lt;outtab&amp;gt; TYPE STANDARD TABLE,    " This is the table.
                 &amp;lt;table_line&amp;gt; TYPE ANY,           " This is a row within the table.
                 &amp;lt;fld&amp;gt; TYPE ANY,                  " This holds the value in the field.
                 &amp;lt;key_value&amp;gt; TYPE ANY.            " This is the value in the field.

  DATA: lt_index_rows TYPE lvc_t_row,             " ALV control - Table rows.
        wa_index_row  LIKE LINE OF lt_index_rows, " Line of ALV control - Table rows.
        key_fname TYPE fieldname.                 " This is the name of the field.

* This statement references the same bit of memory thus both gt_outtab &amp;amp; outtab
* are pointing to the same thing so whatever happens to the local outtab will
* also happen to gt_outtab.
  ASSIGN gt_outtab-&amp;gt;* TO &amp;lt;outtab&amp;gt;.

  CASE gv_main_selection.
    WHEN co_funder.
      key_fname = co_funder.
      ASSIGN gv_selected_funder TO &amp;lt;key_value&amp;gt;.
    WHEN co_funder_type.
      key_fname = co_funder_type.
      ASSIGN gv_selected_funder_type TO &amp;lt;key_value&amp;gt;.
  ENDCASE.

* Loop at the table &amp;lt;outtab&amp;gt; into a work area (&amp;lt;table_line&amp;gt;).
  LOOP AT &amp;lt;outtab&amp;gt; ASSIGNING &amp;lt;table_line&amp;gt;.
*   The next statement processes the work_area (&amp;lt;table_line&amp;gt;)
*   and assigns the key field names (key_fname) to a field variable (&amp;lt;fld&amp;gt;)
    ASSIGN COMPONENT key_fname OF STRUCTURE &amp;lt;table_line&amp;gt; TO &amp;lt;fld&amp;gt;.
*   Next a check is made to see if the selected value (&amp;lt;key_value&amp;gt;) is same
*   as the value read in the field (&amp;lt;fld&amp;gt;) from above statement.
*   If different then the next iteration of the loop occurs.
    CHECK &amp;lt;fld&amp;gt; = &amp;lt;key_value&amp;gt;.
*   Field read (&amp;lt;fld&amp;gt;) is the same as the selected field value (&amp;lt;key_value&amp;gt;)
*   so set the row index (wa_index_row-index) to be that of loop index (sy-tabix)
    wa_index_row-index = sy-tabix.
*   Append the selected row to the ALV control - Table rows
    APPEND wa_index_row TO lt_index_rows.
    EXIT.
  ENDLOOP.

* Call the set_selected_rows method on the ALV grid.
  CALL METHOD gv_alv_obj-grid-&amp;gt;set_selected_rows
    EXPORTING
      it_index_rows = lt_index_rows.

ENDFORM.                    " SET_SELECTED_ROW&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 14:50:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-line-selection/m-p/5722394#M1298311</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-12T14:50:07Z</dc:date>
    </item>
  </channel>
</rss>

