Professional Documents
Culture Documents
Applies to:
SAP ECC 6.0 or higher. For more information, visit the ABAP homepage.
Summary
This article demonstrates usage of advanced ALV features like editable ALV at cell level when working with dynamic internal tables. Author: Nirav Goradia Company: Larsen & Toubro Infotech Ltd. Created on: 21 September 2010
Author Bio
Nirav Goradia is a Technical Consultant working with L&T Infotech, Mumbai, India. His SAP experience of over 4 years spans various technologies like ABAP, Webdynpro for ABAP, Webdynpro for Java, Adobe Flex.
Table of Contents
Introduction ......................................................................................................................................................... 3 Create field catalog for ALV ................................................................................................................................ 3 Create field catalog for dynamic internal table ................................................................................................... 3 Populate data in dynamic internal table .............................................................................................................. 4 Display ALV on screen ....................................................................................................................................... 5 Related Content .................................................................................................................................................. 6 Disclaimer and Liability Notice ............................................................................................................................ 7
SDN - sdn.sap.com 2
Introduction
ALV stands for Advanced List Viewer, mainly used to enhance the output of a report. ALV comes with set of functions that enhance the readability and functionality of ALV report. One important function that we will be focusing on in this article is creating editable ALV at cell level. Though creating an editable ALV is a straightforward process, things can become little tricky if data displayed in ALV is coming from dynamic internal table and we need to make only certain rows of ALV as editable. We will see in detail, things to take care when working on ALV with dynamic internal tables.
SDN - sdn.sap.com 3
'CHAR10' ). APPEND wa_field_dom TO it_field_dom. wa_field_dom-name = 'FIELD2'. wa_field_dom-type ?= cl_abap_datadescr=>describe_by_name( 'CHAR10' ). APPEND wa_field_dom TO it_field_dom. Important step: to add CELLTAB field to the dynamic internal table This field will be required to control the ALV settings at cell level. wa_field_dom-name = 'CELLTAB'. wa_field_dom-type ?= cl_abap_datadescr=>describe_by_name( 'LVC_T_STYL' ). APPEND wa_field_dom TO it_field_dom. ***Create line structure CALL METHOD cl_abap_structdescr=>create EXPORTING p_components = it_field_dom p_strict = cl_abap_structdescr=>false RECEIVING p_result = wr_struct_descr. **Create table type based on the structure CALL METHOD cl_abap_tabledescr=>create EXPORTING p_line_type = wr_struct_descr p_table_kind = cl_abap_tabledescr=>tablekind_std RECEIVING p_result = wr_tab_descr. **Assign the tables CREATE DATA wr_table_data TYPE HANDLE wr_tab_descr. ASSIGN wr_table_data->* TO <it_table>. CREATE DATA wr_line_data TYPE HANDLE wr_struct_descr. ASSIGN wr_line_data->* TO <wa_table>.
SDN - sdn.sap.com 4
IF sy-subrc = 0. <fs_comp> = it_data_table-field1. ENDIF. ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_table> TO <fs_comp>. IF sy-subrc = 0. <fs_comp> = it_data_table-field2. ENDIF. ASSIGN COMPONENT 'CELLTAB' OF STRUCTURE <wa_table> TO <it_comp>. REFRESH <it_comp>. IF sy-subrc = 0 AND it_data_table-field1 < 100. wa_style-fieldname = 'FIELD1'. wa_style-style = cl_gui_alv_grid=>mc_style_disabled. APPEND wa_style TO <it_comp>. ENDIF. APPEND <wa_table> TO <it_table>. ENDLOOP.
Make sure you have provided the style field name in the layout structure as CELLTAB viz. name of the field of type 'LVC_T_STYL' that is part of the internal table.
wa_layout-stylefname = 'CELLTAB'.
Since we are working with field symbols here, it is mandatory to put check at all relevant places to make sure field symbols are assigned to avoid runtime errors. Such case is more likely to occur when there is no data to be displayed in ALV.
SDN - sdn.sap.com 5
Related Content
Simple ALV list for beginners ALV Grid Control ABAP Development and Programming For more information, visit the ABAP homepage.
SDN - sdn.sap.com 6
SDN - sdn.sap.com 7