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

Making toolbar invisble when using a container

munishsb
Participant
0 Likes
429

Hi

I am using multiple container in one screen, as container always comes with toolbar, i dont need that, so anyonehelp me how to make toolbar invisible from the container

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
393

Hi,

sorry check this one.

&----


*& Report Y_TOOL_DEL *

*& *

&----


*& *

*& *

&----


REPORT Y_TOOL_DEL .

type-pools: abap, cntb, icon.

data: gt_sflight type table of sflight.

data: ok_code type ui_func,

*gt_sflight type table of sflight,

g_container type scrfname value 'CUST',

g_grid1 type ref to cl_gui_alv_grid,

g_custom_container type ref to cl_gui_custom_container.

parameters: p_inact radiobutton group grp1 default 'X',

p_dele radiobutton group grp1,

p_newbut as checkbox default ' ',

p_newddm as checkbox default 'X'.

----


  • CLASS lcl_eventhanler DEFINITION

----


*

----


class lcl_eventhanler 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_eventhanler DEFINITION

----


  • CLASS lcl_eventhanler IMPLEMENTATION

----


*

----


class lcl_eventhanler implementation.

method handle_toolbar.

data: ls_toolbar type stb_button,

ls_menu type stb_btnmnu.

add 1 to md_cnt.

    • Inactivate toolbar butttons.* if ( p_inact = abap_true ).

loop at e_object->MT_TOOLBAR into ls_toolbar from 1 to md_cnt.

ls_toolbar-DISABLED = 'X'.

modify e_object->MT_TOOLBAR from ls_toolbar.

endloop.

    • delete toolbar buttons.* else.

do md_cnt times.

delete e_object->MT_TOOLBAR index 1.

enddo.

endif.

*Add new button.

if ( p_newbut = abap_true ).

  • add seperator to seperate default and new buttons.

clear ls_toolbar.

ls_toolbar-butn_type = '3'.

append ls_toolbar to e_object->MT_TOOLBAR.

*add new button 'detail'.

clear ls_toolbar.

ls_toolbar-function = 'DETAIL'.

ls_toolbar-icon = icon_detail.

ls_toolbar-quickinfo = 'Quickinfo'.

ls_toolbar-butn_type = 0.

ls_toolbar-disabled = abap_false.

ls_toolbar-text = 'DETAILS'.

append ls_toolbar to e_object->MT_TOOLBAR.

endif.

*Add new dropdown menu

if ( p_newddm = abap_true ).

  • add seperator to seperate default and new buttons.

clear ls_toolbar.

ls_toolbar-butn_type = '3'.

append ls_toolbar to e_object->MT_TOOLBAR.

*add new dropdown menu 'detail'.

clear ls_toolbar.

ls_toolbar-function = 'DDMENU'.

ls_toolbar-icon = icon_detail.

ls_toolbar-quickinfo = 'Quickinfo'.

ls_toolbar-butn_type = 2.

ls_toolbar-disabled = abap_false.

ls_toolbar-text = 'DD-Menu'.

append ls_toolbar to e_object->MT_TOOLBAR.

endif.

endmethod. "handle_toolbar

endclass. "lcl_eventhanler IMPLEMENTATION

start-of-selection.

select * from sflight into table gt_sflight.

call screen 100.

end-of-selection.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'NAV'.

  • SET TITLEBAR 'xxx'.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING

  • PARENT =

CONTAINER_NAME = g_container

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_SYSTEM_ERROR = 2

  • CREATE_ERROR = 3

  • LIFETIME_ERROR = 4

  • LIFETIME_DYNPRO_DYNPRO_LINK = 5

  • others = 6

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT G_GRID1

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = g_custom_container

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

  • EXCEPTIONS

  • ERROR_CNTL_CREATE = 1

  • ERROR_CNTL_INIT = 2

  • ERROR_CNTL_LINK = 3

  • ERROR_DP_CREATE = 4

  • others = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD G_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

I_STRUCTURE_NAME = 'SFLIGHT'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = gt_sflight

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • when there is user interaction , the below lines

  • should be mentioned

*SET EVENT HANDLER FOR EVENT TOOLBAR

set handler:

lcl_eventhanler=>handle_toolbar for g_grid1.

*endif.

g_grid1->SET_TOOLBAR_INTERACTIVE( ) .

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

  • to react on custom events

CALL METHOD CL_GUI_CFW=>DISPATCH

*IMPORTING

  • RETURN_CODE = .

.

case sy-ucomm.

when 'EXIT'.

  • perform exit_program.

leave program.

when 'OTHERS'.

  • do nothing

endcase.

clear ok_code.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form exit_program

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM exit_program .

leave program.

ENDFORM. " exit_program

2 REPLIES 2
Read only

Former Member
0 Likes
393

hi,

Just execte this object and see

&----


*& Report Y_TOOLBAR *

*& *

&----


*& *

*& *

&----


REPORT Y_TOOLBAR .

TYPE-POOLS: SLIS.

PARAMETERS : MAT TYPE MATNR.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

ERSDA TYPE ERSDA,

END OF ITAB.

SELECT MATNR ERSDA FROM MARA INTO TABLE ITAB WHERE MATNR < 'B'.

DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV,

T_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV.

  • data : g_layout type slis_layout_alv.

wa_fcat-col_pos = '2'.

wa_fcat-edit = 'X'.

wa_fcat-no_out = 'X'.

WA_FCAT-FIELDNAME = 'MATNR'.

WA_FCAT-REF_FIELDNAME = 'MATNR'.

WA_FCAT-REF_TABNAME = 'MARA'.

APPEND WA_FCAT TO T_FCAT.

clear : wa_fcat.

wa_fcat-col_pos = '1'.

WA_FCAT-FIELDNAME = 'ERSDA'.

WA_FCAT-REF_FIELDNAME = 'ERSDA'.

WA_FCAT-REF_TABNAME = 'MARA'.

APPEND WA_FCAT TO T_FCAT.

clear : wa_fcat.

wa_fcat-col_pos = '3'.

WA_FCAT-checkbox = 'X'.

wa_fcat-seltext_l = 'check'.

wa_fcat-edit = 'X'.

APPEND WA_FCAT TO T_FCAT.

clear : wa_fcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_CALLBACK_TOP_OF_PAGE = 'TOP'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = T_FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'X'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = ITAB

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

form top.

data : head type slis_t_listheader with header line..

head-typ = 'H'.

head-info = 'YOGESH'.

append head.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = head

I_LOGO = 'ENJOY'

  • I_END_OF_LIST_GRID =

.

endform.

Read only

Former Member
0 Likes
394

Hi,

sorry check this one.

&----


*& Report Y_TOOL_DEL *

*& *

&----


*& *

*& *

&----


REPORT Y_TOOL_DEL .

type-pools: abap, cntb, icon.

data: gt_sflight type table of sflight.

data: ok_code type ui_func,

*gt_sflight type table of sflight,

g_container type scrfname value 'CUST',

g_grid1 type ref to cl_gui_alv_grid,

g_custom_container type ref to cl_gui_custom_container.

parameters: p_inact radiobutton group grp1 default 'X',

p_dele radiobutton group grp1,

p_newbut as checkbox default ' ',

p_newddm as checkbox default 'X'.

----


  • CLASS lcl_eventhanler DEFINITION

----


*

----


class lcl_eventhanler 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_eventhanler DEFINITION

----


  • CLASS lcl_eventhanler IMPLEMENTATION

----


*

----


class lcl_eventhanler implementation.

method handle_toolbar.

data: ls_toolbar type stb_button,

ls_menu type stb_btnmnu.

add 1 to md_cnt.

    • Inactivate toolbar butttons.* if ( p_inact = abap_true ).

loop at e_object->MT_TOOLBAR into ls_toolbar from 1 to md_cnt.

ls_toolbar-DISABLED = 'X'.

modify e_object->MT_TOOLBAR from ls_toolbar.

endloop.

    • delete toolbar buttons.* else.

do md_cnt times.

delete e_object->MT_TOOLBAR index 1.

enddo.

endif.

*Add new button.

if ( p_newbut = abap_true ).

  • add seperator to seperate default and new buttons.

clear ls_toolbar.

ls_toolbar-butn_type = '3'.

append ls_toolbar to e_object->MT_TOOLBAR.

*add new button 'detail'.

clear ls_toolbar.

ls_toolbar-function = 'DETAIL'.

ls_toolbar-icon = icon_detail.

ls_toolbar-quickinfo = 'Quickinfo'.

ls_toolbar-butn_type = 0.

ls_toolbar-disabled = abap_false.

ls_toolbar-text = 'DETAILS'.

append ls_toolbar to e_object->MT_TOOLBAR.

endif.

*Add new dropdown menu

if ( p_newddm = abap_true ).

  • add seperator to seperate default and new buttons.

clear ls_toolbar.

ls_toolbar-butn_type = '3'.

append ls_toolbar to e_object->MT_TOOLBAR.

*add new dropdown menu 'detail'.

clear ls_toolbar.

ls_toolbar-function = 'DDMENU'.

ls_toolbar-icon = icon_detail.

ls_toolbar-quickinfo = 'Quickinfo'.

ls_toolbar-butn_type = 2.

ls_toolbar-disabled = abap_false.

ls_toolbar-text = 'DD-Menu'.

append ls_toolbar to e_object->MT_TOOLBAR.

endif.

endmethod. "handle_toolbar

endclass. "lcl_eventhanler IMPLEMENTATION

start-of-selection.

select * from sflight into table gt_sflight.

call screen 100.

end-of-selection.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'NAV'.

  • SET TITLEBAR 'xxx'.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING

  • PARENT =

CONTAINER_NAME = g_container

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_SYSTEM_ERROR = 2

  • CREATE_ERROR = 3

  • LIFETIME_ERROR = 4

  • LIFETIME_DYNPRO_DYNPRO_LINK = 5

  • others = 6

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT G_GRID1

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = g_custom_container

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

  • EXCEPTIONS

  • ERROR_CNTL_CREATE = 1

  • ERROR_CNTL_INIT = 2

  • ERROR_CNTL_LINK = 3

  • ERROR_DP_CREATE = 4

  • others = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD G_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

I_STRUCTURE_NAME = 'SFLIGHT'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = gt_sflight

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • when there is user interaction , the below lines

  • should be mentioned

*SET EVENT HANDLER FOR EVENT TOOLBAR

set handler:

lcl_eventhanler=>handle_toolbar for g_grid1.

*endif.

g_grid1->SET_TOOLBAR_INTERACTIVE( ) .

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

  • to react on custom events

CALL METHOD CL_GUI_CFW=>DISPATCH

*IMPORTING

  • RETURN_CODE = .

.

case sy-ucomm.

when 'EXIT'.

  • perform exit_program.

leave program.

when 'OTHERS'.

  • do nothing

endcase.

clear ok_code.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form exit_program

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM exit_program .

leave program.

ENDFORM. " exit_program