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: 

how to create new or delete the existing row in the grid....

Former Member
0 Kudos

hi my friends...

i am developing report using Reuse_alv_grid_display...

my requirement is... At runtime

1. i may create new row on the grid (empty row inwhich i may enter the data).

2. i may delete a existing row in the grid

3. i may edit the existing data...

then i have to trace the modification in the grid in one internal table...

how can i get into this.....

note:

i have some idea to edit the existing record in the grid and trace those modification,

but i don't know abt how to create new or delete the existing row....

can you give me some idea...

1 ACCEPTED SOLUTION

Manohar2u
Active Contributor
0 Kudos

Hope this blog helps you...

/people/srilatha.t/blog/2007/04/16/alv-grid-150-insert-row-function

thanks

Manohar

4 REPLIES 4

Manohar2u
Active Contributor
0 Kudos

Hope this blog helps you...

/people/srilatha.t/blog/2007/04/16/alv-grid-150-insert-row-function

thanks

Manohar

Former Member
0 Kudos

hi

create new row:

put a button on the alv tool bar,when u press the button, just append row to the internal table(you are displaying in alv) and use the function module refresh_table_display of cl_gui_alv_grid.

delete row :

put a button on the alv tool bar, to delete a row

select a row from the alv table and press the delete button, then read the selected row of the alv using the function get_selected_rows and delete the row from the internal table and refresh alv table using the function module refresh_table_display.

modify a row :

the columns you want to modify, make them editable using fieldcatalog

modify the data in the alv, and when u go to the next screen or next action , use the function module check_changed_data of cl_gui_alv_grid.

Hope u understood, if u still have any doubts, revert back to me.i wil try to clarify it

Regards,

Prasant

*Reward if helpful

0 Kudos

hi prasant...

thanks 4 ur effort on my queries...

i am new to oops object... can you send me brief code for this scenario...

0 Kudos

Hi deva,

write a class which implemets these methods

CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

  • To handle the toolbar on alv

handle_toolbar

FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING e_object e_interactive,

  • To handle the buttons on the alv grid

handle_user_command

FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm.

endclass.

Now Implement these methods.

CLASS lcl_event_receiver IMPLEMENTATION.

  • To handle the toolbar on alv

METHOD handle_toolbar.

  • DATA ls_toolbar TYPE stb_button.

CLEAR gs_toolbar.

MOVE 3 TO gs_toolbar-butn_type.

APPEND gs_toolbar TO e_object->mt_toolbar.

CLEAR gs_toolbar.

PERFORM icon_create USING 'ICON_INSERT_ROW' gs_toolbar-icon.

MOVE text-010 TO gs_toolbar-function.

MOVE text-012 TO gs_toolbar-quickinfo.

MOVE ' ' TO gs_toolbar-disabled.

APPEND gs_toolbar TO e_object->mt_toolbar.

CLEAR gs_toolbar.

PERFORM icon_create USING 'ICON_DELETE_ROW' gs_toolbar-icon.

MOVE text-011 TO gs_toolbar-function.

MOVE text-013 TO gs_toolbar-quickinfo.

MOVE ' ' TO gs_toolbar-disabled.

APPEND gs_toolbar TO e_object->mt_toolbar.

ENDMETHOD.

METHOD handle_user_command.

  • In this form, check the function code(e_ucomm has the function code), based on that do the required action.

as i said yesterday(i.e for appending a row, deleting a row, modifying a row)

PERFORM user_command USING e_ucomm.

ENDMETHOD

endclass.

Before calling the alv method, create a object of this class.

DATA :

gref_event_receiver TYPE REF TO lcl_event_receiver,

gv_tables_alv TYPE REF TO cl_gui_alv_grid.

CREATE OBJECT gref_event_receiver.

SET HANDLER gref_event_receiver->handle_user_command

FOR gv_tables_alv.

SET HANDLER gref_event_receiver->handle_toolbar

FOR gv_tables_alv.

check this program for event handling, it is the similar way

demo_abap_objects_events

Hope u understood this.

Regards,

Prasant

  • reward if helpful