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: 

Refresh_protocoll - CL_ALV_CHANGED_DATA_PROTOCOL - nothing happens - why??

Former Member
0 Kudos

Hallo together,

I am realising a transaction with editable alv-grid-control. I use the event handler to react on user handling and implemented a method handle_data_changed where i referred to cl_alv_changed_data_protocol. In this method i handle the data changed and i am using the protocol. So far everything goes well.

Now i have a problem, because i want to refresh the protocol but i don´t know how. Because when i use the method refresh_protocol nothing happens, because m_log_handle is initial.

I found in "An Easy Reference for ALV Grid Control" documentation in "a piece of troubelshooting" under no. 12 this problem, but with the answer i can´t do anything.

Could somebody give me a hint?

Thanx´s a lot and greetings from cologne - germany.

Timo

14 REPLIES 14

former_member188685
Active Contributor
0 Kudos

Hi Can you place the code you are refreshing.

why do you need to refresh can you just tell me.

regards

vijay

former_member188685
Active Contributor
0 Kudos

In my Prg I am using a method to handle data changed event.

  HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                         OF CL_GUI_ALV_GRID
                         IMPORTING ER_DATA_CHANGED
                                   E_ONF4
                                   E_ONF4_BEFORE
                                   E_ONF4_AFTER.
this methos imports <b>ER_DATA_CHANGED</b> it has an object reference to the class CL_ALV_CHANGED_DATA_PROTOCOL , using this object refrence <b> call  refresh_protocol</b> of the class

  METHOD HANDLE_DATA_CHANGED.
<b>[code]call method ER_DATA_CHANGED->REFRESH_PROTOCOL.

</b>

ENDMETHOD.[/code]

*Set the Handler

SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.

try to do the same way.

Message was edited by: Vijay Babu Dudla

Former Member
0 Kudos

Hi Timo,

check this it may help you...


CLASS lcl_event_receiver DEFINITION DEFERRED.

DATA: g_event_receiver TYPE REF TO lcl_event_receiver.

**************************************************************
* LOCAL CLASS Definition
**************************************************************
*§4.Define and implement event handler to handle event DATA_CHANGED.

CLASS lcl_event_receiver DEFINITION.


  public section.
    METHODS:
       handle_data_changed
             FOR EVENT data_changed OF cl_gui_alv_grid
             IMPORTING er_data_changed,

       handle_toolbar
             FOR EVENT toolbar OF cl_gui_alv_grid
             IMPORTING e_object e_interactive.

  PRIVATE SECTION.

* This flag is set if any error occured in one of the
* following methods:
    DATA: error_in_data TYPE c.

* Methods to modularize event handler method HANDLE_DATA_CHANGED:
    
    METHODS: check_ctry_bank
       IMPORTING
          ps_good_ctry_bank TYPE lvc_s_modi
          pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.

ENDCLASS.

CLASS lcl_event_receiver IMPLEMENTATION.

  METHOD handle_data_changed.

    DATA: ls_good TYPE lvc_s_modi.

    error_in_data = SPACE.

    LOOP AT er_data_changed->mt_good_cells INTO ls_good.
      CASE ls_good-fieldname.

        WHEN 'CTRY_BANK'.
          CALL METHOD check_CTRY_BANK
                 EXPORTING
                    ps_good_CTRY_BANK = ls_good
                    pr_data_changed   = er_data_changed.

  ENDCASE.
    ENDLOOP.

*§7.Display application log if an error has occured.
    if error_in_data eq 'X'.
      call method er_data_changed->display_protocol.
    endif.

  ENDMETHOD.

*--------------------------------------------------------------------
  METHOD check_CTRY_BANK.

*...................................................

    DATA: l_LAND1 TYPE LAND1,
          ls_T005 TYPE T005.

* Get new cell value to check it.

    CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id =    ps_good_CTRY_BANK-row_id
                    i_fieldname = ps_good_CTRY_BANK-fieldname
          IMPORTING e_value     = l_LAND1.
* existence check:
    SELECT SINGLE * FROM T005 INTO ls_T005 WHERE
                                     LAND1 = l_LAND1.
    IF sy-subrc NE 0 and l_land1 ne ' '.

      CALL METHOD pr_data_changed->add_protocol_entry
       EXPORTING
          i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
          i_msgv1 = text-003           "Flugzeugtyp
          i_msgv2 = l_LAND1
          i_msgv3 = text-002           "exitstiert nicht
          i_fieldname = ps_good_CTRY_BANK-fieldname
          i_row_id = ps_good_CTRY_BANK-row_id.

      error_in_data = 'X'.
      EXIT.
    ENDIF.

  ENDMETHOD.
*--------------------------------------------------------------------

ENDCLASS.

hope this helps you...

regards,

venu.

0 Kudos

Hi Venu,

when will be call method er_data_changed->display_protocol be displayed? I implemented my class in a separated include.

May be i have a problem with my process logic. After the user press save on my own gui-status i have a subprogram where i call check_changed_data to check if everything is ok, because i am not sure if every user presses refresh on the alv to check if every entry is ok.

My subprogram look like this:

FORM pruefen_rueck USING p_l_valid.

TYPES: zbapi TYPE TABLE OF zbapi_alm_timeconfirmation.

FIELD-SYMBOLS: check_changed_data

IMPORTING

e_valid = p_l_valid.

*---Wenn Protokoll vorhanden,dann rauss

IF p_l_valid = space.

RETURN.

ENDIF.

...

Any idea?

Thank you Timo

0 Kudos

Hi Timo,

er_data_changed->display_protocol is called inside save_data method and one such call is also inside check_changed_data method.

Firstly are you adding messages to protocol inside your handler method for data_changed?

Also, by the time you call refresh_protocol if there are no messages inside then nothing happens..

Hope this helps..

Sri

0 Kudos

Hi Timo,

I understand what you are trying to do. Heres a couple of suggestions.

1. The refresh_protocol() method will simply clear out all the error messages from the internal table which stores the protocol error. => it is just like a refresh internal table or a clear statement that we issue.

2. After data_changed event, the system calls display_protocol, if there are changes to the protocol.

3. So essentially, what you have to do is in data_changed handler is refresh_protocol() and add_protocol_entry()

4. If you are in 4.7 or upwards, after call to set_table_for_first_display(), call the method <b>process_ucomm_on_invalid_input</b>. This will enable processing of User_command even if there is a error !

and your problem should be solved. and in this case, the fun part is <u><i>you dont have to do a refresh_protocol</i></u>.

Hope you get the point.

Regards,

Prashanth.

0 Kudos

Hi Sri,

i add messages to protocol inside my handler method. Is this bad? I don´t know another way.

Timo

0 Kudos

Can you paste the code..

So that we can see and let you know...

regards

vijay

0 Kudos

here my code. Hope this helps: Sorry that the documentation is not in english.

TYPE lvc_t_msg1.

*---Protokoll refreshen

  • CALL METHOD er_data_changed->refresh_protocol.

*---Gibt es neue Zeilen oder Änderungen

DESCRIBE TABLE er_data_changed->mt_mod_cells LINES n.

IF n check_changed_data

IMPORTING

e_valid = p_l_valid.

*---Wenn Protokoll vorhanden,dann rauss

IF p_l_valid = space.

RETURN.

ENDIF.

...

Thanks

Timo

0 Kudos

Timo,

Did you try my suggestions ?

I have tried this in my code, and it is working perfectly in my code...

Process_ucomm_on_invalid_input( ) shd work.

Rgds,

Prabhu

0 Kudos

Prabhu,

i tried your suggestion but nothing happens. I can call the method process_ucomm_on_invalid_input and export an ucomm. But when i debugg this method the debugger didn´t runs through the method.

We are on SAP_BASIS Release 620. May this is the reason why it didn´t work?

Rgds

Timo

0 Kudos

Hi Timo,

Try this, I saw your code I think you are doing every thing right.

Now uncomment your REFRESH_PROTOCOL call and then at the end of your data changed handler method. Try calling DISPLAY_PROTOCOL method of the CL_ALV_CHANGED_DATA_PROTOCOL.

This is how normally I code for editable ALV Grids,

Firstly in data changed event handler method I just one flag saying data_modified = 'X' and then call CL_GUI_CFW=>SET_NEW_OK_CODE to trigger PAI.

In PAI, I write a MODULE in which I have some thing like the following,

IF data_modified = 'X'.

****Call to check_changed_data method

****if valid then

****LOOP on the data table

****My checks here, messages display

****ENDLOOP.

****If there are no errors then clear data_modified

****otherwise no to make sure that whatever user does ****without correcting errors in the grid are taken care ****of

ENDIF.

Hope this helps..

Sri

0 Kudos

HI Sri,

this looks good for me. I will try your suggestion with set_new_ok_code to trigger PAI.

Thank you very much

Timo

Former Member
0 Kudos

Hi vijay,

i want to refresh the protocol because,when an error message is posted and the user make the changes i want to delete the protocol.

But venu´s reply seems to help me, because i react on the error message later and not in my method handle_data_changed. I will check this.

Thanx´s to you.

Timo