2019 Dec 21 2:58 PM
Hello
i make an alv report with "CL_ALV_TABLE" class that has a method, double_click
METHODS : on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
this method works truly, when double click on a specific row of ALV
i want call this method in a push button as illustrate , but this error raise "Dereferencing of the null reference"
TRY.
data x_lcl_event_handler type ref to lcl_event_handler.
call method x_lcl_event_handler->ON_DOUBLE_CLICK
exporting Row = '1'
column = 'STEP' .
CATCH CX_ROOT INTO lr_exp.
lv_text = lr_exp->get_text( ).
message 'Error: .' && lv_text type 'S'.
ENDTRY.
i can not focus on the alv table before call this code
Thanks in advance for your help

Hello
i make an alv report with "CL_ALV_TABLE" class that has a method, double_click
METHODS : on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
this method works truly, when double click on a specific row of ALV
i want call this method in a push button as illustrate , but this error raise "Dereferencing of the null reference"
TRY.
data x_lcl_event_handler type ref to lcl_event_handler.
call method x_lcl_event_handler->ON_DOUBLE_CLICK
exporting Row = '1'
column = 'STEP' .
CATCH CX_ROOT INTO lr_exp.
lv_text = lr_exp->get_text( ).
message 'Error: .' && lv_text type 'S'.
ENDTRY.
i can not focus on the alv table before call this code
Thanks in advance for your help

2019 Dec 21 3:14 PM
The error is obvious, you should instantiate x_lcl_event_handler before calling its method. Why can't you?
What means "I can not focus on the alv table before call this code"?
2019 Dec 21 3:23 PM
thanks sandra.rossi
this method is not work on outside of ALV table (when button press) .
the x_lcl_event_handler is instant of lcl_event_handler class.
2019 Dec 21 3:31 PM
It's difficult to help without any information about the important parts of your code.
There shouldn't by any problem to call the method of a public attribute.
Just a guess, I hope it will help you: make x_lcl_event_handler as a public attribute of your ALV instance, or make it a global variable, and calling any of its public methods should be possible.
2019 Dec 22 6:22 AM
these methods was public
"--class handler--"
CLASS lcl_event_handler DEFINITION DEFERRED.
"--CLASS lcl_handle_events DEFINITION--"
CLASS lcl_event_handler DEFINITION FINAL.
PUBLIC SECTION.
METHODS : on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
METHODS : on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS."lcl_handle_events DEFINITION
"--CLASS lcl_handle_events IMPLEMENTATION--"
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_double_click.
MESSAGE i001(00) WITH 'Double click1: column: ' column ' / line: ' row.
ENDMETHOD."on_double_click
METHOD on_link_click.
MESSAGE i001(00) WITH 'Click on link: column: ' column ' / line: ' row.
ENDMETHOD."on_link_click
ENDCLASS."lcl_handle_events IMPLEMENTATION
2019 Dec 22 2:35 PM
Rather than just create a class to handle the events -put everything into a class,including these methods.
2019 Dec 22 7:03 PM
I just repeat myself: "Just a guess, I hope it will help you: make x_lcl_event_handler as a public attribute of your ALV instance, or make it a global variable, and calling any of its public methods should be possible."
2019 Dec 23 12:25 AM
If you are following demo: SALV_DEMO_TABLE_EVENTS, did you do §6 register to the events of cl_salv_table?