You are on page 1of 2

ALV Grid OO - Tips

Refreshing ALV Grid Refreshing ALV grid in OO ABAP using method REFRESH_TABLE_DISPLAY does not refresh the layout settings of grid to frontend, for example if you are refreshing the content of alv grid then column does not automatically optimise their width according to new content. To avoid this right way to refresh grid is to first call SET_FRONTEND_LAYOUT then REFRESH_TABLE_DISPLAY .

1 2 3 4 5

CALL METHOD ob_grid->set_frontend_layout EXPORTING is_layout = gs_layout. CALL METHOD ob_grid->refresh_table_display.

GS_LAYOUT is the same layout structure which was used with method SET_TABLE_FOR_FIRST_DISPLAY . Hiding ALV Grid toolbar button. Buttons in the ALV toolbar can be hidden by specifying parameter IT_TOOLBAR_EXCLUDING in method SET_TABLE_FOR_FIRST_DISPLAY. Every button is defined by a constant in class CL_GUI_ALV_GRID. Below are some example MC_FC_FIND - Find MC_FC_LOC_DELETE_ROW - Local: Delete Row MC_FC_LOC_INSERT_ROW - Local: Insert Row MC_FC_PRINT - Print MC_FC_SAVE_VARIANT - Save Variant MC_FC_SELECT_ALL - Select All Rows MC_FC_SORT_ASC - Sort in Ascending Order MC_FC_SORT_DSC - Sort in Descending Order MC_FC_SUBTOT - Subtotals Passing these constant values in internal table to parameter IT_TOOLBAR_EXCLUDING will hide them from screen.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

DATA : li_exclude TYPE ui_functions, ls_exclude TYPE ui_func . ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc. APPEND ls_exclude TO li_exclude. ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc. APPEND ls_exclude TO li_exclude. CALL METHOD ob_grid->set_table_for_first_display EXPORTING is_variant = gs_variant i_save = 'A' is_layout = gs_layout it_toolbar_excluding = li_exclude CHANGING it_outtab = i_rep it_fieldcatalog = i_fld.

Refresh Field Catelog buffer ALV function modules which format fields on ALV based on tablename and fieldname stores the setting in buffer for

performance reason. For example, if you are referring to MARA-MATNR then ALV program will read column heading of data element MATNR from buffer. If you have modified the label in data dictionary it will not be refreshed immediately. To reset this buffer and see your changes immediately you need to clear buffer using program BALVBUFDEL.

You might also like