2008 Sep 26 11:37 AM
how can i add MC_FC_LOC_DELETE_ROW to the standard toolbar.
i create my alv as follows:
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZSTRUCTURE'
is_layout = gs_layout
CHANGING
it_outtab = lt_table
it_fieldcatalog = lt_fct
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Edited by: Muhammet Kir on Sep 26, 2008 12:38 PM
2008 Sep 26 11:59 AM
hi,
Refer This:
https://forums.sdn.sap.com/click.jspa?searchID=16796780&messageID=6258928
Regards,
Shiva Kumar
2008 Sep 26 12:12 PM
now i make this but i can't see a delete row button in the toolbar.
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
perform delete_button.
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZSTRUCTURE'
is_layout = gs_layout
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
CHANGING
it_outtab = lt_table
it_fieldcatalog = lt_fct
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
form delete_button.
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO LT_EXCLUDE.
endform. " delete_button
2008 Sep 26 12:04 PM
Hello Muhammet
If you ALV is editable you will get this toolbar function for free.
However, I assume your ALV should not be editable except for deleting entire rows.
Two options are available:
(1) Set entire ALV editable but suppress editability at cell level
(2) Add you own function code to the toolbar
Perhaps you find the following threads useful:
Regards
Uwe
2008 Sep 26 12:04 PM
2008 Sep 26 12:16 PM
Hi Muhammet Kir ,
see this program i think this is helpful for you.
Regards,
Mahesh.
&----
*& Report ZMA_ALV_GRID
*&
&----
*&
*&
&----
REPORT ZMA_ALV_GRID.
*types gt_struct type sflight.
DATA BEGIN OF GT_STRUCT.
INCLUDE STRUCTURE SFLIGHT.
DATA CHEK(1) TYPE C.
DATA RCOL(4) TYPE C.
DATA COLORS TYPE LVC_T_SCOL.
DATA END OF GT_STRUCT.
TYPES: BEGIN OF STRU,
CBOX,
MAXSEATS,
SEATS_OCCUPIED,
END OF STRU.
DATA:STRU1 TYPE STRU.
DATA:STRU2 TYPE TABLE OF STRU.
*ALV GRIDs
DATA GR_ALVGRID TYPE REF TO CL_GUI_ALV_GRID.
DATA GR_ALVGRID1 TYPE REF TO CL_GUI_ALV_GRID.
DATA GC_CUSTOM_CONTROL_NAME TYPE SCRFNAME VALUE 'CC_ALV'.
DATA GC_CUSTOM_CONTROL_NAME1 TYPE SCRFNAME VALUE 'CC_ALV1'.
*CONTAINERs
DATA GR_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA GR_CCONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
*FIELDCATALOGs
DATA GT_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE.
DATA GT_FIELDCAT1 TYPE LVC_T_FCAT WITH HEADER LINE.
*LAYOUTs
DATA GS_LAYOUT TYPE LVC_S_LAYO.
DATA GS_LAYOUT1 TYPE LVC_S_LAYO.
DATA PT_EXCLUDE TYPE UI_FUNCTIONS. "internal table declaration to be passed.
*DATA pt_cell TYPE lvc_t_cell with header line.
DATA : GT_LIST LIKE GT_STRUCT OCCURS 50 WITH HEADER LINE,
GT_LIST1 LIKE GT_STRUCT OCCURS 50 WITH HEADER LINE.
*DATA v_ucomm TYPE sy-ucomm.
CALL SCREEN 100.
&----
*& Module display_alv OUTPUT
&----
text
----
MODULE DISPLAY_ALV OUTPUT.
PERFORM DISPLAY_ALV.
ENDMODULE. " display_alv OUTPUT
&----
*& Module PAI INPUT
&----
text
----
MODULE PAI INPUT.
CASE SY-UCOMM.
WHEN 'EXIT'.
PERFORM EXIT_PROGRAM.
WHEN 'PICK'.
PERFORM CELL_INFO.
ENDCASE.
ENDMODULE. " PAI INPUT
&----
*& Form display_alv
&----
text
----
FORM DISPLAY_ALV.
PERFORM PREPARE_FIELD_CATALOG CHANGING GT_FIELDCAT[].
PERFORM PREPARE_LAYOUT CHANGING GS_LAYOUT.
PERFORM DATA_RETRIVAL.
IF GR_ALVGRID IS INITIAL.
CREATE OBJECT GR_CCONTAINER
EXPORTING
CONTAINER_NAME = GC_CUSTOM_CONTROL_NAME
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.
ENDIF.
CREATE OBJECT GR_ALVGRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = GR_CCONTAINER
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
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.
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE.
PERFORM SET_COL.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = GS_LAYOUT
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = PT_EXCLUDE "excluding toolbar functions
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = GT_LIST[]
IT_FIELDCATALOG = GT_FIELDCAT[]
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.
ELSE.
CALL METHOD GR_ALVGRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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.
ENDIF.
*
PERFORM PREPARE_FIELD_CATALOG1 CHANGING GT_FIELDCAT1[].
PERFORM PREPARE_LAYOUT1 CHANGING GS_LAYOUT1.
PERFORM DATA_RETRIVAL1.
IF GR_ALVGRID1 IS INITIAL.
CREATE OBJECT GR_CCONTAINER1
EXPORTING
CONTAINER_NAME = GC_CUSTOM_CONTROL_NAME1
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.
ENDIF.
CREATE OBJECT GR_ALVGRID1
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = GR_CCONTAINER1
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
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.
PERFORM SET_COL1.
CALL METHOD GR_ALVGRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'STRU1'
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = GS_LAYOUT1
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = PT_EXCLUDE
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = GT_LIST1[]
IT_FIELDCATALOG = GT_FIELDCAT1[]
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.
ELSE.
CALL METHOD GR_ALVGRID1->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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.
ENDIF.
ENDFORM. "display_alv
&----
*& PREPARE_FIELD_CATALOG
&----
text
----
--> p1 text
<-- p2 text
----
FORM PREPARE_FIELD_CATALOG CHANGING PGT_FIELDCAT TYPE LVC_T_FCAT.
DATA LV_FLDCAT TYPE LVC_S_FCAT.
CLEAR LV_FLDCAT.
LV_FLDCAT-ROW_POS = '1'.
LV_FLDCAT-COL_POS = '1'.
LV_FLDCAT-FIELDNAME = 'CHEK'.
LV_FLDCAT-TABNAME = 'GT_LIST'.
LV_FLDCAT-OUTPUTLEN = 5.
LV_FLDCAT-CHECKBOX = 'X'.
LV_FLDCAT-SCRTEXT_M = 'CBOX'.
LV_FLDCAT-EDIT = 'X'. " This option ensures that you can
LV_FLDCAT-JUST = ' '.
LV_FLDCAT-TOOLTIP = 'CHECK BOX'.
LV_FLDCAT-COL_OPT = 'X'.
APPEND LV_FLDCAT TO PGT_FIELDCAT.
CLEAR LV_FLDCAT.
LV_FLDCAT-ROW_POS = '1'.
LV_FLDCAT-COL_POS = '6'.
LV_FLDCAT-FIELDNAME = 'CARRID'.
LV_FLDCAT-TABNAME = 'GT_LIST'.
LV_FLDCAT-OUTPUTLEN = 10.
LV_FLDCAT-SCRTEXT_M = 'Air line code'.
LV_FLDCAT-COL_OPT = 'X'.
APPEND LV_FLDCAT TO PGT_FIELDCAT.
CLEAR LV_FLDCAT.
LV_FLDCAT-ROW_POS = '1'.
LV_FLDCAT-COL_POS = '16'.
LV_FLDCAT-FIELDNAME = 'CONNID'.
LV_FLDCAT-TABNAME = 'GT_LIST'.
LV_FLDCAT-OUTPUTLEN = 10.
LV_FLDCAT-SCRTEXT_M = 'Connection code'.
LV_FLDCAT-COL_OPT = 'X'.
APPEND LV_FLDCAT TO PGT_FIELDCAT.
CLEAR LV_FLDCAT.
LV_FLDCAT-ROW_POS = '1'.
LV_FLDCAT-COL_POS = '26'.
LV_FLDCAT-FIELDNAME = 'PRICE'.
LV_FLDCAT-TABNAME = 'GT_LIST'.
LV_FLDCAT-OUTPUTLEN = 10.
LV_FLDCAT-SCRTEXT_M = 'Price'.
LV_FLDCAT-COL_OPT = 'X'.
APPEND LV_FLDCAT TO PGT_FIELDCAT.
CLEAR LV_FLDCAT.
ENDFORM. " PREPARE_FIELD_CATALOG
&----
*& Form prepare_layout
&----
text
----
-->GS_LAYOUT text
----
FORM PREPARE_LAYOUT CHANGING GS_LAYOUT TYPE LVC_S_LAYO.
CLEAR GS_LAYOUT.
GS_LAYOUT-STYLEFNAME = 'FIELD_STYLE'.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-GRID_TITLE = 'FLIGHT'.
GS_LAYOUT-SEL_MODE = 'A'.
GS_LAYOUT-CTAB_FNAME = 'COLORS'.
GS_LAYOUT-CWIDTH_OPT = ' '.
GS_LAYOUT-NO_TOOLBAR = 'X'.
GS_LAYOUT-NO_HGRIDLN = 'X'.
GS_LAYOUT-NO_VGRIDLN = 'X'.
GS_LAYOUT-SEL_MODE = 'N'.
GS_LAYOUT-NO_ROWMARK = 'X'.
ENDFORM. "prepare_layout
&----
*& Form data_retrival
&----
text
----
FORM DATA_RETRIVAL.
SELECT CARRID
CONNID
PRICE
FROM SFLIGHT
INTO CORRESPONDING FIELDS OF TABLE GT_LIST
UP TO 50 ROWS.
ENDFORM. "data_retrival
----
FORM EXIT_PROGRAM *
----
FORM EXIT_PROGRAM.
CALL METHOD GR_CCONTAINER->FREE.
CALL METHOD GR_CCONTAINER1->FREE.
LEAVE TO SCREEN 0.
ENDFORM. "exit_program
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STAT'.
SET TITLEBAR 'xxx'.
IF W_CUSTOM_CONTAINER IS INITIAL.
*
**sets TITLEBAR
PERFORM TITLEBAR.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Form prepare_field_catalog1
&----
text
----
-->GT_FIELDCAT text
----
FORM PREPARE_FIELD_CATALOG1 CHANGING PGT_FIELDCAT1 TYPE LVC_T_FCAT.
DATA LS_FIELDCAT TYPE LVC_S_FCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-ROW_POS = '1'.
LS_FIELDCAT-COL_POS = '0'.
LS_FIELDCAT-FIELDNAME = 'CHEK'.
LS_FIELDCAT-TABNAME = 'GT_LIST1'.
LS_FIELDCAT-OUTPUTLEN = 5.
LS_FIELDCAT-CHECKBOX = 'X'.
LS_FIELDCAT-COL_OPT = 'X'.
LS_FIELDCAT-SCRTEXT_M = 'CBOX'.
LS_FIELDCAT-EDIT = 'X'. " This option ensures that you can
LV_FLDCAT-TOOLTIP = 'CHECK BOX'.
APPEND LS_FIELDCAT TO PGT_FIELDCAT1.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-TABNAME = 'gt_list1'.
LS_FIELDCAT-FIELDNAME = 'SEATSMAX'.
LS_FIELDCAT-SCRTEXT_M = 'MAX. SEATS'.
LS_FIELDCAT-COL_POS = '6'.
LS_FIELDCAT-OUTPUTLEN = 10.
LS_FIELDCAT-COL_OPT = 'X'.
ls_fieldcat-emphasize = 'C400'.
ls_fieldcat-key = ' '.
LS_FIELDCAT-EDIT = 'X'.
APPEND LS_FIELDCAT TO PGT_FIELDCAT1.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-TABNAME = 'gt_list1'.
LS_FIELDCAT-COL_POS = '16'.
LS_FIELDCAT-FIELDNAME = 'SEATSOCC'.
LS_FIELDCAT-SCRTEXT_M = 'SEATS OCCUPIED'.
LS_FIELDCAT-EDIT = 'X'.
LS_FIELDCAT-COL_OPT = 'X'.
APPEND LS_FIELDCAT TO PGT_FIELDCAT1.
CLEAR LS_FIELDCAT.
ENDFORM. "prepare_field_catalog
&----
*& Form prepare_layout1
&----
text
----
-->GS_LAYOUT text
----
FORM PREPARE_LAYOUT1 CHANGING GS_LAYOUT1 TYPE LVC_S_LAYO.
GS_LAYOUT1-STYLEFNAME = 'FIELD_STYLE'.
GS_LAYOUT1-ZEBRA = 'X'.
GS_LAYOUT-GRID_TITLE = 'FLIGHT'.
GS_LAYOUT1-SEL_MODE = 'A'.
GS_LAYOUT1-CTAB_FNAME = 'COLORS'.
GS_LAYOUT1-CWIDTH_OPT = 'X'.
GS_LAYOUT1-NO_TOOLBAR = 'X'.
GS_LAYOUT1-SEL_MODE = 'N'.
GS_LAYOUT1-NO_ROWMARK = 'X'.
GS_LAYOUT1-INFO_FNAME = 'RCOL'.
GS_LAYOUT1-NO_HGRIDLN = 'X'.
GS_LAYOUT1-NO_VGRIDLN = 'X'.
GS_LAYOUT1-NO_HEADERS = 'X'.
GS_LAYOUT1-NO_KEYFIX = ' '.
GS_LAYOUT1-FRONTEND = 'X'.
ENDFORM. "prepare_layout
&----
*& Form data_retrival1
&----
text
----
FORM DATA_RETRIVAL1.
SELECT SEATSMAX
SEATSOCC
FROM SFLIGHT
INTO CORRESPONDING FIELDS OF TABLE GT_LIST1
UP TO 50 ROWS.
ENDFORM. "data_retrival
&----
*& Form cell_info
&----
text
----
FORM CELL_INFO. "CHANGING pt_cell TYPE lvc_t_cell.
DATA LT_CELL TYPE LVC_T_CELL WITH HEADER LINE.
CALL METHOD GR_ALVGRID->GET_SELECTED_CELLS
IMPORTING
ET_CELL = LT_CELL[].
LOOP AT LT_CELL.
WRITE : LT_CELL-COL_ID , LT_CELL-ROW_ID.
ENDLOOP.
MODIFY pt_cell[] from lt_cell[].
ENDFORM. "cell_info
&----
*& Form set_col
&----
text
----
FORM SET_COL .
DATA LS_CELLCOLOR TYPE LVC_S_SCOL.
LOOP AT GT_LIST.
IF GT_LIST-PRICE GT 500.
LS_CELLCOLOR-FNAME = 'PRICE'.
LS_CELLCOLOR-COLOR-COL = 5.
LS_CELLCOLOR-COLOR-INT = 1.
LS_CELLCOLOR-COLOR-INV = 0.
APPEND LS_CELLCOLOR TO GT_LIST-COLORS.
ELSE.
LS_CELLCOLOR-FNAME = 'PRICE'.
LS_CELLCOLOR-COLOR-COL = 3.
LS_CELLCOLOR-COLOR-INT = 1.
APPEND LS_CELLCOLOR TO GT_LIST-COLORS.
ENDIF.
MODIFY GT_LIST.
ENDLOOP.
ENDFORM. "set_col
&----
*& Form set_col1
&----
text
----
FORM SET_COL1.
DATA : IND TYPE SY-TABIX,
INDX TYPE SY-TABIX.
LOOP AT GT_LIST1.
IND = SY-TABIX / 2.
INDX = SY-TABIX - IND.
IF INDX EQ IND.
GT_LIST1-RCOL = 'C500'.
ENDIF.
MODIFY GT_LIST1.
ENDLOOP.
ENDFORM. "set_col
*FORM TITLEBAR.
*SET TITLEBAR 'TITLE'.
*ENDFORM.
&----
*& Form exclude_tb_functions
&---- subroutine to exclude toolbar options -
text
----
-->PT_EXCLUDE text
----
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_MAXIMUM.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_MINIMUM.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SUBTOT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SUM.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_SUBTOT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_SUM.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_FILTER.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_ASC.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_DSC.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_PRINT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_EXPORT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_VIEW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_FIND_MORE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_FIND.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_GRAPH.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_INFO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_DETAIL.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_AVERAGE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_CURRENT_VARIANT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_REFRESH.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. "data_retrival1
2008 Sep 26 1:49 PM
i make it now like this but it still don't work
DATA PT_EXCLUDE TYPE UI_FUNCTIONS.
FORM delete_button.
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_MAXIMUM.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " delete_button
MODULE init_0100 OUTPUT.
IF g_custom_container1 IS INITIAL.
CREATE OBJECT g_custom_container1
EXPORTING
container_name = 'CCCONTAINER1'.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container1.
PERFORM delete_button.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'ZSERIALNO_INPUT'
is_layout = gs_layout
IT_TOOLBAR_EXCLUDING = PT_EXCLUDE
CHANGING
it_outtab = lt_zserialno_input
it_fieldcatalog = lt_fct
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
2008 Sep 26 8:17 PM
Hello Muhammet
The sample report ZUS_SDN_ALV_EVT_TOOLBAR_2 demonstrates how to define your own 'DELETE_ROW' button on a non-editable ALV list.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_ALV_EVT_TOOLBAR_2
*&
*&---------------------------------------------------------------------*
*& Thread: MC_FC_LOC_DELETE_ROW alv oo
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1064506"></a>
*&---------------------------------------------------------------------*
*& This sample report explains the handling of event TOOLBAR in order
*% to activate or inactive buttons of the ALV toolbar.
*&
*& Based on: BCALV_GRID_DEMO
*&
*& Procedure: Copy BCALV_GRID_DEMO and replace entire coding OR
* copy screen '0100' and GUI status 'MAIN100' from
* BCALV_GRID_DEMO to this report.
*&---------------------------------------------------------------------*
REPORT zus_sdn_alv_evt_toolbar_2.
TYPE-POOLS: abap, cntb, icon.
DATA:
ok_code TYPE ui_func,
gt_sflight TYPE TABLE OF sflight,
*
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_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_okcode TYPE ui_func. " store ok_code 'SAVE'
CLASS-METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive
sender,
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_toolbar.
* § 2.In event handler method for event TOOLBAR: Append own functions
* by using event parameter E_OBJECT.
DATA:
ls_toolbar TYPE stb_button,
ls_menu TYPE stb_btnmnu.
*....................................................................
* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
* This class has got one attribute, namly MT_TOOLBAR, which
* is a table of type TTB_BUTTON. One line of this table is
* defined by the Structure STB_BUTTON (see data deklaration above).
*
* A remark to the flag E_INTERACTIVE:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 'e_interactive' is set, if this event is raised due to
* the call of 'set_toolbar_interactive' by the user.
* You can distinguish this way if the event was raised
* by yourself or by ALV
* (e.g. in method 'refresh_table_display').
* An application of this feature is still unknown... :-)
* Add separator to separate default and new buttons
CLEAR: ls_toolbar.
ls_toolbar-butn_type = cntb_btype_sep. " separator
APPEND ls_toolbar TO e_object->mt_toolbar.
* Add new button "DELETE_ROW"
CLEAR: ls_toolbar.
ls_toolbar-function = 'DELETE_ROW'.
ls_toolbar-icon = icon_delete_row.
ls_toolbar-quickinfo = 'Delete Row'.
ls_toolbar-butn_type = cntb_btype_button.
ls_toolbar-disabled = abap_false.
* ls_toolbar-checked = ' '.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
CHECK ( e_ucomm = 'DELETE_ROW' ).
" Trigger PAI with ok-code = 'DELETE_ROW'
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = e_ucomm
* IMPORTING
* rc =
.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
SELECT * FROM sflight INTO TABLE gt_sflight.
CALL SCREEN 100.
END-OF-SELECTION.
*---------------------------------------------------------------------*
* 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 g_grid1
EXPORTING
i_parent = g_custom_container.
CALL METHOD g_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 g_grid1,
lcl_eventhandler=>handle_user_command FOR g_grid1.
ENDIF.
* $Comment: Toolbar can be modified on-the-fly
g_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.
TRANSLATE ok_code TO UPPER CASE.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'DELETE_ROW'.
PERFORM delete_row.
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
*&---------------------------------------------------------------------*
*& Form DELETE_ROW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM delete_row .
" define local data
DATA: lt_cells TYPE lvc_t_cell,
ls_cell TYPE lvc_s_cell.
CALL METHOD g_grid1->get_selected_cells
IMPORTING
et_cell = lt_cells.
SORT lt_cells BY row_id DESCENDING. " !!!
LOOP AT lt_cells INTO ls_cell.
DELETE gt_sflight INDEX ls_cell-row_id.
ENDLOOP.
CALL METHOD g_grid1->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
* EXCEPTIONS
* finished = 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.
ENDFORM. " DELETE_ROW
Regards
Uwe