Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CL_SALV column position ?

former_member194669
Active Contributor
0 Kudos
6,906

Hi,

I am using a Object Model )SALV) inside a docking container . My problem is how align the columns in the tree

I have internal table i_ynatic that contains the following fields in this order

1. mandt

2. dcode

3. tcode

4. ctcno

5. tversn.

My requirement is in the tree i am removing the MANDT, DCODE, TCODE , and i need

fields to be displayed in the following order ie TVERSN then CTCNO

I checked the class "cl_salv_column_tree" for column position,(just like COL_POS) in the field catalog. but i could not ,

Anybody have info on how to position the field columns in the tree?


  create object g_docking_container_2
    exporting
      repid     = g_repid
      dynnr     = '300'
      extension = 160
      side      = cl_gui_docking_container=>dock_at_top.

  call method cl_salv_tree=>factory
    exporting
      r_container = g_docking_container_1
    importing
      r_salv_tree = grt_tree
    changing
      t_table     = i_ynatic.

  grt_functions = grt_tree->get_functions( ).
  grt_functions->set_all( abap_true ).
  grt_display = grt_tree->get_tree_settings( ).

  grt_nodes = grt_tree->get_nodes( ).

  grt_columns = grt_tree->get_columns( ).
  grt_column ?= grt_columns->get_column( 'MANDT' ).
  grt_column->set_visible( abap_false ).
  grt_column ?= grt_columns->get_column( 'DCODE' ).
  grt_column->set_visible( abap_false ).
  grt_column ?= grt_columns->get_column( 'TCODE' ).
  grt_column->set_visible( abap_false ).

  perform f_build_tree_header.
  perform f_build_tree_info.
  perform f_build_tree_events.

  grt_tree->display( ).

1 ACCEPTED SOLUTION

Former Member
0 Kudos
867

Hi,

Check REPORT 'SALV_DEMO_TREE_FUNCTIONS' , it will solve your problem.

Reward points if useful....

-Umesh

2 REPLIES 2

Former Member
0 Kudos
868

Hi,

Check REPORT 'SALV_DEMO_TREE_FUNCTIONS' , it will solve your problem.

Reward points if useful....

-Umesh

former_member194669
Active Contributor
867

Hi,

Problem solved

I am looking at wrong class. Here is the correction code


  data: grt_columns type ref to cl_salv_columns,
        grt_column  type ref to cl_salv_column.
  grt_columns = gr_tree->get_columns( ).
  grt_columns->set_optimize( abap_true ).
  grt_columns->set_column_position( columnname = 'TVERSN'
                                   position   = 1 ).
  grt_columns->set_column_position( columnname = 'CTCNO'
                                   position   = 2 ).