cancel
Showing results for 
Search instead for 
Did you mean: 

Need inputs on how to change Field names while using class cl_salv_table

ABAPer_1631
Explorer
0 Kudos
137

Hello,

Need inputs on below case:

In a report program I am using the class CL_SALV_TABLE to display final result of the internal table using ALV.

The structure which is used for the final output table has multiple fields and some of them pointing to same data element. Here is the example.

Final table name - gt_<table_name>

gt_<table_name> is TYPE TABLE OF ZP_S_<structure_name>.

the global structure ZP_S_<structure_name> has below fields:

component namecomponent typeshort description
<field1><field_type1>ID
<field2><field_type2>NAME
<field3><field_type3>Description
<field4><field_type3>Description
<field5><field_type3>Description

As field3,4,5 using same data element it is displaying the same field label in the ALV.

But I would like display valid/relevant field names which I provide in the program as field label.

In precise, now, after I execute report program output is as below:

IDNameDescriptionDescriptionDescription

I would like to display as shown below:

IDNameAddress Key 1Address Key 2Description

Could you please tell how to achieve this if I use same data element for more than one field?

Thanks!

View Entire Topic
Ryan-Crosby
Active Contributor
0 Kudos

It would be something like the following but it only refers to one field name and you would need to tailor the approach to your needs (kept short for brevity)...

DATA: alv_ref  TYPE REF TO cl_salv_table,
      cols_ref TYPE REF TO cl_salv_columns,
      col_ref  TYPE REF TO cl_salv_column.

* Create ALV here ...
...

cols_ref = alv_ref->get_columns( ).
TRY.
  col_ref = cols_ref->get_column( 'FIELD3' ).
  col_ref->set_medium_text( 'Some Text' ).
  CATCH cx_salv_not_found.
ENDTRY.

 

Regards,

Ryan Crosby