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: 

e_ucomm problem

Former Member
0 Kudos

hello,

in my data_changed method I am doing a check on e_ucomm which is the function code of a context_menu in an ALV-Grid.

method handle_data_changed.
    if e_ucomm = 'Context_menu_AAS'.
      /bmw/pur_a003_cl_inbox_appl=>gv_verantw_flag = 'X'.
    endif.

Unfortunately the handle_data_changed is triggered also by pressing ENTER on the grid. I found out that e_ucomm is still set to value 'Context_menu_AAS' and is not set for exampe on initial.

Can I somehow clear the content of e_ucomm?

I tried

method handle_data_changed.
    if e_ucomm = 'Context_menu_AAS'.
      /bmw/pur_a003_cl_inbox_appl=>gv_verantw_flag = 'X'.
     clear e_ucomm.
    endif.

But that did not have any effects on future calls of handle_data_changed.

had somebody had the same experience?

with best regards

luchticha

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Luchticha

I would recommend to define an instance (static) attribute in your event handler class, e.g.:


CLASS lcl_eventhandler  DEFINITION.
  " NOTE: I prefer to use static methods and attributes for my event handler class, but this is a matter of taste...
  PUBLIC SECTION.
    CLASS-DATA:
      md_okcode       TYPE ui_func.  
    CLASS-METHODS:
      handle_data_changed
         FOR EVENT data_changed OF cl_gui_alv_grid
             IMPORTING er_data_changed,


    handle_onf4 FOR EVENT onf4 OF cl_gui_alv_grid
          IMPORTING sender
                 e_fieldname
                 e_fieldvalue
                 es_row_no
                 er_event_data
                 et_bad_cells
                 e_display.

ENDCLASS.                    "lcl_eventhandler DEFINITION

When the user chooses a function of the context menu it should trigger event USER_COMMAND. Here you can store and refresh you attribute, e.g.:


METHOD handle_user_command.

  md_okcode = e_ucomm.
" Do something...
  CLEAR: md_okcode.
ENDMETHOD.

Perhaps you need another place where to clear the ok-code but I think you understand the concept and can easily adapt this to your scenario.

Regards

Uwe

7 REPLIES 7

uwe_schieferstein
Active Contributor
0 Kudos

Hello Luchticha

I would recommend to define an instance (static) attribute in your event handler class, e.g.:


CLASS lcl_eventhandler  DEFINITION.
  " NOTE: I prefer to use static methods and attributes for my event handler class, but this is a matter of taste...
  PUBLIC SECTION.
    CLASS-DATA:
      md_okcode       TYPE ui_func.  
    CLASS-METHODS:
      handle_data_changed
         FOR EVENT data_changed OF cl_gui_alv_grid
             IMPORTING er_data_changed,


    handle_onf4 FOR EVENT onf4 OF cl_gui_alv_grid
          IMPORTING sender
                 e_fieldname
                 e_fieldvalue
                 es_row_no
                 er_event_data
                 et_bad_cells
                 e_display.

ENDCLASS.                    "lcl_eventhandler DEFINITION

When the user chooses a function of the context menu it should trigger event USER_COMMAND. Here you can store and refresh you attribute, e.g.:


METHOD handle_user_command.

  md_okcode = e_ucomm.
" Do something...
  CLEAR: md_okcode.
ENDMETHOD.

Perhaps you need another place where to clear the ok-code but I think you understand the concept and can easily adapt this to your scenario.

Regards

Uwe

Former Member
0 Kudos

Hi Luchticha ,

You can define another variable like e_ucomm. Then you can modify your code something like this:

data: l_ucomm like e_ucomm

method handle_data_changed.
    l_ucomm = e_ucomm.
    if l_ucomm = 'Context_menu_AAS'.
       clear: e_ucomm,l_ucomm.
      /bmw/pur_a003_cl_inbox_appl=>gv_verantw_flag = 'X'.
    endif.

Hope this will change your problem.

Regards,

Brajvir

Former Member
0 Kudos

Unfortunately the problem remains.

I tried to clear e_ucomm on various places, but it is not set to INITIAL.

Maybe anybody else has an idea what happens?

thx

uwe_schieferstein
Active Contributor
0 Kudos

Hello Luchticha

I have some problems understanding why you need to know E_UCOMM (triggered by choosing a context menu function) at the event handler HANDLE_DATA_CHANGED. Perhaps you can explain your scenario or show parts of the relevant coding.

Regards

Uwe

Former Member
0 Kudos

I will try to explain better,

in my data_changed method I am doing a check on e_ucomm which is the function code of a context_menu in an ALV-Grid.

method handle_data_changed.
    if e_ucomm = 'Context_menu_AAS'.
      flag = 'X'.
    endif.

I need this because if handel_data_changed is triggered by clicking on the context-menu some error checks, which will be called later in this method, must not be done. I am doing this by checking whether the flag is set or not.

Till here everything works fine, but if I change a field in the ALV and press Enter (which triggers handle_data_changed) e_ucomm is still set to 'Context_menu_AAS' and so the flag is set again to X and the error-checking again is not done which is wrong.

However, shouldn't the u_ecomm not be initialized automatically?

I tried

Former Member
0 Kudos

Hello,

I am not sure the problem is still alive.

I faced the same problem and found a solution to clear the e_ucomm.

The user command is stored in CL_GUI_ALV_GRID->M_UCOMM.

The data_changed event is triggered as follows:

raise event data_changed exporting er_data_changed = mr_data_changed

e_onf4 = i_f4

e_onf4_before = i_f4_before

e_onf4_after = i_f4_after

e_ucomm = m_ucomm.

so all we need do is to clear M_UCOMM.

There is a method:

CL_GUI_ALV_GRID->SET_USER_COMMAND

exporting

i_ucomm = space.

I hope this helps!

Viktor Bojtos

Hungary

Hi Viktor,

I am so happy that I see this post and your answer. I have the same problem and have searched for a solution for a long time. And your answer is correct and I have solved my problem. Thanks a lot!

best regards,

Wenwen