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

[SAPUI5] Add custom header parameter to all oData queries

Simply go to your Component.js file and add this line to the init function:

this.getModel().setHeaders({"myCustomParameter": "test"})

In a CAP Backend, you get this parameter from the express req object, which can be accessed via the req.http property:


And here is a nice code snippet, on how to read this header parameter in an ABAP system: https://answers.sap.com/answers/425621/view.html

[nodejs] iterate through fetch response headers


        const response = await fetch("https://example.com/api")

        for (const [key, value] of response.headers) {
            console.log(key, value)

An alternative would be forEach()

        response.headers.forEach((value, key) => {
            console.log(value, key)

Or using the entries() iterator (ES8)

          const headerIterator = response.headers.entries()

To add a new header just use set()

response.set(key, value)

[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' ).

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