I want to change the layout of a cl_gui_alv_tree
programmatically. My current approach is not working. This is my code so far, executed in screen's PBO:
CALL METHOD gs_0700-s_tree-r_tree->delete_all_nodes
EXCEPTIONS
failed = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM load_new_tree_nodes.
ls_vari-report = gs_0700-repid.
ls_vari-handle = 'TREE'.
ls_vari-variant = '/new_variant'
(...)
CALL METHOD gs_0700-s_tree-r_tree->set_variant_key
EXPORTING
is_variant = ls_vari.
CALL METHOD gs_0700-s_tree-r_tree->column_optimize.
CALL METHOD gs_0700-s_tree-r_tree->update_calculations.
CALL METHOD gs_0700-s_tree-r_tree->frontend_update.
The tree is redrawn and new nodes are loaded. Even the columns get optimized. Everything changes but not the layout variant. It looks always like /default
layout variant I set with the set_table_for_first_display
method during init of the tree. I created the variant /new_variant
and I can load it via the toolbar.
Is there some other way to change the layout variant of a tree programmatically?
Do you call
SET_TABLE_FOR_FIRST_DISPLAY
method with parameterI_DEFAULT = space
?Default setting will be
'X'
which results in always displaying the default variant.