<?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 GRID insert delete row in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268016#M781070</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Additionally, to copy any changes to your internal table... use method &lt;/P&gt;&lt;P&gt;  CALL METHOD grid-&amp;gt;check_changed_data. in your PAI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I forgot to mention in my previous response.&lt;/P&gt;&lt;P&gt;Use &lt;/P&gt;&lt;P&gt;    CALL METHOD grid-&amp;gt;set_toolbar_interactive. -- in your PBO..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jan 2008 06:00:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-08T06:00:41Z</dc:date>
    <item>
      <title>ALV GRID insert delete row</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268011#M781065</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 want to add / delete rows in an alv grid.I found BCALV_EDIT_04.but it is very complicated.can u tell me how can i do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Jan 2008 16:01:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268011#M781065</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-05T16:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: ALV GRID insert delete row</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268012#M781066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this blog..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/srilatha.t/blog/2007/04/13/alv-grid--delete-row-function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Maha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Jan 2008 18:37:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268012#M781066</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-05T18:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: ALV GRID insert delete row</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268013#M781067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi burc,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this  simple code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****To identify the selected records to delete  declare a field&lt;/P&gt;&lt;P&gt;****flag to layout&lt;/P&gt;&lt;P&gt;  gs_layout-box_fieldname = 'FLAG'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            i_callback_program       = ws_repid&lt;/P&gt;&lt;P&gt;            i_callback_pf_status_set = 'GUI_STAT'&lt;/P&gt;&lt;P&gt;            i_callback_user_command  = 'STAT'&lt;/P&gt;&lt;P&gt;            is_layout                = gs_layout&lt;/P&gt;&lt;P&gt;            it_fieldcat              = i_fieldcat[]&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            t_outtab                 = i_zaw_pol_plan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;     MESSAGE----&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ENDFORM.                    " change_data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**--Setting Status of outout screen&lt;/P&gt;&lt;P&gt;FORM gui_stat USING rt_extab TYPE slis_t_extab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****In your PF status add button Delete&lt;/P&gt;&lt;P&gt;  SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.&lt;/P&gt;&lt;P&gt;  SET TITLEBAR text-005.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**--Calling the subroutine when button clicked on output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM stat USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA selfield TYPE slis_selfield.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CASE r_ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**--When Delete Button Pressed&lt;/P&gt;&lt;P&gt;    WHEN 'DELE'.&lt;/P&gt;&lt;P&gt;        LOOP AT internal table WHERE flag EQ c_x.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          DELETE   the record from internal table or database &lt;/P&gt;&lt;P&gt;                         table &lt;/P&gt;&lt;P&gt;                                &lt;/P&gt;&lt;P&gt;         ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ADD also same when press add button insert the records in internal table or database tables and refresh the output layout screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to refresh the screen aftyer adding or deleting write below code.&lt;/P&gt;&lt;P&gt;DATA ref1 TYPE REF TO cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'&lt;/P&gt;&lt;P&gt;         IMPORTING&lt;/P&gt;&lt;P&gt;              e_grid = ref1.&lt;/P&gt;&lt;P&gt;    CALL METHOD ref1-&amp;gt;check_changed_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CALL METHOD ref1-&amp;gt;refresh_table_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward if useful....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDCASE.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2008 04:23:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268013#M781067</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-07T04:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: ALV GRID insert delete row</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268014#M781068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why do you insist on using Dinosaur Technology (the old way) for ALV grids&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The real SIMPLE way using the new cl_gui_alv_grid class is simply to display your table in EDIT mode; You'll then see on a standard toolbar the Insert / delete lines. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to do any special coding or event handling.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This also ensures the Grid is EDITABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a simple program that does just this. It reads 200 entries from VAPMA and displays them in an editable grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will work for almost any structure as it builds a dynamic FCAT and Dynamic table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ensure you have a simple screen (100)  with just a custom control on it called CCONTAINER1 and a simple ststus (SE41) with BACK EXIT and CANCEL buttons on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

Program ZZZ_SIMPLE_EDITABLE_GRID.

* Define any structure
types:  begin of s_elements,
  vbeln   type vapma-vbeln,
  posnr   type vapma-posnr,
  matnr   type vapma-matnr,
  kunnr   type vapma-kunnr,
  werks   type vapma-werks,
  vkorg   type vapma-vkorg,
  vkbur   type vapma-vkbur,
  status  type c,

end of  s_elements.

* end of your structure
tables: vapma.
data lr_rtti_struc type ref to cl_abap_structdescr .
data:
    zog                     like line of lr_rtti_struc-&amp;gt;components .
  data:
    zogt                    like table of zog,
  wa_it_fldcat type lvc_s_fcat,
  it_fldcat type lvc_t_fcat ,
  dy_line            type ref to data,
  dy_table           type ref to data.


 data:  dref               type ref to data.
 field-symbols: &amp;lt;fs&amp;gt; type any,
    &amp;lt;dyn_table&amp;gt;    type  standard table,
    &amp;lt;dyn_wa&amp;gt;.

data grid_container1 type ref to cl_gui_custom_container .
  data grid1 type ref to cl_gui_alv_grid .
data: ok_code type sy-ucomm.
data: STRUCT_GRID_LSET type lvc_s_layo.
*now I want to build a field catalog
* First get your data structure into a field symbol
create data dref type s_elements.
  assign dref-&amp;gt;* to &amp;lt;fs&amp;gt;.

  lr_rtti_struc ?= cl_abap_structdescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

    zogt[]  = lr_rtti_struc-&amp;gt;components.
 loop at zogt into zog.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = zog-name .
      wa_it_fldcat-datatype = zog-type_kind.
      wa_it_fldcat-inttype = zog-type_kind.
      wa_it_fldcat-intlen = zog-length.
      wa_it_fldcat-decimals = zog-decimals.
      wa_it_fldcat-coltext = zog-name.
      wa_it_fldcat-lowercase = 'X'.
      append wa_it_fldcat to it_fldcat .
    endloop.
* Let's create a dynamic table and populate it

call method cl_alv_table_create=&amp;gt;create_dynamic_table
       exporting
            it_fieldcatalog = it_fldcat
       importing
            ep_table = dy_table.


assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.
  create data dy_line like line of &amp;lt;dyn_table&amp;gt;.
  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.
* Fill the dynamic table
  select vbeln posnr matnr kunnr werks vkorg vkbur
         up to 200 rows
         from vapma
         into  corresponding fields of table &amp;lt;dyn_table&amp;gt;.
* display grid via screen call.
call screen 100.

module status_0100 output.

if grid_container1 is initial.
create object grid_container1
        exporting
           container_name = 'CCONTAINER1'.
    create object  grid1
       exporting
          i_parent = grid_container1.
  struct_grid_lset-edit = 'X'.    "To enable editing in ALV

call method grid1-&amp;gt;set_table_for_first_display
  exporting is_layout =  struct_grid_lset
  changing
             it_outtab       = &amp;lt;dyn_table&amp;gt;
             it_fieldcatalog = it_fldcat.


endif.
set pf-status '001'.
     set titlebar '000'.

endmodule.

  MODULE user_command_0100 INPUT.
      case sy-ucomm.
    when 'BACK'.
      leave program.
    when 'EXIT'.
      leave program.
    when 'RETURN'.
      leave program.
    when others.
  endcase.
endmodule.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't want to see any more of the old Dinosaur SLIS type of function module calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you now ever need to take take longer than 5 mins to code simple ALV grids then please re-read this post as it is completely general for around 99.99% of SIMPLE Grids (not Trees or complicated data handling).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should show you the principle easily enough.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jimbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2008 13:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268014#M781068</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-07T13:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: ALV GRID insert delete row</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268015#M781069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi burc,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using classes for ALV...&lt;/P&gt;&lt;P&gt;use method&lt;/P&gt;&lt;P&gt;CALL METHOD grid-&amp;gt;set_toolbar_interactive. -- where &lt;/P&gt;&lt;P&gt;grid TYPE REF TO cl_gui_alv_grid, (This you should have already defined for creating grid).. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mohaiyuddin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jan 2008 05:58:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268015#M781069</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-08T05:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: ALV GRID insert delete row</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268016#M781070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Additionally, to copy any changes to your internal table... use method &lt;/P&gt;&lt;P&gt;  CALL METHOD grid-&amp;gt;check_changed_data. in your PAI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I forgot to mention in my previous response.&lt;/P&gt;&lt;P&gt;Use &lt;/P&gt;&lt;P&gt;    CALL METHOD grid-&amp;gt;set_toolbar_interactive. -- in your PBO..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jan 2008 06:00:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-grid-insert-delete-row/m-p/3268016#M781070</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-08T06:00:41Z</dc:date>
    </item>
  </channel>
</rss>

