cancel
Showing results for 
Search instead for 
Did you mean: 

How to change layout dynamically?

Former Member
0 Kudos

Hi,

I have 15 fields in my WD ALV output. All i need is to display only certain columns on some action (by hitting button1) and to display other set of columns on other action (by hitting button2). Please let me know how should i approach in this?

Rgds

Sudhanshu

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello

In ALV, YOU BIND THE TABLE, SO all what you binding will be displayed.

In the Action, Get the context, Check which all attributes you want to display, Bind them to context table.

It will show only those.

Best regards,

Rohit

Former Member
0 Kudos

how to check whcih all attributes i need to display as output. user can selet any set of fields from layout. can you please elaborate more?

rgds

sudhanshu

Former Member
0 Kudos

Hello

In ALV there is already a view option is there, Where user can select which columns he want to see and which to hide.

User can save views based on its requirement and switch when ever required.

Other wise, You have to get the attributes and set them dynmically.

BEst regards,

Rohit

Former Member
0 Kudos

yes, that is what my issue is. how to get those attrbute and set them dynamically.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Via the ALV Model API classes you can access all the current columns and then hide any of them you wish. Here is some sample code:

DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
  l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

  DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
  l_salv_wd_table = wd_this->wd_cpifc_alv( ).
  DATA l_table TYPE REF TO cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).

 DATA l_column TYPE REF TO cl_salv_wd_column.
  l_column = l_table->if_salv_wd_column_settings~get_column( 'CLIENT' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).

There is also a GET_COLUMNS method that will return an internal table of all columns and their objects that you can loop through.