Application Development and Automation 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: 
Read only

CL_SALV_TABLE event

Madjid_Khanevadegi
Participant
0 Likes
8,436

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

7 REPLIES 7
Read only

Sandra_Rossi
Active Contributor
0 Likes
4,150

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"?

Read only

Madjid_Khanevadegi
Participant
0 Likes
4,150

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.

Read only

Sandra_Rossi
Active Contributor
4,150

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.

Read only

Madjid_Khanevadegi
Participant
0 Likes
4,150

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
Read only

matt
Active Contributor
4,150

Rather than just create a class to handle the events -put everything into a class,including these methods.

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,150

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."

Read only

DoanManhQuynh
Active Contributor
0 Likes
4,150

If you are following demo: SALV_DEMO_TABLE_EVENTS, did you do §6 register to the events of cl_salv_table?