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: 

set_toolbar_interactive

Former Member
0 Kudos

Hi;

I receive dump error message "Access not possible using 'NULL' object reference." if i call method set_toolbar_interactive to set my toolbar object in ALV grid. Which parameter should i pass to this method?

Thx

Ali

7 REPLIES 7

Former Member
0 Kudos

Hi Ali,

Refer Sample program:

BCALV_GRID_05

BCALV_GRID_VERIFY

Reward points if that helps.

Manish

uwe_schieferstein
Active Contributor
0 Kudos

Hello Ali

The event TOOLBAR has the importing parameter E_OBJECT.

Your event handler method should look like this:

  handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
      e_object
      sender.

The toolbar functions are stored in e_object->mt_toolbar.

Your error message indicates that you probably have suppressed the toolbar of the ALV grid (layout-no_toolbar = 'X'). To omit the error simply add the following line in your event handler method:

* Check if we have a toolbar instance
  CHECK ( e_object IS BOUND ).

Regards

Uwe

0 Kudos

Hi Uwe;

it did not work unfortunately. if i add the command

CALL METHOD gr_alvgrid2->set_toolbar_interactive i get this dump error message. Actually without this my toolbar runs just fine. Should i really use this method?

Thx for the help

Ali

0 Kudos

Hello Ali

In this case you have not instantiated your ALV grid. Here is a sample report demonstrating an interactive toolbar. Push several times the ENTER button and the toolbar functions will be disabled one by one. Please check the coding in PBO module <b>PBO</b>.

[code]PROGRAM ZUS_SDN_BCALV_GRID_DEMO.

DATA: ok_code LIKE sy-ucomm,

gt_sflight TYPE TABLE OF sflight,

g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',

grid1 TYPE REF TO cl_gui_alv_grid,

g_custom_container TYPE REF TO cl_gui_custom_container.

----


  • CLASS lcl_eventhandler DEFINITION

----


*

----


CLASS lcl_eventhandler DEFINITION.

PUBLIC SECTION.

CLASS-DATA:

md_cnt TYPE i.

CLASS-METHODS:

handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING

e_object

e_interactive

sender.

ENDCLASS. "lcl_eventhandler DEFINITION

----


  • CLASS lcl_eventhandler IMPLEMENTATION

----


*

----


CLASS lcl_eventhandler IMPLEMENTATION.

METHOD handle_toolbar.

DATA:

ls_button TYPE stb_button.

ADD 1 TO md_cnt. " a simple counter

LOOP AT e_object->mt_toolbar INTO ls_button FROM 1 TO md_cnt.

ls_button-disabled = 'X'.

MODIFY e_object->mt_toolbar FROM ls_button.

ENDLOOP.

ENDMETHOD. "handle_toolbar

ENDCLASS. "lcl_eventhandler IMPLEMENTATION

START-OF-SELECTION.

----


  • MAIN *

----


SELECT * FROM sflight INTO TABLE gt_sflight.

CALL SCREEN 100.

----


  • MODULE PBO OUTPUT *

----


MODULE pbo OUTPUT.

SET PF-STATUS 'MAIN100'.

IF g_custom_container IS INITIAL.

CREATE OBJECT g_custom_container

EXPORTING container_name = g_container.

  • Instantiate ALV grid control

CREATE OBJECT grid1

EXPORTING i_parent = g_custom_container.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

it_outtab = gt_sflight.

  • Set event handler for event TOOLBAR

SET HANDLER:

lcl_eventhandler=>handle_toolbar FOR grid1.

ENDIF.

  • $Comment: Toolbar can be modified on-the-fly

grid1->set_toolbar_interactive( ).

ENDMODULE. "PBO OUTPUT

----


  • MODULE PAI INPUT *

----


MODULE pai INPUT.

  • to react on oi_custom_events:

CALL METHOD cl_gui_cfw=>dispatch.

CASE ok_code.

WHEN 'EXIT'.

PERFORM exit_program.

WHEN OTHERS.

  • do nothing

ENDCASE.

CLEAR ok_code.

ENDMODULE. "PAI INPUT

----


  • FORM EXIT_PROGRAM *

----


FORM exit_program.

  • CALL METHOD G_CUSTOM_CONTAINER->FREE.

  • CALL METHOD CL_GUI_CFW=>FLUSH.

LEAVE PROGRAM.

ENDFORM. "EXIT_PROGRAM[/code]

Regards

Uwe

0 Kudos

Hi

Where do you calling that method? It should trigger the event toolbar, are you using that event?

Max

0 Kudos

Hello Max

After instantiating the grid control I call

[code]* $Comment: Toolbar can be modified on-the-fly

grid1->set_toolbar_interactive( ).[/code]

This method raises event TOOLBAR.

Regards

Uwe

0 Kudos

Hi

Uwe my question is for Ali, I saw you have raised that event.

I don't know if Ali has done it too.

Max