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: 

Display a dynamically generated table as a tree

former_member423549
Discoverer
0 Kudos

Hi everyone,

the document http://scn.sap.com/docs/DOC-53788 describes how to display a dynamically generated table (using RTTS) as a list (class cl_salv_table). This works, but I would like to display a dynamic table as a tree (class cl_salv_tree). Unfortunately it doesn't work for me. I'm getting cx_salv_error. Does anybody know how to do this?


TRY.

        cl_salv_tree=>factory(

          IMPORTING

            r_salv_tree = lo_salv_tree

          CHANGING

            t_table     = <fs_table> ).

      CATCH cx_salv_data_error INTO lo_data_err.

      CATCH cx_salv_not_found INTO lo_not_found.

      CATCH cx_salv_error INTO lo_error.

ENDTRY.


Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

when creating a tree the parameter

t_table

has to be an empty table of the target structure.

You musn't have any lines in t_table.


After you used the factory method you have to use the "nodes" element and add nodes, here you can provide a data row, this data row must be of the same structure as the table you provided for the factory.


do you have an example of your structure? do you know on what logic your tree shall be built?

With those information I can provide you some better instructions.


so regarding to the instructions for a list you need to pass over this step:


Step 3 - Populate internal table.


instead you have to build the hierarchy from nodes and assign data rows to the nodes

2 REPLIES 2

Former Member
0 Kudos

when creating a tree the parameter

t_table

has to be an empty table of the target structure.

You musn't have any lines in t_table.


After you used the factory method you have to use the "nodes" element and add nodes, here you can provide a data row, this data row must be of the same structure as the table you provided for the factory.


do you have an example of your structure? do you know on what logic your tree shall be built?

With those information I can provide you some better instructions.


so regarding to the instructions for a list you need to pass over this step:


Step 3 - Populate internal table.


instead you have to build the hierarchy from nodes and assign data rows to the nodes

0 Kudos

Markus, thank you for your help.

You are absolutely right. I forgot that the input table of the factory method (cl_salv_tree) shouldn't contain data.

The question is closed.