Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to prevent CL_SALV_TABLE from removing leading spaces?

Tags:

abap

alv

Is there a way to prevent an instance of CL_SALV_TABLE from removing leading spaces in the display?

I have the following piece of code in which I put a single space in front of Master text and two spaces in front of Slave text.

REPORT zzy.

CLASS lcl_main DEFINITION FINAL CREATE PRIVATE.
  PUBLIC SECTION.
    CLASS-METHODS:
      main.
ENDCLASS.

CLASS lcl_main IMPLEMENTATION.
  METHOD main.
    TYPES: BEGIN OF l_tys_test,
      name  TYPE string,
      value TYPE i,
    END OF l_tys_test,
    l_tyt_test TYPE STANDARD TABLE OF l_tys_test WITH EMPTY KEY.

    DATA(lt_test) = VALUE l_tyt_test(
      ( name = `Root` value = 0 )
      ( name = ` Master` value = 1 )
      ( name = `  Slave` value = 2 )
    ).

    cl_salv_table=>factory(
      IMPORTING
        r_salv_table = DATA(lo_salv_table)
      CHANGING
        t_table = lt_test
    ).
    lo_salv_table->display( ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  lcl_main=>main( ).

Unfortunately the leading spaces get trimmed in the view.

Spaces get trimmed

In this tutorial the guy seems to have made it somehow.

like image 365
Jagger Avatar asked May 19 '16 15:05

Jagger


1 Answers

Yes, there is:

lo_salv_table->get_columns( )->get_column( 'NAME' )->set_leading_spaces( abap_true ).
like image 121
vwegert Avatar answered Sep 17 '22 17:09

vwegert