Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV -- OOP method

Sujai
Participant
0 Likes
780

Hi

I am using a hierarchical ALV to display my output using OO methods (Factory method to be precise). How can I increase the width of the columns for displaying the output? The columns titles are getting truncated at the field size.

Pls help.

thanx

Sujai

7 REPLIES 7
Read only

Former Member
0 Likes
742
in the fieldcatalog you can increase the sizw

loop at it_fieldcat into wa_fieldcat.

case wa_fieldcat-fieldname.

when 'FIELD1'.
wa_fieldcat-outputlen = '25'.
modify it_fieldcat from wa_fieldcat.

when 'FIELD2'.
wa_fieldcat-outputlen = '35'.
modify it_fieldcat from wa_fieldcat.

endcase.

endloop.
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
742

Are you "Optimizing the column width" somewhere?

Regards,

Rich Heilman

Read only

0 Likes
742

You might want to try to turn it off, if it is already being set.

data: gr_columns type ref to cl_salv_columns.

gr_columns = gr_table->get_columns( ).
gr_columns->SET_OPTIMIZE( ).

Regards,

Rich Heilman

Read only

0 Likes
742

Hi

The columns are not optimized. Actually the field titles that i gave are a little longer than the field size of the columns, which is now getting truncated. This is the method that im using to display the alv

CALL METHOD cl_salv_hierseq_table=>factory

EXPORTING

t_binding_level1_level2 = lt_binding

IMPORTING

r_hierseq = gr_hierseq

CHANGING

t_table_level1 = gt_final_hdr

t_table_level2 = gt_final_item.

and I am changing the titles using

FORM set_columns_heading_009 USING ir_columns TYPE REF TO cl_salv_columns_hierseq

iv_col TYPE lvc_fname "column name

iv_long TYPE scrtext_l "Long text

iv_medium TYPE scrtext_m "Medium text

iv_short TYPE scrtext_s. "Short text

DATA: lr_column TYPE REF TO cl_salv_column.

lr_column = ir_columns->get_column( iv_col ).

    • Set column headings

lr_column->set_long_text( iv_long ).

lr_column->set_medium_text( iv_medium ).

lr_column->set_short_text( iv_short ).

lr_column->set_output_length( 15 ).

even after giving the output length there is no change in the output.

How do I go about changing it?

Regards

sujai

Read only

Former Member
0 Likes
742

Hi

When you fill the catalog table you can also set the size of the colunm.

Max

Read only

Former Member
0 Likes
742

Hi,

In the layout

 
DATA:        w_variant TYPE disvariant,
 PERFORM f9400_layout using sy-title 'X' 'A' 'X' p_layout.

 FORM f9400_layout USING    value(ptitle)
                     value(pzebra)
                     value(pmode)
                     value(pwidth)
                     value(pvariant).

  w_layout-grid_title = ptitle.
  w_layout-zebra      = pzebra.
  w_layout-sel_mode   = pmode.
  w_layout-cwidth_opt = pwidth.
  w_variant-handle    = pvariant.
  w_variant-report    = sy-repid.


ENDFORM.                    " f9400_layout
 CALL METHOD o_alvgrid->set_table_for_first_display
     EXPORTING
*    I_BYPASSING_BUFFER            =
*    I_BUFFER_ACTIVE               =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
       is_variant                    = w_variant
       i_save                        = c_a
*    I_DEFAULT                     = 'X'
       is_layout                     = p_layout
*    IS_PRINT                      =
       it_special_groups             = p_groups[]
       it_toolbar_excluding          = p_exclude[]
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
    CHANGING
       it_outtab                     = p_output[]
       it_fieldcatalog               = p_fieldcat[]
*    IT_SORT                       =
*    IT_FILTER                     =
    EXCEPTIONS
       invalid_parameter_combination = 1
       program_error                 = 2
       too_many_lines                = 3
       OTHERS                        = 4.

Read only

Former Member
0 Likes
742

Hi

you may try this piece

*to change length

LOOP AT t_fieldcat INTO ls_fcat.

CASE ls_fcat-fieldname.

WHEN field1.

ls_fcat-outputlen = 10.

WHEN field2.

ls_fcat-outputlen = 20.

WHEN field3.

ls_fcat-outputlen = 20.

WHEN field4.

ls_fcat-outputlen = 20.

WHEN OTHERS.

"do nothing

ENDCASE.

*fixed column

ls_fcat-fix_column = c_x.

*changes to take effect

MODIFY t_fieldcat FROM ls_fcat.

CLEAR ls_fcat.

Regards