<?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: ALVGRID: Modify cell values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879488#M1140463</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Giovanni&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to use IMPORTING parameter &lt;STRONG&gt;IS_STABLE:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ls_stable-row = 'X'
ls_stable-col = 'X'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way you maintain the current positioning of the ALV list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Feb 2009 16:20:17 GMT</pubDate>
    <dc:creator>uwe_schieferstein</dc:creator>
    <dc:date>2009-02-02T16:20:17Z</dc:date>
    <item>
      <title>ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879483#M1140458</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;How do one edit a alvgrid?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 3 cell in one row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cell 1 = 20&lt;/P&gt;&lt;P&gt;cell 2 = 40&lt;/P&gt;&lt;P&gt;cell 3 = cell 1 + cell 2.&lt;/P&gt;&lt;P&gt;After ive executed the program, the alvgrid shows that cell 3 = 60&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I now want to be able to change the content of cell 1 and cell 2 and it must then update cell 3 automatically. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2008 12:13:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879483#M1140458</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-15T12:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879484#M1140459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Giovanni,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the below code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*----------------------------------------------------------------------*
*       CLASS lcl_event_responder DEFINITION                           *
*----------------------------------------------------------------------*
CLASS lcl_event_responder DEFINITION.
  PUBLIC SECTION.
    METHODS refresh_changed_data  FOR EVENT data_changed
                                  OF cl_gui_alv_grid
                                  IMPORTING er_data_changed
                                            e_ucomm.

ENDCLASS.                    "event_responder DEFINITION

TYPES : BEGIN OF ty_line,
        field1 TYPE i,
        field2 TYPE i,
        sum    TYPE i,
        END OF ty_line.

TYPES ty_table TYPE STANDARD TABLE OF ty_line.

DATA: go_container       TYPE REF TO cl_gui_custom_container,
      go_handler         TYPE REF TO lcl_event_responder,
      go_grid            TYPE REF TO cl_gui_alv_grid,
      gt_fieldcat        TYPE lvc_t_fcat,
      gt_outtab          TYPE ty_table WITH HEADER LINE.

FIELD-SYMBOLS : &amp;lt;field&amp;gt;.

CALL SCREEN 100.

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'BASIC'.
  PERFORM create_and_init_alv CHANGING gt_outtab[]
                                       gt_fieldcat.
ENDMODULE.                    "pbo OUTPUT
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai INPUT.
  LEAVE PROGRAM.
ENDMODULE.                    "pai INPUT



*&amp;amp;---------------------------------------------------------------------*
FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
                                  pt_fieldcat TYPE lvc_t_fcat.

  CHECK go_container IS NOT BOUND.

  CREATE OBJECT go_container
    EXPORTING
      container_name = 'CUSTOM'.

  CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_container.

  PERFORM build_display_table.

  PERFORM build_fieldcat CHANGING pt_fieldcat.

  go_grid-&amp;gt;set_table_for_first_display( CHANGING  it_fieldcatalog      = pt_fieldcat
                                                  it_outtab            = pt_outtab ).

  go_grid-&amp;gt;set_ready_for_input( 1 ).

* raises the 'data_changed' event when we select another cell/any action after changing the data
  go_grid-&amp;gt;register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=&amp;gt;mc_evt_modified ).

  CREATE OBJECT go_handler.

  SET HANDLER go_handler-&amp;gt;refresh_changed_data FOR go_grid.

ENDFORM.                               "CREATE_AND_INIT_ALV
*&amp;amp;---------------------------------------------------------------------*
FORM build_display_table.
  FREE gt_outtab.
  DO 10 TIMES.
    gt_outtab-field1 = sy-index.
    gt_outtab-field2 = sy-index * 2.
    gt_outtab-sum    = gt_outtab-field1 + gt_outtab-field2.
    APPEND gt_outtab.
  ENDDO.
ENDFORM.                               "build_display_table
*&amp;amp;---------------------------------------------------------------------*
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.

  DATA ls_fcat TYPE lvc_s_fcat.

  ls_fcat-fieldname = ls_fcat-reptext = 'FIELD1'.
  ls_fcat-edit       = abap_true.
  APPEND ls_fcat TO pt_fieldcat.
  ls_fcat-fieldname = ls_fcat-reptext = 'FIELD2'.
  ls_fcat-edit       = abap_true.
  APPEND ls_fcat TO pt_fieldcat.
  ls_fcat-fieldname = ls_fcat-reptext = 'SUM'.
  ls_fcat-edit       = abap_false.
  APPEND ls_fcat TO pt_fieldcat.
ENDFORM.                               "build_fieldcat

*---------------------------------------------------------------------*
*       CLASS event_responder IMPLEMENTATION                          *
*---------------------------------------------------------------------*
CLASS lcl_event_responder IMPLEMENTATION.
  METHOD refresh_changed_data.
    DATA : ls_modified TYPE lvc_s_modi,
           ls_line     TYPE ty_line.

    READ TABLE er_data_changed-&amp;gt;mt_mod_cells INTO ls_modified INDEX 1.
    CHECK sy-subrc EQ 0.
    READ TABLE gt_outtab INTO ls_line INDEX ls_modified-row_id.
    CHECK sy-subrc EQ 0.
    ASSIGN COMPONENT ls_modified-fieldname OF STRUCTURE ls_line TO &amp;lt;field&amp;gt;.
    MOVE ls_modified-value TO &amp;lt;field&amp;gt;.
    ls_line-sum = ls_line-field1 + ls_line-field2.
    MODIFY gt_outtab FROM ls_line INDEX ls_modified-row_id.
    go_grid-&amp;gt;refresh_table_display( ).
  ENDMETHOD.                    "refresh_changed_data
ENDCLASS.                    "event_responder IMPLEMENTATION&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Screen 100 has a custom control 'CUSTOM'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;screen flow logic..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PROCESS BEFORE OUTPUT.
  MODULE pbo.

PROCESS AFTER INPUT.
  MODULE pai.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2008 12:54:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879484#M1140459</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-15T12:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879485#M1140460</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;  Use:&lt;/P&gt;&lt;P&gt;getting current cell:&lt;/P&gt;&lt;P&gt;DATA: ld_row      TYPE i.&lt;/P&gt;&lt;P&gt;CALL METHOD go_grid1-&amp;gt;get_current_cell&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      e_row = ld_row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Krishna...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2008 13:43:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879485#M1140460</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-15T13:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879486#M1140461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jose&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Worked perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I now have a problem that when the line items in the alvgrid is more&lt;/P&gt;&lt;P&gt;that the screen size and you scroll down to edit the last row, the&lt;/P&gt;&lt;P&gt;cursor or screen jumps to the first screen when you use&lt;/P&gt;&lt;P&gt;go_grid-&amp;gt;refresh_table_display( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i ensure that the cursor jumps back to the cell/row that i've modified?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2009 14:15:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879486#M1140461</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-02T14:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879487#M1140462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;follow-up&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2009 14:24:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879487#M1140462</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-02T14:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879488#M1140463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Giovanni&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to use IMPORTING parameter &lt;STRONG&gt;IS_STABLE:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ls_stable-row = 'X'
ls_stable-col = 'X'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way you maintain the current positioning of the ALV list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2009 16:20:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879488#M1140463</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-02-02T16:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: ALVGRID: Modify cell values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879489#M1140464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Uwe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLASS lcl_event_responder IMPLEMENTATION.
  METHOD refresh_changed_data.
    DATA : ls_modified TYPE lvc_s_modi,
           ls_line     TYPE ty_line.
    DATA:  ls_stable TYPE lvc_s_stbl. "Added this line
                                                                                READ TABLE er_data_changed-&amp;gt;mt_mod_cells INTO ls_modified INDEX 1.
    CHECK sy-subrc EQ 0.
    READ TABLE gt_outtab INTO ls_line INDEX ls_modified-row_id.
    CHECK sy-subrc EQ 0.
    ASSIGN COMPONENT ls_modified-fieldname OF STRUCTURE ls_line TO &amp;lt;fs&amp;gt;.
    MOVE ls_modified-value TO &amp;lt;fs&amp;gt;.
    ls_line-sum = ls_line-field1 + ls_line-field2.
    MODIFY gt_outtab FROM ls_line INDEX ls_modified-row_id.
    ls_stable-row = 'X'.
    ls_stable-col = 'X'.
    go_grid-&amp;gt;refresh_table_display(   exporting is_stable = ls_stable ). "Changed this line


  ENDMETHOD.                    "refresh_changed_data
ENDCLASS.                    "event_responder IMPLEMENTATION&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2009 10:12:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alvgrid-modify-cell-values/m-p/4879489#M1140464</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-03T10:12:33Z</dc:date>
    </item>
  </channel>
</rss>

