Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Yesterday I was working with SALV for one of the reports that we had developed and we were stuck with a particular issue.

We wanted to display the long text for a particular field since the customers wanted to see the full explanation for the display field.

We searched the CL_SALV_COLUMN_TABLE and found that SET_LONG_TEXT will work well for our requirement.

We gave something like this.

  START-OF-SELECTION.

  SELECT * INTO TABLE ispfli FROM spfli.

  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = gr_table
        CHANGING
          t_table      = ispfli.
    CATCH cx_salv_msg .
  ENDTRY.

  gr_funct = gr_table->get_functions( ).
  gr_funct->set_all( abap_true ).
    gr_columns = gr_table->get_columns( ).
  gr_column ?= gr_columns->get_column( 'DISTANCE' ).

  gr_column->set_long_text( 'NEW LONG TEXT FOR DIST' ).

  gr_table->display( ).


This didn't give us the expected results.

It showed the Short text from the data element of the field.

Then we changed the code to below and started experimenting.

  gr_column ?= gr_columns->get_column( 'DISTANCE' ).
  gr_column->set_short_text( 'NEW SHORT ' ).
  gr_column->set_medium_text( 'NEW MEDIUM TEXT ' ).
  gr_column->set_long_text( 'NEW LONG TEXT FOR DIST' ).
  gr_table->display( ).

It took the new short text as we had given.

If I comment the set_short_text method call it again calls the short text of the data element.

Here if you use SET_OUTPUT_LENGTH and set the output length to 25, it shows the long text.

But now the columns were not optimized. We used SET_OPTIMIZE method to optimize the columns.

  gr_columns->set_optimize( 'X' ).

The issue came back, it had again set the short text that we had set to the field name.

So we started wondering how to give the long text?

If we use the method SET_SHORT_TEXT, it sets the field name with the text we had given.

If we comment it, it takes the short text from the data element.

Eventually, we got the solution.

You have to pass blank values in the method SET_SHORT_TEXT and SET_MEDIUM_TEXT to display the long text.

  gr_columns->set_optimize( 'X' ).
  gr_column ?= gr_columns->get_column( 'DISTANCE' ).
  gr_column->set_short_text( ' ' ).
  gr_column->set_medium_text( ' ' ).
  gr_column->set_long_text( 'NEW LONG TEXT FOR DIST' ).
  gr_table->display( ).

9 Comments