sapdev logo background
sapdev logo sapdev logo
Comments

Hide fields of a web dynpro ALV table




Here are the simple instruction of how to hide certians fields of a web dynpro ALV table. First you need to have created a Basic Web Dynpro ALV table, Once you have your basic web dynpro ALV grid you can follow the basic steps below to hide the specific fields you require.



Step 1 - Add component Use to view
Within the Properties tab of your View click on the create controller usage button add the two entries releated to your ALV component use (ALV_COMP). These have to be added one at a time.


Step 2 - Controller usages entered
Once you have done this your properties tab should look like the following.


Step 3 - Add ABAP code to hide certain fields
Next you need to add the following ABAP code to your WDDOINTINIT or where ever you want as long as it happens before your view is displayed. The top section should aready exist in your code as this populates the ALV table with data, especially if you have used the example Web Dynpro ALV from this website. You therefor only need to add the bottom section of code inorder to hide fields of your ALV.

Note: the wd_this->wd_cpuse_alv_comp( ) will change depending on what you called your ALV usage i.e. if you called your ALV usage TMP_ALV this statement would be wd_this->wd_cpuse_tmp_alv( ).


* create local data variable to access context information
  Data: context_node type ref to if_wd_context_node.

* create table based on context structure
  data: it_scarr type STANDARD TABLE OF if_view1=>element_ALV_TABLE,
        wa_scarr like line of it_scarr.

*select data from required SAP table
  select *
    from scarr
    into table it_scarr.

* bind data to context used by ALV
  context_node = wd_context->get_child_node( name = 'ALV_TABLE').
  context_node->BIND_table( it_scarr ).

* Declare ALV config table
  data: ALV_CONFIG_TABLE  type REF TO CL_SALV_WD_CONFIG_TABLE.

  DATA: wd_table_usage TYPE REF TO if_wd_component_usage.

* Create an instance of ALV component created ALV_COMP is usage name
  wd_table_usage = wd_this->wd_cpuse_alv_comp( ).
  IF wd_table_usage->has_active_component( ) IS INITIAL.
    wd_table_usage->create_component( ).
  ENDIF.

* Get ALV component
  DATA: wd_table TYPE REF TO iwci_salv_wd_table.

  wd_table = wd_this->wd_cpifc_alv_comp( ).
  alv_config_table = wd_table->get_model( ).

* Declare variable to store column details
  DATA: column_settings TYPE REF TO if_salv_wd_column_settings,
        column          TYPE REF TO cl_salv_wd_column.

  column_settings ?= alv_config_table.

***************
*HIDE COLUMNS *
***************
  column = column_settings->get_column( 'MANDT' ).
  column->set_visible( if_wdl_core=>visibility_none ).




comments powered by Disqus