1

I'm using a SALV to display an internal table. Therefore I optimize the columns and set the column text. When the SALV displays the column header is always showing the short text because the value in the column is only a boole_d ('X').

I tried SET_OUTPUT_LENGTH to set a fixed column width. Also deleted the short text and only added a medium or long text. The column remains to small to display the long text.

The initial report was written by someone else and I had to adjust some columns. So the factory method was called twice but I'm not really sure why. Don't know if this causes some error with the configuration.

Does anyone had the same issue? I added some of the code to generate the ALV.

[...]
END-OF-SELECTION.

      "sALV nach Pernr erzeugen
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = go_tabpernr
        CHANGING
          t_table      = gt_result.

    DATA: go_tabpernr      TYPE REF TO   cl_salv_table.
    DATA: go_tabdepart  TYPE REF TO   cl_salv_table.

    go_tabpernr->get_columns( )->set_optimize( abap_true ).
          "Überschrift mitgeben
          go_tabpernr->get_columns( )->get_column( 'TEXT01')->set_medium_text( 'Department' ).
          go_tabpernr->get_columns( )->get_column( 'AUSTRITT')->set_medium_text( 'Austritt' ).
          go_tabpernr->get_columns( )->get_column( 'AUSTRITT')->set_short_text( 'Aust.' ).
          go_tabpernr->get_columns( )->get_column( 'LZK')->set_short_text( 'LZK' ).
          go_tabpernr->get_columns( )->get_column( 'LZK')->set_medium_text( 'Langzeitkrank' ).
          go_tabpernr->get_columns( )->get_column( 'AUSGESTEUERT')->set_medium_text( 'Ausgesteuert' ).
          go_tabpernr->get_columns( )->get_column( 'AUSGESTEUERT')->set_short_text( 'Aus.' ).
          go_tabpernr->get_columns( )->get_column( 'WEINGLIED')->set_short_text( 'Eingl.' ).
          go_tabpernr->get_columns( )->get_column( 'WEINGLIED')->set_medium_text( 'Wiedereingl.' ).
          go_tabpernr->get_columns( )->get_column( 'WEINGLIED')->set_long_text( 'Wiedereingliederung' ).
          go_tabpernr->get_columns( )->get_column( 'NPLUS_TEXT')->set_medium_text( 'N+' ).
          go_tabpernr->get_columns( )->get_column( 'NPLUS_TEXT')->set_short_text( 'N+' ).

      "Darstellung anpassen
      go_tabpernr->get_display_settings( )->set_striped_pattern( abap_true ).

      "Funktionen freischalten
      go_tabpernr->get_functions( )->set_all( abap_true ).

      "Gruppierung und Sortierung
      SORT gt_result  BY pernr DESCENDING . "endda
      go_tabpernr->get_sorts( )->clear( ).

      ""ALV für Department erzeugen (gleiches Vorgehen wie nach pernr)

      "sALV erzeugen
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = go_tabdepart
        CHANGING
          t_table      = gt_result.

  go_tabpernr->display( ).
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Dyrdek
  • 411
  • 4
  • 12
  • 33

3 Answers3

1

You can force the width of the column by using method SET_OUTPUT_LENGTH on the column. For example:

DATA(lo_column) = go_tabpernr->get_columns( )->GET_COLUMN( 'LZK' ).
lo_column->SET_MEDIUM_TEXT( 'Langzeitkrank' ).
lo_column->SET_OUTPUT_LENGTH( '20' ).

To get this to work I had to turn set column optimization to false. There is also a SET_OPTIMIZED method on the cl_salv_column class. You may need to set this for each column to get the desired effect. The following post talks more about using these SET_OPTIMIZE and SET_OPTIMIZED and how they work with the general layout of the ALV Grid.

mperry
  • 91
  • 5
0

According to this: https://archive.sap.com/discussions/thread/220953 it seems to be required (in case of manually setting short/medium/long-texts) to define all three of them, not only short-text or short/medium. always all three of them. Could you give it a try?

dotchuZ
  • 2,621
  • 11
  • 39
  • 65
0

I read you thread and solve the problem like this:

  • I Set the column optimize;
  • After getting the column data as in your code, I set the short and midium text with empty value;
  • Then I used the method set_fixed_header_text to make a similar efect as the "wa_fieldcat-ddictxt = 'L'", but thinking right now I made so many tests that I am not sure that this part is realy necessary, please try without it and check if you get the excel with the complete text of the header.
    lo_columns = lo_alv->get_columns( ).
    lo_columns->set_optimize(  ).  

    lo_col_ref = lo_columns->get( ).

    LOOP AT lo_col_ref ASSIGNING <fs_col_ref>.
          <fs_col_ref>-r_column->set_short_text( '' ).
          <fs_col_ref>-r_column->set_medium_text( '' ).

      CALL METHOD <fs_col_ref>-r_column->set_fixed_header_text
        EXPORTING
          value = 'L'.
    ENDLOOP.
bguiz
  • 27,371
  • 47
  • 154
  • 243