搜档网
当前位置:搜档网 › ALV grid control with 2 different approaches! - ABAP Development - SCN Wiki

ALV grid control with 2 different approaches! - ABAP Development - SCN Wiki

ALV grid control with 2 different approaches! - ABAP Development - SCN Wiki
Last month, i was engaging with a small project that involved with alv grid.?And usually, there are 2 ways to do the alv grid control:1 Call FM2 ALV grid control using OO?approach. (Object Orientied)?and some of my team members are a little confused about which to choose, so i want to talk about the differences between the 2 approaches.For the first one, call funtion module, this is something like the structured programming approach. We call a funtion module, pass some parameters to this funtion module, and it will do some specific function. and it is done. the mostly used function modules are: REUSE_ALV_LIST_DISPLAY ,EUSE_ALV_GRID_DISPLAY,REUSE_ALV_GRID_DISPLAY_LVC.For the later one, OO approach. we are using a more flexible way. and it is different. first we need to create some objects : instance of cl_gui_alv_grid, instance of cl_gui_custom_container. then we have to create a screen to hold the container.finally, we call a method "set_table_for_first_display"apart from that , there are some other different.the parameter types are different .for function modules REUSE_ALV_LIST_DISPLAY ,EUSE_ALV_GRID_DISPLAY,the parameter:is_layout is of type slis_layout_alv,and the parameter it_fieldcat is of type slit_t_fieldcata_alvbut when you using the OO approach, the two parameters are of type lvc_s_layo and lvc_t_fcat. however, when you call function module REUSE_ALV_GRID_DISPLAY_LVC, the two parameters are the some as the OO approach. Following listed a simple sample.Call Function Module:data: layout type slis_layout_alv, fcat type slis_t_fieldcata_alv, w_fcat type slit_fieldcata_alv.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = layout it_fieldcat = fcat TABLES t_outtab = your table.OO approachdata: grid type ref to cl_gui_alv_grid, container type ref to cl_gui_custom_container, layout type lvc_s_layo, fcat type lvc_t_fcat, w_fcat type lvc_s_fcat.if container is initial. create object container exporting container_name = 'mycont'. create object grid exporting i_parent = parent_grid. call method grid->set_table_for_first_display exporting is_layout = layout changing it_fieldcatalog = fcat it_outtab = your it.next time i would talk about the event handling differeces between those 2 approaches. -->

相关主题