Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

SALV Default Column description as Column Name

$
0
0

Code snippet to set the Column Description as the Column Name when the Column description is empty in the ALV generated by SALV model.

Sometimes you want to do some quick programming. When you use the generic types to define the Itab, SALV doesn’t show any description.

 

Column Description as Column Name


* DATA: lo_cols     TYPE REF TO  cl_salv_columns,

               lo_column   TYPE REF TO  cl_salv_column_list,

               lt_cols     TYPE         salv_t_column_ref,

               ls_cols     LIKE LINE OF lt_cols.  

     DATA: lv_short    TYPE scrtext_s.

     DATA: lv_med      TYPE scrtext_m.

     DATA: lv_long     TYPE scrtext_l. 

* Columns lo_cols = o_salv->get_columns( ). lo_cols->set_optimize( 'X' ).  

* For each column

* If Short description is not there, set Short

* If Medium description is not there, set Medium

* If Long description is not there, set Long

   lt_cols    = lo_cols->get( ).

LOOP AT lt_cols INTO ls_cols.

lo_column ?= ls_cols-r_column.    "Narrow casting

IF lo_column->get_short_text( ) IS INITIAL.

  lv_short = ls_cols-columnname.

  lo_column->set_short_text( lv_short ).

ENDIF.

IF lo_column->get_medium_text( ) IS INITIAL.

  lv_med = ls_cols-columnname.

  lo_column->set_medium_text( lv_med ).

ENDIF.

IF lo_column->get_long_text( ) IS INITIAL.

  lv_long = ls_cols-columnname.

  lo_column->set_long_text( lv_long ).

ENDIF.

ENDLOOP. 

 

 

Regards.


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>