cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a new attribute(column) to an ALV output

Former Member
0 Kudos

Hi All,

I would like to add a new column to an ALV table when I do some action like pressing an INSERT button. How would I actually add up that column to the output? Do I have to modify the view or can I just add a column from output itself. If yes how?

I know how to create a node or an attribute dynamically. Now the problem is when I say INSERT to insert a column how exactly I modify that ALV table to display an extra column.

Pls help me out.

Thank You,

Suresh.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Mayaa and Vijay,

I cannot do that. I have to add column dynamically. I dont know how many columns I end up with. So, I cannot add attibutes in the node first with invisible mode and activate them later on when I need them.

Is it possible to refresh or modify that ALV table on some action? I have that ALV table in a view container UI element in one of my view. If I click a button I would like to modify that table with an extra column. Is it possible to do that?

Thank You,

Gajendra.

Former Member
0 Kudos

Hi Suresh,

First you take all the columns in to your internal table and Make them hide useing the following Code. When you click the Button just change the Visible property. This code will help you to how to hide the column.

*... init ColumnSettings
  data:
    lr_column_settings type ref to if_salv_wd_column_settings.

  lr_column_settings ?= wd_this->r_table.

  data:
    lt_columns type salv_wd_t_column_ref.

  lt_columns = lr_column_settings->get_columns( ).

  data:
    ls_column type salv_wd_s_column_ref.

  data:
    lr_column type ref to cl_salv_wd_column.

**Here I am seetting the following mestion fields should be visible other than those field will be hide.
**In the same way you can change the coding

  loop at lt_columns into ls_column.
    case ls_column-id.
      when 'CARRID' or 'CONNID' or 'FLDATE' or 'PLANETYPE' or
           'PRICE' or 'CURRENCY' or 'SEATSOCC' or
           'DISTANCE' or 'DISTID'.
        ls_column-r_column->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE ).

      when others.
        ls_column-r_column->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-NONE ).
    endcase.
  endloop.

Warm Regards,

Vijay

Former Member
0 Kudos

Hi suresh,

you should hide/show the column you want to add.

declare your column in your node, hide it at first, and then when the user clicks on the button 'add' show it. you have to manage this in your modifyView method.

I hope this helps.

Mayaa