简体   繁体   中英

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

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.

空间被修剪

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

是的,有:

lo_salv_table->get_columns( )->get_column( 'NAME' )->set_leading_spaces( abap_true ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM