Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[Fiori Elements] Custom Column in a Table is not visible

I had a generated Fiori Elements App (done by using @sap/generator-fiori), containing a List, where I needed to add a custom column containing a Button. I found this well explained in the official documentation:

https://sapui5.hana.ondemand.com/#/topic/d525522c1bf54672ae4e02d66b38e60c

I followed the instructions exactly, but it didn’t work. When comparing my manifest.json again with the example, I noticed one minor difference. In my generated App, there was an extra items/ in front of the @com.sap.vocabularies.UI.v1.LineItem.

My generated App
The manifest.json sample

After removing items/ the custom column was suddenly visible. When I noticed the difference, I thought that would never be the reason. Luckily, I tested it after all. That really is a big problem with Fiori Elements. These are problems that can no longer be solved by debugging or similar.

Here some more helpful links, when challenging with a custom column:

https://github.com/SAP-samples/fiori-elements-feature-showcase/blob/main/README.md#add-custom-column-extensibility

https://ui5.sap.com/test-resources/sap/fe/core/fpmExplorer/index.html#/customElements/customColumnContent

[ABAP] SALV – Access column name

  TRY.
      cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
                              CHANGING  t_table      = lt_output ).
    CATCH cx_salv_msg INTO DATA(lx_salv).
      WRITE: / lx_salv->get_text( ).
  ENDTRY.

  DATA(columns) = lo_alv->get_columns( ).
  DATA(lt_cols) = columns->get( ).

  LOOP AT lt_cols INTO DATA(ls_cols).
    DATA(lo_column) = ls_cols-r_column.
    CASE ls_cols-columnname.
      WHEN 'MANDT'
        lo_column->set_visible( abap_false ).
    ENDCASE.
  ENDLOOP.

[ABAP] ALV column header

DATA: o_salv TYPE REF TO cl_salv_table.

cl_salv_table=>factory( IMPORTING r_salv_table = o_salv
                        CHANGING  t_table      = l_lines ).

LOOP AT o_salv->get_columns( )->get( ) REFERENCE INTO DATA(l_column).
  DATA(lo_column) = CAST cl_salv_column( l_column->r_column ).
  lo_column->set_fixed_header_text( 'L' ).
ENDLOOP.

o_salv->get_columns( )->get_column( 'TEST1' )->set_long_text( 'Test1 Header' ).
o_salv->get_columns( )->get_column( 'TEST2' )->set_long_text( 'Test2 Header' ).