Skip to Content
avatar image
Former Member

CL_SALV_TABLE - column headers in saved variants

Dear all,

the situation is the following:

The users have the option to save variants for alv outputs. If they save the variant and re-submit the report defining the output variant, the column texts are ALL used from the DDIC reference although I define the text using the text methods.

...
    lr_layout->set_initial_layout( ip_vari ).
...
    lr_column ?= lr_columns->get_column( 'KTEXT' ).

    CALL METHOD lr_column->set_short_text
      EXPORTING
        value = ''.

    CALL METHOD lr_column->set_medium_text
      EXPORTING
        value = 'KoStlBez'.

    CALL METHOD lr_column->set_long_text
      EXPORTING
        value = 'KoStlBez'.
...

Can anybody tell me how I can tell the ALV not using the DDIC reference? (The DDIC reference is also not used, if I call the ALV w/o a variant)

Thx in advance for your help.

Kind regards.

André

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 17, 2016 at 06:41 AM

    The whole field catalog is stored with the variants, so I fear you have to detect/handle event for load of a variant an apply your modification again and not only once at first display.

    Hint: Look at sample program SALV_TEST_TABLE_EVENTS you look for an after function code event related to load variant (some gr_events->on_after_salv_function)

    Regards,
    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 18, 2016 at 10:32 AM

    Hello Andre,

    The Solution;

    and regards.

    METHOD create_variant. "Ex.
        DATA: lo_layout  TYPE REF TO cl_salv_layout,
              lf_variant TYPE slis_vari,
              ls_key     TYPE salv_s_layout_key.
        DATA: ls_layout TYPE salv_s_layout_info.
        lo_layout = mo_alv->get_layout( ).
        ls_key-report = sy-repid.
        lo_layout->set_key( ls_key ).
        lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
        lo_layout->set_default( 'X' ).
        lf_variant = 'DEFAULT'.
        "Pre-setting with bring. variant
        ls_layout = cl_salv_layout_service=>get_default_layout(
        s_key    = ls_key
        restrict = if_salv_c_layout=>restrict_none ).
        lo_layout->set_initial_layout( ls_layout-layout ).
    ENDMETHOD. 
    
    
    Add comment
    10|10000 characters needed characters exceeded