Application Development and Automation 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: 
Read only

Three Level ALV Tree.

Former Member
0 Likes
1,212

Is it possible to create an ALV Structure upto three Levels eg.

Company

+ --- Department

+ -


Employee Emp No..

If Yes, Then How ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
733

BALVHD01

check BCALVTREE programs in SE38 for your refrence

same thread

4 REPLIES 4
Read only

Former Member
0 Likes
734

BALVHD01

check BCALVTREE programs in SE38 for your refrence

same thread

Read only

Former Member
0 Likes
733

Hi,

Copy paste the following code.

Create a screen 100 and a control area 'CCAREA_TREE' and execute the following code


REPORT  ZSIMPLE_TREE                  .


data : gref_tree type ref to CL_gui_simple_tree,
       gref_cont type ref to cl_gui_custom_container.


       call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_0100 output.
  SET PF-STATUS 'STAT_100'.
*  SET TITLEBAR 'xxx'.

data:  NODE_TABLE TYPE table of MTREESNODE.

  DATA: NODE LIKE MTREESNODE.

if gref_tree is initial.
   create object gref_cont
     exporting
       container_name              = 'CCAREA_TREE'
       .


create object gref_tree
  exporting
    parent                      = gref_cont
    node_selection_mode       = CL_GUI_SIMPLE_TREE=>NODE_SEL_MODE_SINGLE
    .


  NODE-NODE_KEY = 'Root'.   
  CLEAR NODE-RELATKEY.     
  CLEAR NODE-RELATSHIP.    
  NODE-HIDDEN = ' '.       
  NODE-DISABLED = ' '.      
  NODE-ISFOLDER = 'X'.     
  CLEAR NODE-N_IMAGE.       
  CLEAR NODE-EXP_IMAGE.    
  CLEAR NODE-EXPANDER.     
  NODE-TEXT = 'Company'.
  APPEND NODE TO NODE_TABLE.


  NODE-NODE_KEY = 'Child1'. 
  NODE-RELATKEY = 'Root'.
  NODE-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
  NODE-HIDDEN = ' '.
  NODE-DISABLED = ' '.
  NODE-ISFOLDER = 'X'.
  CLEAR NODE-N_IMAGE.
  CLEAR NODE-EXP_IMAGE.
  NODE-EXPANDER = 'X'.
  NODE-TEXT = 'Department'.
  APPEND NODE TO NODE_TABLE.

  NODE-NODE_KEY = 'Child2'. 
  NODE-RELATKEY = 'Child1'.
  NODE-RELATSHIP = CL_GUI_SIMPLE_TREE=>RELAT_LAST_CHILD.
  NODE-HIDDEN = ' '.
  NODE-DISABLED = ' '.
  NODE-ISFOLDER = 'X'.
  CLEAR NODE-N_IMAGE.
  CLEAR NODE-EXP_IMAGE.
  NODE-EXPANDER = 'X'.
  NODE-TEXT = 'Employee No.'.
  APPEND NODE TO NODE_TABLE.


  CALL METHOD Gref_TREE->ADD_NODES
    EXPORTING
      TABLE_STRUCTURE_NAME = 'MTREESNODE'
      NODE_TABLE           = NODE_TABLE
    EXCEPTIONS
      FAILED                         = 1
      ERROR_IN_NODE_TABLE            = 2
      DP_ERROR                       = 3
      TABLE_STRUCTURE_NAME_NOT_FOUND = 4
      OTHERS                         = 5.
endif.

endmodule.                 " STATUS_0100  OUTPUT
*&--------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
module USER_COMMAND_0100 input.

case sy-ucomm.
   when 'BACK'.
      leave to screen 0.
endcase.
endmodule.                 " USER_COMMAND_0100  INPUT

Hope this helps.

Regards,

Kinshuk

PS Reward points if you find the post helpful

Read only

Former Member
0 Likes
733

Hi ashwa,

1. Its quite simple.

2. Basically there are TWO FMs,

which do the job.

3. just copy paste in new program

and u will know the whole logic.

4.

REPORT abc.

DATA : tr LIKE TABLE OF snodetext WITH HEADER LINE.

*----


data

tr-id = '1'.

tr-tlevel = 1.

tr-name = 'amit'.

APPEND tr.

tr-id = '2'.

tr-tlevel = 2.

tr-name = 'mittal'.

APPEND tr.

tr-id = '3'.

tr-tlevel = 2.

tr-name = 'Hello'.

APPEND tr.

tr-id = '4'.

tr-tlevel = 2.

tr-name = 'Brother'.

APPEND tr.

tr-id = '5'.

tr-tlevel = 4.

tr-name = 'Brother'.

APPEND tr.

*----


display

CALL FUNCTION 'RS_TREE_CONSTRUCT'

TABLES

nodetab = tr

EXCEPTIONS

tree_failure = 1

OTHERS = 4.

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'

.

regards,

amit m.

Read only

Former Member
0 Likes
733

How to create the control area 'CCAREA_TREE' ?