cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Events

Former Member
0 Kudos

Hi,

i want to do something when a row selected. i searched how to do this, all must create an event handler method as on_click but i couldn't create it because the fields of event handler on methods is unwritable.

How can i create an on_click event handler?

Can somebody help me pls?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thank you very much,

no problem when debuged but when i test the application, an ALV error is taking

in st22 ;

UNCAUGHT_EXCEPTION

CX_WDR_RT_EXCEPTION

i debuged the program , error is taking in follow

DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  <here>     l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

  DATA: l_value TYPE REF TO cl_salv_wd_config_table.

Former Member
0 Kudos

Have you used the 'component usage' properly in 'properties' tab of a view.

In ur property tab these two lines should be added...

ALV	SALV_WD_TABLE	                    	ALV Component
ALV	SALV_WD_TABLE	INTERFACECONTROLLER	

First you have to add the used component at component level and then at view level. At view level select the interface controller then it will create 2 lines mentioned above.

Thanks,

Former Member
0 Kudos

Thanks first of all,

yes both the component controller and the main view have same component use.


ALV	SALV_WD_TABLE	                    
ALV	SALV_WD_TABLE	INTERFACECONTROLLER

...?

uday_gubbala2
Active Contributor
0 Kudos

Hi Nurullah,

I think that the ALV component has not been instantiated because of which you get this error. If you make use of the code wizard for generating the necessary coding it will come up with 2 things. The first one would be to create an instance of the ALV component & the 2nd one would be to get the ALV configuration model.

You should be having 2 things in your code similar to something shown below:

** Instantiate the ALV component
  DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

  lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

** Get the ALV configuration model
  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).

  DATA lo_value TYPE REF TO cl_salv_wd_config_table.
  lo_value = lo_interfacecontroller->get_model( ).

You can refer to this [blog |https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1190424a-0801-0010-84b5-ef03fd2d33d9]by Claudia Dangers if you are new to programming the ALV configuration model in WebDynpro ABAP. You can also go through this [blog |https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/webDynproABAP-UsingUIelementsinALVcomponentcells]by David Pietroniro if you want to have an example of how to handle the ON_CLICK event in ALV.

Regards,

Uday

Former Member
0 Kudos

Thank you very much Uday,

it solved my problem.

Thanks again.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you very much,

i'm doing now, when i have a problem, i will write

Former Member
0 Kudos

Go to the methods tab of ur view

1- create a method lets say 'on_enter'

2- select the method type as 'event handler'

3- In event column take the f4 help and select on_click event.

4 - Write the code in this method 'On_enter' as per ur requirements.

Thanks

Former Member
0 Kudos

Thanks,

When i took f4 in event column, i am taking an message box has that message;

'Used controllers (-> Properties) do not have events'.

Former Member
0 Kudos

Go to component and follow the following steps.

1- Add component 'SALV_WD_TABLE'

2- Come back to the view , go to properties tab

3- click on 'create controller usage' button and select the component which u have created.

4- Now follow the steps which i posted in my last post

Hope it will work.

Thanks

Former Member
0 Kudos

Hi,

i found an example and the wddoinit method is ;

* Display link in column connid
DATA: lr_link TYPE REF TO cl_salv_wd_uie_link_to_action.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'CONNID' ).
CREATE OBJECT lr_link.
lr_link->set_text_fieldname( 'CONNID' ).
lr_column->set_cell_editor( lr_link ).

the error is " the field 'L_VALUE' is unknown " but that example didn't define it anywhere.

when i define it, same error about 'LR_COLUMN', and i define it too, it is working but now 'access via null reference' is taking.

what is 'L_VALUE' and 'LR_COLUMN'? How can i define them?

Former Member
0 Kudos

Define like this...

* Create component usage for alv component
  DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
  l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

* Get config model
  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
  DATA: l_value TYPE REF TO cl_salv_wd_config_table.
  l_value = l_ref_interfacecontroller->get_model( ).


* set cell editor for input fields (~make colum PRICE editable)
  DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
  lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
  lr_column_settings ?= l_value.
  DATA: lr_column TYPE REF TO cl_salv_wd_column.