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

ALV code needed

Former Member
0 Likes
856

Hi all,

Can one tell me how to add menu in Oops concept Please post some examples.

regards,

Lisa

7 REPLIES 7
Read only

Former Member
0 Likes
839

Have you seen these reports?

BCALV_GRID_05

BCALV_GRID_06

BCALV_GRID_07

BCALV_GRID_08

bye

enzo

Read only

0 Likes
839

Hi Enzo,

I understood what do you want say to me but my requirement is in the grid bar there is diplay button instead of selecting from the grid bar i want to select it from menu .Is it possible?.If u know any example code just post it.

Regards,

Lisa.

Read only

0 Likes
839

Hi Lisa,

probably I don't understood you because of my english, any way, I belive you are speaking about the menu at the top of the dympro, in other words where is written 'System', 'Help', ...

is it correct?

Read only

Former Member
0 Likes
839

Do you mean setting your own pf-status or adding additional buttons to the standard ALV toolbar?

In OO ALV, you will use your screen and have a custom container to show the ALV grid. So in the PBO of that screen you can set the menu by using SET PF-STATUS 'MYMENU'.

For adding additional buttons to the standard ALV toolbar, you have to do the following.


*-- First declare the event receiver class 
*-- Class Definitions
*-- Class Definitions
CLASS lcl_event_receiver DEFINITION DEFERRED.

*---------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVER DEFINITION                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS: add_button_to_toolbar FOR EVENT toolbar      OF cl_gui_alv_grid
                                   IMPORTING e_object e_interactive,
             handle_user_command   FOR EVENT user_command OF cl_gui_alv_grid
                                   IMPORTING e_ucomm.
  PRIVATE SECTION.

ENDCLASS.                        " LCL_EVENT_RECEIVER DEFINITION

*-- Define the object for the event receiver
DATA: ler_add_button_to_toolbar TYPE REF TO lcl_event_receiver,
            ler_user_command          TYPE REF TO lcl_event_receiver.

*-- Class Implementations
*---------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVER IMPLEMENTATION                       *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.

  METHOD add_button_to_toolbar.
*-- Add the SAVE button to the grid toolbar
    PERFORM add_button_to_toolbar CHANGING e_object.
  ENDMETHOD.                    "add_button_to_toolbar

*-- Handle the User Commands
  METHOD handle_user_command.
    PERFORM user_command CHANGING e_ucomm.
  ENDMETHOD.                           "handle_button_click

ENDCLASS.                        " LCL_EVENT_RECEIVER IMPLEMENTATION

*-- Routines
*----------------------------------------------------------------------*
*       FORM  ADD_BUTTON_TO_TOOLBAR                                    *
*----------------------------------------------------------------------*
*       text                                                           *
*----------------------------------------------------------------------*
FORM add_button_to_toolbar CHANGING e_object TYPE REF TO cl_alv_event_toolbar_set.

  DATA: ls_toolbar  TYPE stb_button.

  CLEAR ls_toolbar.
  MOVE 3 TO ls_toolbar-butn_type.
  APPEND ls_toolbar TO e_object->mt_toolbar.
  CLEAR ls_toolbar.
  MOVE: 'SAVE'           TO ls_toolbar-function,
        icon_system_save TO ls_toolbar-icon,
       'Save Entries'    TO ls_toolbar-quickinfo,
       'Save'            TO ls_toolbar-text,
       ' '               TO ls_toolbar-disabled.
  APPEND ls_toolbar TO e_object->mt_toolbar.

ENDFORM.                      " ADD_BUTTON_TO_TOOLBAR

*----------------------------------------------------------------------*
*       Form  USER_COMMAND                                             *
*----------------------------------------------------------------------*
*       text                                                           *
*----------------------------------------------------------------------*
*      -->COMMAND    text                                              *
*----------------------------------------------------------------------*
FORM user_command CHANGING command LIKE sy-ucomm.

  CASE command.
    WHEN 'SAVE'.
    WHEN OTHERS.
  ENDCASE.

ENDFORM.                           " USER_COMMAND

*-- Then after your call to 'set_table_for_first_display' add the following code.

*-- Create the event handler for save
  CREATE OBJECT ler_add_button_to_toolbar.
  SET HANDLER ler_add_button_to_toolbar->add_button_to_toolbar
          FOR lcl_alvgrid.
*-- Create the event handler for user command
  CREATE OBJECT ler_user_command.
  SET HANDLER ler_user_command->handle_user_command
          FOR lcl_alvgrid.
* § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
  CALL METHOD lcl_alvgrid->set_toolbar_interactive.

Hope this helps,

Srinivas

Read only

0 Likes
839

Hi Srinivas,

I dont want create a new button in toolbar.But i need to access all functionalities as available in toolbar from menu bar.

Regards,

Lisa.

If u didnt understand the wording then please look at my reply of the previous message.

Read only

0 Likes
839

I don't know of a way to do it, but what I posted is a work around for you. You remove the standard toolbar function for 'Display' and add your own toolbar function using the code I posted and use the same icon(if that matters) for display.

Srinivas

Read only

0 Likes
839

Hi Lisa,

You can add Menu options in menu bar.

Explore your GUI status and explore the menubar > Put your cursor in any empty place and right clickThen choose Copy the menu option from a standard program.

Hope this will wok for you.

Regards,

Lanka