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: 

How to use cl_gui_gos_container

Former Member
0 Kudos
349

Hi to all,

Can any one give some examples how to use the cl_gui_gos_container in ooabap.

thanks and regards,

Naresh.

1 REPLY 1

Former Member
0 Kudos
135

Hi,

Please refer this code

PROGRAM.
*----------------------------------------------------------------------*
* ZPA_ENJOY_GOS_CONTAINER - Demo: GOS Container + Toolbar Control
*----------------------------------------------------------------------*
CLASS lcl_main DEFINITION.
  TYPE-POOLS
    icon.
*
  PUBLIC SECTION.
    CLASS-METHODS:
      at_user_command,
*
      on_function_selected FOR EVENT function_selected OF cl_gui_toolbar IMPORTING fcode.
ENDCLASS.                    "lcl_main DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_main IMPLEMENTATION.
  METHOD at_user_command.
    DATA:
      gos     TYPE REF TO cl_gui_gos_container,
      toolbar TYPE REF TO cl_gui_toolbar,
*
      ievents TYPE cntl_simple_events,
      xevents LIKE LINE OF ievents.
*
    CREATE OBJECT gos EXPORTING width = 135.
    CREATE OBJECT toolbar EXPORTING parent       = gos
                                    display_mode = toolbar->m_mode_horizontal.
*   Normale Drucktaste
    toolbar->add_button( fcode     = 'AbC' "!!!
                         icon      = icon_positive
                         butn_type = cntb_btype_first ).
*   Separator
    toolbar->add_button( fcode     = 'AAA'
                         icon      = space
                         butn_type = cntb_btype_sep ).
*   Checkbox
    toolbar->add_button( fcode     = 'XYZ'
                         icon      = icon_negative
                         butn_type = cntb_btype_check ).
*   Radiobutton Group
    toolbar->add_button( fcode     = 'A'
                         icon      = icon_insert_row
                         butn_type = cntb_btype_group ).
*
    toolbar->add_button( fcode     = 'B'
                         icon      = icon_delete_row
                         butn_type = cntb_btype_group ).
*   Events des Toolbar-Controls beim CFW registrieren
    xevents-eventid = toolbar->m_id_function_selected.
    APPEND xevents TO ievents.
*
    CALL METHOD toolbar->set_registered_events( events = ievents ).
*   Objekte für den Handler registrieren
    SET HANDLER on_function_selected FOR toolbar.
  ENDMETHOD.                    "at_user_command
*----------------------------------------------------------------------*
  METHOD on_function_selected.
    MESSAGE s000(oo) WITH fcode.
  ENDMETHOD.                    "on_function_selected
ENDCLASS.                    "lcl_main IMPLEMENTATION
*----------------------------------------------------------------------*
AT USER-COMMAND.
  CALL METHOD lcl_main=>at_user_command.
*----------------------------------------------------------------------*
START-OF-SELECTION.
  WRITE /.
  SET USER-COMMAND 'X'.

Regards,

Nandha