Skip to Content
0

ALV OO display_protocol not working after 'forcing' a check_data_changed

Jul 04, 2017 at 10:09 AM

307

avatar image
Former Member

Hi experts,

I'm having an issue with an OO editable ALV. I've had to add an option for the user to append lines to the ALV uploading an Excel file and I am having problems showing the protocol entry messages.

I have managed to force the flow to raise the event handle_data_changed once the new data is loaded in the ALV grid's content table and then I would need to check the uploaded data in order to show error messages if such errors occur. I'm adding the messages in the handle_data_changed method of my event receiver local class, via the method add_protocol_entry, and it seems to be doing it ok (at least I see no difference with how it is done when I add a new line manually to the ALV), but when the code addresses the display_protocol method nothing happens.

I forced the handle_data_changed event doing something like this in the PAI:

  data(lv_refresh) = abap_true.
  gr_grid->check_changed_data( importing e_valid   = data(lv_valid)
                                changing c_refresh = lv_refresh ).

  gr_grid->set_delta_cells( exporting it_delta_cells = lt_delta_cells
                                          i_modified = abap_true ).
 
 gr_grid->check_changed_data( importing e_valid   = lv_valid
                                changing c_refresh = lv_refresh ).

In the lt_delta_cells I populate the new data added via Excel upload.

Then, in my handle_data_method I check the data, add protocol messages where needed...

lr_data_changed->add_protocol_entry( exporting i_msgid = 'ZZZZ'
                                               i_msgty = 'E'
                                               i_msgno = '001'
                                              i_fieldname = 'FIELD' ).

... and finally, if mt_protocol contains something, I try to show the protocol messages:

lr_data_changed->display_protocol( ).

Also, on the layout definition for the ALV I am setting the following (not really sure if it's needed at all):

  cs_layout-val_data   = abap_true.

I'll appreciate any kind guidance with this.

Regards,

Álvaro.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Richard Harper Jul 04, 2017 at 10:56 AM
0

You also need HANDLE_DATA_CHANGED_FINISHED.

I think it's called automagically if there are any entries in the error tables.

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Richard, thank you for your answer.

I don't really get why would I need to use the handle_data_changed_finished event. It is in the handle_data_changed event where I have access to the cl_alv_changed_data_protocol reference, to add and display protocol messages.

I have nonetheless implemented the handle_data_changed_finished event in my local event receiver class, but I don't see anything different (I'm not really sure of what do I have to do there though).

Regards,

Álvaro.

0

Hi Alvaro,

yes and no... I've just checked some of my ALV grids and I don't explicitly call Protocol_Display. However, I do have a data-changed_finished event that has a note in it that states the protocol doesn't display unless the event is there.

I've debugged my grid and it's called during the Alg grid Save method which is called by either of these two events:

Call Method Me->Register_Edit_Event
 Exporting
 i_Event_Id = Me->Mc_Evt_Enter
 Exceptions
 Error = 1
 Others = 2.
 Call Method Me->Register_Edit_Event
 Exporting
 i_Event_Id = Me->Mc_Evt_Modified
 Exceptions
 Error = 1
 Others = 2.

So just out of interest add these and see what happens.

Rich

0
Former Member

Yes, I have both edit events registered, sorry I didn't specify that.

I seem to have no problem with the ALV noticing that a change has happened, and with the set_delta_cells and check_changed_data I can manage to trigger the handle_data_changed event. The issue is when I try to add the protocol messages and then display them when I have forced the handle_data_event: it seems that the messages are correctly added and the display looks like it's working ok... but it doesn't show the dialog with the message list.

If I enter one new line (manually) that should cause an error, the program flow is identical and eventually reaches the hadle_data_changed method of my event receiver class. In this case, although it is treated in the same place and form, it works properly. That makes me think that I am doing something wrong when artificially forcing the handle_data_event to occur.

Álvaro.

0

This is how I force my grids to validate themselves:

Method External_Validation_Check.
*
       Data: l_Valid Type Boolean.
*
*      Validation checks triggered by a PAI from one of the 'report' buttons.
*      Force the check by changing the GridModified property,  or the other
*      grid....
*
       If i_UComm = Me->fc_Save.
          Me->Set_UComm( i_UComm ).
          Call Method Me->if_Cached_Prop~Set_Prop
            Exporting
              PropName  = 'GridModified'
              PropValue = '1'.
          Me->Check_Changed_Data(
            Importing
               e_Valid = l_Valid ).
       Else.
          l_Valid = Abap_True.
       EndIf.
       e_Valid = l_Valid.
       Free: l_valid.
EndMethod.

And then I call the Save_Data method of the grid:

0
Sandra Rossi Jul 04, 2017 at 07:32 PM
0

I can't be sure you have the same issue as I had, but calling the method ACTIVATE_DISPLAY_PROTOCOL( 'X' ) of CL_GUI_ALV_GRID, had solved the issue for me.

Share
10 |10000 characters needed characters left characters exceeded