cancel
Showing results for 
Search instead for 
Did you mean: 

Wrap in ALV

Former Member

Hi there,

I would like to configure my ALV in wrap or something like.

Because I do not want vertical or horizontal scrolls.

Is it possible?

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Please explain your requirements in a little more detail. What do you mean by "Wrap"? Why do you want to avoid scrolling? For an ALV of any size, the scrolling is serious performance measurement. Displaying all rows of a large table should be avoided at any cost. If you want to print the entire table, you should look into the Print Options of the ALV, which output via the Adobe Document Services.

Former Member
0 Kudos

Hi Thomas,

I had a ALV, but a cell has 255 char and I want broke in many lines.

Ex.: |The quick brown |

fox jumps over

the lazy dog.

And not: The quick brown fox jumps over the lazy dog.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You just need to programmatically set the column attributes via the ALV Model:


  data: l_ref_cmp_usage type ref to if_wd_component_usage.
  l_ref_cmp_usage =   wd_this->wd_cpuse_alv_adv( ).
  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_adv( ).
  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.
  data textview type ref to cl_salv_wd_uie_text_view.
  l_column = l_table->if_salv_wd_column_settings~get_column( 'ADD_PARTICIPANTS' ).
  create object textview.
  textview->set_text_fieldname( 'ADD_PARTICIPANTS' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).

Former Member
0 Kudos

-

Edited by: Arvind Patel on Feb 18, 2011 1:08 PM

surajarafath
Contributor
0 Kudos

Thank You so Much, Thomas.

Your code is working perfectly for me. The time i took is just 10 mins to read this thread clearly and i did my code. Its worked.

Usefull Thread

Anyway i share my code here...

In Comp Contrl..

INITIALIZE_OVERVIEW_ALV Method ALV settings for Overview (V_MAIN)

METHOD initialize_overview_alv .
  DATA:
    lr_comp_alv    TYPE REF TO if_wd_component_usage,
    lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
    lr_config      TYPE REF TO cl_salv_wd_config_table.

*... ALV Component Usage
  lr_comp_alv = wd_this->wd_cpuse_overview_alv( ).
  IF lr_comp_alv->has_active_component( ) IS INITIAL.
    lr_comp_alv->create_component( ).
  ENDIF.

  lr_comp_if_alv = wd_this->wd_cpifc_overview_alv( ).

*... Set Data Node
  DATA:
  lr_node TYPE REF TO if_wd_context_node.

  lr_node = wd_context->get_child_node( 'OVERVIEW_DATA' ).
  lr_comp_if_alv->set_data( lr_node ).

*... Configure ALV
  lr_config = lr_comp_if_alv->get_model( ).

*... ... Table Settings
  lr_config->if_salv_wd_table_settings~set_visible_row_count( 12 ).
  lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
  lr_config->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event ).

*... ... Table Header
  lr_config->if_salv_wd_table_settings~r_header->set_text( 'Overview' ). "#EC NOTEXT

*... ... Table Hierarchy Settings
  lr_config->if_salv_wd_table_hierarchy~set_expanded( abap_true ).

*... ... Standard ALV Functions
*  cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
*    r_model = lr_config
*    allowed = abap_true ).
*
  cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_group_edit(
    r_model = lr_config
    allowed = abap_false ).
*... ... Columns and Column Header
  DATA:
    lt_columns     TYPE salv_wd_t_column_ref,
    ls_column      TYPE salv_wd_s_column_ref,
    lr_column      TYPE REF TO cl_salv_wd_column,
    lr_header      TYPE REF TO cl_salv_wd_column_header,
    lr_drdn_by_key TYPE REF TO cl_salv_wd_uie_dropdown_by_key,
*    lr_drdn_by_key TYPE REF TO cl_salv_wd_fe_dropdown_by_key ,
    lr_input_field TYPE REF TO cl_salv_wd_uie_input_field,
    lr_icon_field  TYPE REF TO cl_salv_wd_uie_image.


  lt_columns = lr_config->if_salv_wd_column_settings~get_columns( ).
 LOOP AT lt_columns INTO ls_column.
    CLEAR lr_header .
    lr_column = ls_column-r_column.
    lr_column->delete_header( ) .
    lr_header = lr_column->create_header(  ).
CASE ls_column-id.
...
..
      WHEN 'COMMENTS'.
        lr_header->set_text('Wrapped Text') .

        DATA textview TYPE REF TO cl_salv_wd_uie_text_view."""""
*        lr_column = lr_config->if_salv_wd_column_settings~get_column( 'COMMENTS' ).
        CREATE OBJECT textview.
        textview->set_text_fieldname( 'COMMENTS' ).
        textview->set_wrapping( abap_true ).
        lr_column->set_cell_editor( textview ).
    ENDCASE.
  ENDLOOP.
ENDMETHOD.

Answers (2)

Answers (2)

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

I tried it the WDDOINIT, same effect.

But after adding the following line at the end of the ALV changing code, it works:


lr_table_settings->set_fixed_table_layout( abap_true ).

This brought up my next question, now I need a solution that the row heights are adjusted automatically according to the displayed text. Is there a method/property for that?

Regards, Steffen

Edited by: Steffen Weber on Feb 10, 2009 1:36 PM

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Are the row heights not automatically adjusting? Are you getting a scrollbar in the text view cell? I didn't do anything differently than the code I posted and my row heights are adjusting automatically.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

no, they are not adjusted automatically.

Maybe this comes with the fixed_table_layout? But it seems that I need this statement in order to get the wrapping working. And no, there's no scrollbar inside the textview.

Any idea how to solve this?

Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I'm afraid that I may not be of much help becuase I simply can't replicate the problem in my 7.0 SP14 system, my 7.01 system, or my 7.02 system. I will post the complete coding for this method and you see if you spot any differences. I just did add the fixed_layout to see if that had any effect - but it still worked for me.

METHOD init_alv_basic .
  DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
  l_ref_cmp_usage =   wd_this->wd_cpuse_alv_basic( ).
  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_basic( ).
  DATA l_table TYPE REF TO cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).

  l_table->if_salv_wd_table_settings~set_read_only( abap_false ).
  l_table->if_salv_wd_table_settings~set_scrollable_col_count( 8 ).
  l_table->if_salv_wd_table_settings~set_fixed_table_layout( abap_true ).
  l_table->if_salv_wd_std_functions~set_edit_append_row_allowed( abap_false ).
  l_table->if_salv_wd_std_functions~set_edit_check_available( abap_false ).
  l_table->if_salv_wd_std_functions~set_edit_insert_row_allowed( abap_false ).
  l_table->if_salv_wd_std_functions~set_edit_delete_row_allowed( abap_false ).
  DATA l_column TYPE REF TO cl_salv_wd_column.
  l_column = l_table->if_salv_wd_column_settings~get_column( 'MANDT' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).
  l_column = l_table->if_salv_wd_column_settings~get_column( 'MEETING_ID' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).
  l_column = l_table->if_salv_wd_column_settings~get_column( 'PM_CONTACT' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).
  l_column = l_table->if_salv_wd_column_settings~get_column( 'ACTIVITY_TYPE' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).
  l_column = l_table->if_salv_wd_column_settings~get_column( 'EVENT' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).
  l_column = l_table->if_salv_wd_column_settings~get_column( 'MAIN_TOPIC' ).
  l_column->set_visible( cl_wd_uielement=>e_visible-none ).

  DATA textview1 TYPE REF TO cl_salv_wd_uie_input_field.
  DATA textview TYPE REF TO cl_salv_wd_uie_text_view.
  l_column = l_table->if_salv_wd_column_settings~get_column( 'ADD_PARTICIPANTS' ).
  CREATE OBJECT textview.

  textview->set_text_fieldname( 'ADD_PARTICIPANTS' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).

  l_column = l_table->if_salv_wd_column_settings~get_column( 'COMMENTS' ).
  CREATE OBJECT textview.
  textview->set_text_fieldname( 'COMMENTS' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).

  l_column = l_table->if_salv_wd_column_settings~get_column( 'STATUS' ).
  DATA ddlb TYPE REF TO cl_salv_wd_uie_dropdown_by_key.
  CREATE OBJECT ddlb
    EXPORTING
      selected_key_fieldname = 'STATUS'.
  ddlb->set_read_only( abap_true ).
  l_column->set_cell_editor( ddlb ).


ENDMETHOD.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

very strange!

We are also on NetWeaver 7.0 SP14 and I used exactly your code (with some adjustments for my scenario), but I still have the same result. Is there anything I miss? Any other setting somewhere else?

Steffen


DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
  
  l_ref_cmp_usage =   wd_this->wd_cpuse_baps_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_baps_alv( ).
  DATA l_table TYPE REF TO cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).

  l_table->if_salv_wd_table_settings~set_read_only( abap_false ).
*  l_table->if_salv_wd_table_settings~set_scrollable_col_count( 8 ).
  l_table->if_salv_wd_table_settings~set_fixed_table_layout( abap_true ).

  l_table->if_salv_wd_std_functions~set_edit_append_row_allowed( abap_false ).
  l_table->if_salv_wd_std_functions~set_edit_check_available( abap_false ).
  l_table->if_salv_wd_std_functions~set_edit_insert_row_allowed( abap_false ).
  l_table->if_salv_wd_std_functions~set_edit_delete_row_allowed( abap_false ).

  DATA l_column TYPE REF TO cl_salv_wd_column.
  DATA textview TYPE REF TO cl_salv_wd_uie_text_view.

  l_column = l_table->if_salv_wd_column_settings~get_column( 'ACTIVITY_DESCR' ).

* Make column smaller
  l_column->set_resizable( abap_true ).
  l_column->set_width( '50' ).

  CREATE OBJECT textview.
  textview->set_text_fieldname( 'ACTIVITY_DESCR' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I'm not sure what other variables there might be. I'm using IE, I'm not running in the portal, I have the default, uncustomized theme. My ALV is contained within a Tray UI element. The tray is using Flow Layout.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

Nearly the same for me:

-IE 7

-default, uncustomized theme

-but my ALV is embedded in a View Container UI Element into which I embedd the ALV via the Windows pane

I'm not aware of how to put an ALV directly in tray, isn't a View Container UI Element required for displaying ALVs?

Regards, Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Sorry, I didn't mean to say that the ALV is directly in the tray. It is of course in a ViewUIElementContainer. The Container is what I have nested within a tray. Just trying to give you the hierarchy of UI elements, because somethings the higher level elements and the layout type used can have some effect.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

I've changed everything to flow layout, and indeed, the ALV layout changed too.

The column width was adjusted that the ALV fits to the browser window.

But still the row height isn't adjusted to the content. I can see that the text is wrapped, but that's all.

Would a screenshot help?

And thanks a lot for all your help!!!!! Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are welcome to post a screen shot, but I'm running out of ideas of what could possibly be different between our two apps.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

checked it also with scrollbars by setting application parameter "WDTABLENAVIGATION = SCROLLBAR".

No change! I think I have to give up!

Regards, Steffen

Former Member
0 Kudos

Hi Steffen,

Did you ever find a solution to the problem of the row height not adjusting as i am getting the same problem!

Regards

Mart

steffen_weber
Employee
Employee
0 Kudos

Hi Mart,

Unfortunately not!

I've tried all the examples Thomas provided, but nothing solved the issue.

Best regards, Steffen

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

is this also true only for Netweaver 7 Enhancment Pack 1?

Here is my MofifyView were I try to wrap a column, but nothing happens/changes:


method WDDOMODIFYVIEW .

    DATA lr_config TYPE REF TO cl_salv_wd_config_table.
    DATA lr_column TYPE REF TO cl_salv_wd_column.
    DATA lr_comp_if_alv TYPE REF TO iwci_salv_wd_table.
    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
    DATA lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    DATA lr_table_settings TYPE REF TO if_salv_wd_table_settings.
  
* ----------------------------------------------------------------------------------------
* Change ALV Incidents
* ----------------------------------------------------------------------------------------

*   Get ALV Component
    lo_cmp_usage =   wd_this->wd_cpuse_baps_alv( ).
    IF lo_cmp_usage->has_active_component( ) IS INITIAL.
      lo_cmp_usage->create_component( ).
    ENDIF.

*   Set Referencees to MYALV
    lr_comp_if_alv = wd_this->wd_cpifc_baps_alv( ).            " get component
    lr_config = lr_comp_if_alv->get_model( ).               " get cofig model
    lr_column_settings ?= lr_config.
    lr_table_settings ?= lr_config.

*   MYALV - Disable Write Protection
*   -----------------------------
    lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).


*   MYALV - Enable Text Wrapping COLUMN
*   ---------------------------------------
    DATA lr_textview TYPE REF TO cl_salv_wd_uie_text_view.

    lr_column = lr_column_settings->get_column( 'ACTIVITY_TITLE' ).

*   Make column smaller
*    lr_column->set_resizable( abap_false ).
    lr_column->set_width( '10' ).

*   Create Text View and enable wrapping
    CREATE OBJECT lr_textview.
    lr_textview->set_text_fieldname( 'ACTIVITY_TITLE' ).
    lr_textview->set_wrapping( abap_true ).
    lr_column->set_cell_editor( lr_textview ).


endmethod.

To test it, I make the column smaller, but even this is currently not replicated on the ALV.

Anything I missed? The field Activity_title is a Char 50 field.

Regards, Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I know that the wrapping inside a text field in an ALV worked before EnhP1. I have an applicaiton that was written back on 7.0 SP14 and it works fine. Perhaps it is because you are running this code in WDDOMODIFYVIEW. I have my logic in the WDDOINIT.

l_column = l_table->if_salv_wd_column_settings~get_column( 'COMMENTS' ).
  create object textview.
  textview->set_text_fieldname( 'COMMENTS' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).