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: 

Get edited row number for ALV

Former Member
0 Kudos

Hi Friends,

I have ALV with a editable column. I want to get row number where the user insert or change data of editable column of ALV.

I am displaying ALV using following code.

*Display final ALV with fix column

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = wa_layout

it_fieldcat_lvc = t_fieldcat

i_save = 'A'

TABLES

t_outtab = t_final

EXCEPTIONS

program_error = 1

OTHERS = 2

.

Also I am geting chenaged data using following code.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref_grid.

CALL METHOD ref_grid->check_changed_data.

Please help me to get row number for chage in ALV.

Thanks

7 REPLIES 7

Former Member
0 Kudos

hi

try this....

data: begin of it_itab occurs 0.

counter type i,

name type name,

age type age,

end of it_itab.

clear counter.

select name age from <table> into (it_itab-name, it_itab-age)

where <cond>.

counter = counter +1.

append it_itab.

clear: it_itab.

endselect.

thanks

chaitanya

Former Member
0 Kudos

hi,

Thanks & regards.

Former Member
0 Kudos

Hi,

In form USER_COMMAND write following code,

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

READ TABLE I_MARC INTO WA_MARC INDEX RS_SELFIELD-TABINDEX .

ENDCASE.

ENDFORM.

Here I have written code for sy-ucomm '&IC1' , which is code for double click. If you want to capture the value of selected row when you click some button , write your code for that perticular sy-ucomm of button click.

You will get all the details regarding selected row in RS_SELFIELD . RS_SELFIELD-TABINDEX contains index of selected row.

Hope this helps.

Thanks & Regards

Tejaswini Khante

Former Member
0 Kudos

HI


*---Method definition....
    methods handle_data_changed
     for event data_changed of cl_gui_alv_grid
     importing   er_data_changed.

*----implementation....
  method handle_data_changed.
    loop at er_data_changed->mt_mod_cells into is_cells==>check this table ...
    endloop.
endmethod

0 Kudos

Hi Prabhu,

Thanks for help.

I tryed that event handling but I am facing problem. Could you please suggest a way to complete this,

==> At top include of program

  • local class to handle semantic checks

CLASS lcl_event_receiver DEFINITION DEFERRED.

----


  • CLASS lcl_event_receiver DEFINITION

----


*

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

handle_data_changed

FOR EVENT data_changed OF cl_gui_alv_grid

IMPORTING er_data_changed.

ENDCLASS.

DATA: g_event_receiver TYPE REF TO lcl_event_receiver.

==> In user command subroutine.

DATA: ref_grid TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref_grid.

CALL METHOD ref_grid->check_changed_data.

CALL METHOD ref_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

CLASS lcl_event_receiver IMPLEMENTATION.

METHOD handle_data_changed.

DATA: wa_modi TYPE lvc_s_modi.

LOOP AT er_data_changed->mt_good_cells INTO wa_modi.

ENDLOOP.

  • LOOP AT t_final INTO wa_final.

  • READ TABLE er_data_changed->mt_good_cells INTO wa_modi INDEX sy-tabix.

  • IF sy-subrc NE 0.

  • wa_final-indicator = 1.

  • MODIFY t_final FROM wa_final TRANSPORTING indicator.

  • ENDIF.

  • ENDLOOP.

ENDMETHOD. "handle_data_changed

ENDCLASS. "lcl_event_receiver IMPLEMENTATION

CREATE OBJECT g_event_receiver.

SET HANDLER g_event_receiver->handle_data_changed FOR ref_grid.

Please Guide me

Thanks

Amit

0 Kudos

Hi Amit ,

check sample code ..


    loop at er_data_changed->mt_mod_cells into is_cells.
      if is_cells-value is not initial.
      clear: ls_item,
             l_value,
             l_change.
      "validate changed records....
      read table gt_item1 into ls_item index is_cells-row_id.
     check sy-subrc .
    endif.
endloop.

0 Kudos

Hi Prabhu,

Thank you for replay,

But control is not going into method handle_data_changed to verify change entry.

Thanks.