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: 

Check_changed_data method on editable ALV Grid ( class cl_gui_alv_grid)

former_member125661
Contributor
0 Kudos

Hi guys,

I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.

call method alv_grid->register_edit_event

exporting

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.

Any advice or tips or sample code is greatly appreciated.

Thanks,

Shareen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Shareen,

Not all events get triggered on save. Also i think the qty check as u mnetioned is done by the DDIC structure reference which is done internally by the system.

May be you can write a simple piece of code to scan through the records on SAVE and to trigger your validation. Check_changed_data will only indicate if the data has been changed by the user. I think it does not do a "Check" for the data consistency.

Hope this helps.

Cheers

VJ

12 REPLIES 12

Former Member
0 Kudos

Hi Shareen,

Not all events get triggered on save. Also i think the qty check as u mnetioned is done by the DDIC structure reference which is done internally by the system.

May be you can write a simple piece of code to scan through the records on SAVE and to trigger your validation. Check_changed_data will only indicate if the data has been changed by the user. I think it does not do a "Check" for the data consistency.

Hope this helps.

Cheers

VJ

0 Kudos

Hi Vijayendra,

You are most likely to be correct. THis is what i fear too. My editable grid has more than a 100 fields and most of these fields are of the type floating point. The Enter event above takes takes of all the validations. I wonder, how I can replicate this validation which the DDIC structure is doing (if at all, it is doing ) ?

Thanks,

Shareen

0 Kudos

Hi Shareen,

whenever this method is called it reflects the changes that you made in the grid back to the internal TAble..

so you can call it when ever you save ...



FORM check_data_change.
*This method will trigger the change event when the user clicks on save
*without clicking enter. Earlier the data dchanged with just save wasnt
*captured

  DATA : wl_refresh TYPE c VALUE 'X'.
  CALL METHOD w_alv_grid->check_changed_data
  CHANGING  c_refresh = wl_refresh.
 ENDFORM.

Now the lt_good_cells will have those cells which had the modification..

you can simple use it make the validations..

regards

satesh

0 Kudos

Satesh,

Thanks for the input. I am aware that check_changed_data puts the grid values back in gi_outtab. But why are u passing wl_refresh = X to the method ? what does it do ?

The problem is I have more than 100 validations to do. I cannot write validation routines for each of these fields. If i can replicate the standard DDIC validation routine which is triggered when u click on "Check" button on ALV Grid, it would be awesome.

0 Kudos

Hi Shareen,

Handle the data_changed event in the grid.

Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.

    METHODS handle_data_changed
      FOR EVENT data_changed OF cl_gui_alv_grid
      IMPORTING er_data_changed.

Implementation:

  METHOD handle_data_changed.
    PERFORM validations USING er_data_changed.
  ENDMETHOD.

FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
  DATA: ls_good TYPE lvc_s_modi.
  DATA  wa LIKE LINE OF lt_good_cells.
  CALL METHOD g_grid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_modified.

  LOOP AT er_data_changed->mt_good_cells INTO ls_good.
    CASE ls_good-fieldname.
    WHEN 'FIELDNAME'. "Your fieldname
        CALL METHOD er_data_changed->get_cell_value "Get the changed value
          EXPORTING
            i_row_id    = ls_good-row_id
            i_fieldname = ls_good-fieldname
          IMPORTING
            e_value     = temp. "Your temp variable
        "Make your validations here.
    ENDCASE.

Ps: Reward points if helpful.

Regards,

Wenceslaus.

0 Kudos

Hi,

You can use this

CALL METHOD g_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_modified.

in the PERFORM where you PERFORM validations.

In the SAVE PAI event call

CALL METHOD g_grid->check_changed_data

Ps: Reward points if helpful.

Regards,

Wenceslaus.

former_member125661
Contributor
0 Kudos

Hi Wenceslaus G ,

Thanks for the reply. This is something, I want to try when I go to office in the morning. I will keep you posted about the outcome. But still, i need to write my own validation for each field. As i have said before, i have more than 100 fields to validate and the DDIC validation performed by the system does validate for all..Somehow, if i can replicate that validation, it would be great.

Thanks,

Shareen

0 Kudos

Hi Shareen,

This above code can perform the required validation for any field in addition to the DDIC validation performed by the system.

Regards,

Wenceslaus.

0 Kudos

HI Shareen,

sorry for the late reply..

yes you can easily validate for all the fields by doing something like this..

 DATA: ls_good TYPE lvc_s_modi.
  DATA  wa LIKE LINE OF lt_good_cells.
  CALL METHOD g_grid->register_edit_event    
   EXPORTING    
      i_event_id = cl_gui_alv_grid=>mc_evt_modified. 

 LOOP AT er_data_changed->mt_good_cells INTO ls_good.
  CALL METHOD er_data_changed->get_cell_value     EXPORTING        
    i_row_id    = ls_good-row_id 
    i_fieldname = ls_good-fieldname          IMPORTING           
 e_value     = temp. 

data : cond(100).

concatenate ls_good-fieldname 'EQ' temp into cond separated by space.
select (ls_good-fieldname)
   up to 1 rows
   into (temp)
   from <table>
   where (cond).
ENDSELECT.

if sy-subrc NE 0.
*no field of that value exists
endif.
ENDLOOP.

this will validate if the field value exists or not..

FOR ALL THE 100 FIELDS..

regards

satesh

0 Kudos

Now where do I use the following method ?

CALL METHOD g_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_modified.

Should I write it under PAI event 'SAVE' ? I want the validations to occur even when I click save.

Thanks,

SHK

0 Kudos

Hi Shareen,

you need not write this when you click on SAVE .

you'll have to write it at other places when you want to do validations..

the check_data_changed event takes care of the changes in the SAVE part of the PAI..

regards

satesh

0 Kudos

Hi satesh ,

Im new for ALV . can u pls give me sample coding .where i use enter key to save and check when i usee reuse_alv_list_display.mail me at shankimail@gmail.com

Thanks

Shankar S