Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9239

Re: Remove a column in SALV

$
0
0

Sorry I got distracted halfway through. I wanted to add if you don't want to manually create a local version of this table that has this column taken out you could do it dynmaically which would be more robust to future changes in the structure of  t_header. Adding the following code into your routine should do the trick


data: lr_table    TYPE REF TO  cl_abap_tabledescr,
       lr_old_str  TYPE REF TO  cl_abap_structdescr,
       lr_new_str  TYPE REF TO  cl_abap_structdescr,
       lt_comp TYPE cl_abap_structdescr=>component_table,
       lr_new_tab  TYPE REF TO  cl_abap_tabledescr,
       lr_local TYPE REF TO data.
FIELD-SYMBOLS: <lt_local> TYPE STANDARD TABLE,
                <ls_local> TYPE ANY.


lr_table ?= cl_abap_tabledescr=>DESCRIBE_BY_DATA( t_header ).
lr_old_str ?= lr_table->GET_TABLE_LINE_TYPE( ).
lt_comp = lr_old_str->GET_COMPONENTS( ).

*replace COL with name of column that has type talbe
delete lt_comp where name = 'COL'.
lr_new_str = cl_abap_structdescr=>create( lt_comp ).
lr_new_tab = cl_abap_tabledescr=>create(
                   p_line_type  = lr_new_str
                   p_table_kind = cl_abap_tabledescr=>tablekind_std
                   p_unique     = abap_false ).
CREATE DATA lr_local TYPE HANDLE lr_new_tab.
ASSIGN lr_local->* TO <lt_local>. "INTERNAL TABLE.



data: ls_header like LINE OF t_header.


loop at t_header into ls_header.
   APPEND INITIAL LINE TO <lt_local> ASSIGNING <ls_local>.
   MOVE-CORRESPONDING ls_header to <ls_local>.
ENDLOOP.


cl_salv_table=>factory(
EXPORTING
   r_container    = ref_docking_hdr
IMPORTING
   r_salv_table   ref_hdr
CHANGING
   t_table        = <lt_local> ).

ref_hdr->display( ).


Viewing all articles
Browse latest Browse all 9239

Trending Articles



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