Skip to Content
author's profile photo Former Member
Former Member

Change Column property for ALV using FACTORY method

Hi,

Please find the code below, there is no change for the Column header names.

Kindly guide me.

*- Final Internal Table
Types:
        BEGIN OF gy_final,
          vstel   TYPE vstel,         "Shipping Point
          matnr   TYPE matnr,         "Material Number
          maktx   TYPE maktx,         "Material Description
          profl   TYPE adge_profl,    "Dangerous Goods Indicator Profile
          lfimg   TYPE lfimg,         "Actual quan delivered (in sales units)
          packm   TYPE matnr,     
          pakwt   TYPE lfimg,
          qpackm  TYPE lfimg,     "Quantity of packing material
          pmatty  TYPE mtart,     "Type of packing material
        END OF gy_final,

CONSTANTS:
        lc_error            TYPE symsgty VALUE 'E'.

  DATA:
        lt_columns          TYPE REF TO   cl_salv_columns_table,
*- Individual Column
        lt_column           TYPE REF TO   cl_salv_column,
        lt_salv_not_found   TYPE REF TO   cx_salv_not_found,
        lt_salv_msg         TYPE REF TO   cx_salv_msg,
*- Exception class
        lv_msg              TYPE          string,
        lv_col_l            TYPE          scrtext_l,
        lv_col_m            TYPE          scrtext_m,
        lv_col_s            TYPE          scrtext_s.


*- Get all the Columns
  lt_columns = pi_alv_output->get_columns( ).
*- Set Column optimization
  lt_columns->set_optimize( 'X' ).

*- Change the properties of Individual Columns
  TRY.
*- 'LFIMG' = Quantity delivered
      CLEAR lv_col_m.
      lt_column = lt_columns->get_column( 'LFIMG' ).
      lv_col_m = text-001.
      lt_column->set_medium_text( lv_col_m ).
      lt_column->set_output_length( 25 ).

*- Catch the Exceptions
    CATCH cx_salv_not_found INTO lt_salv_not_found.
      lv_msg = lt_salv_not_found->get_text( ).
      MESSAGE lv_msg TYPE lc_error.
  ENDTRY.

  TRY.
*- 'PACKM' = Packing Material
      CLEAR lv_col_m.
      lt_column = lt_columns->get_column( 'PACKM' ).
      lv_col_m = text-002.
      lt_column->set_medium_text( lv_col_m ).
      lt_column->set_output_length( 25 ).

*- Catch the Exceptions
    CATCH cx_salv_not_found INTO lt_salv_not_found.
      lv_msg = lt_salv_not_found->get_text( ).
      MESSAGE lv_msg TYPE lc_error.
  ENDTRY.

  TRY.
*- 'PAKWT' = Packaging Weight in KG
      CLEAR lv_col_l.
      lt_column = lt_columns->get_column( 'PAKWT' ).
      lv_col_m = text-005.
      lt_column->set_long_text( lv_col_l ).
      lt_column->set_output_length( 30 ).

*- Catch the Exceptions
    CATCH cx_salv_not_found INTO lt_salv_not_found.
      lv_msg = lt_salv_not_found->get_text( ).
      MESSAGE lv_msg TYPE lc_error.
  ENDTRY.


  TRY.
*- 'QPACKM' = Packing Material Quan.
      CLEAR lv_col_l.
      lt_column = lt_columns->get_column( 'QPACKM' ).
      lv_col_l = text-003.
      lt_column->set_long_text( lv_col_l ).
      lt_column->set_output_length( 30 ).
*- Catch the Exceptions
    CATCH cx_salv_not_found INTO lt_salv_not_found.
      lv_msg = lt_salv_not_found->get_text( ).
      MESSAGE lv_msg TYPE lc_error.
  ENDTRY.

  TRY.
*- 'PMATTY' = Packing Material Type
      CLEAR lv_col_l.
      lt_column = lt_columns->get_column( 'PMATTY' ).
      lv_col_l = text-004.
      lt_column->set_long_text( lv_col_l ).
      lt_column->set_output_length( 30 ).
*- Catch the Exceptions
    CATCH cx_salv_not_found INTO lt_salv_not_found.
      lv_msg = lt_salv_not_found->get_text( ).
      MESSAGE lv_msg TYPE lc_error.
  ENDTRY .

Edited by: Raj on Sep 10, 2010 7:27 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Sep 10, 2010 at 02:35 PM

    Try to set all the three text for the Column using the methods SET_SHORT_TEXT, SET_MEDIUM_TEXT & SET_LONG_TEXT. You can also check this blog post: http://help-abap.blogspot.com/2008/09/salv-model-7-changing-column-settings.html

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Raj

      Naimesh has paved the way for you. On ERP 6.0 you will sample report SALV_DEMO_TABLE_COLUMNS teaching you a lot about column settings, e.g.:

      ...
      *... §4.1 set exception column
        try.
            lr_columns->set_exception_column( 'EXCEPTION' ).
          catch cx_salv_data_error.                           "#EC NO_HANDLER
        endtry.
        try.
            lr_column ?= lr_columns->get_column( 'EXCEPTION' ).
            lr_column->set_short_text( 'MY EXCEPT' ).
            lr_column->set_medium_text( 'MY EXCEPTION' ).
            lr_column->set_long_text( 'MY EXCEPTION COLUMN' ).
          catch cx_salv_not_found.                            "#EC NO_HANDLER
        endtry.
      
      *... §4.9 set icon tooltips
        data: lr_functional_settings type ref to cl_salv_functional_settings.
      
        lr_functional_settings = gr_table->get_functional_settings( ).
      
        perform set_tooltips using lr_functional_settings.
      
      *... §4.2 set icon column
        try.
            lr_column ?= lr_columns->get_column( 'ICON' ).
            lr_column->set_icon( if_salv_c_bool_sap=>true ).
            lr_column->set_long_text( 'ICON' ).
          catch cx_salv_not_found.                            "#EC NO_HANDLER
        endtry.
      
      *... §4.3 set symbol column
      ...
      

      Regards

      Uwe

  • Posted on Sep 10, 2010 at 02:14 PM

    Try avoiding this line.

    lt_columns->set_optimize( 'X' ).

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 10, 2010 at 03:02 PM

    Hi

    maintain null value to both medium and short text

    than you can see long text for all the fields

    see the below code

    l_column->set_long_text( 'this is long text' ).

    l_column->set_medium_text( ' ' ).

    l_column->set_short_text( ' ' ).

    Let me know how it goes

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 13, 2010 at 07:26 AM

    Thanks for all your comments. I have maintained space for long and short. And finally I got the column property changed.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.