06-16-2011 7:02 AM
Hello Guru's,
i want to create a only tree node and display the internal table data as the leaves of the node.
my internal table consist of 5 coulmns.
i want id i expand the node all the data os internal table should be displayed as the leaf nodes .
also can we do this in alv.
thanks,
Kanchan.
06-16-2011 7:33 AM
06-16-2011 7:35 AM
hI,
yOU CAN TRY BELOW CODE FOR YOUR REFERENCE.
REPORT z_simpletree.
TYPE-POOLS : fibs,stree.
DATA : t_node TYPE snodetext.
DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
wa_node LIKE t_node.
DATA : it_0022 TYPE STANDARD TABLE OF pa0022 INITIAL SIZE 0,
wa_0022 TYPE pa0022.
DATA : it_517x TYPE STANDARD TABLE OF t517x INITIAL SIZE 0,
wa_517x TYPE t517x.
DATA : it_517t TYPE STANDARD TABLE OF t517t INITIAL SIZE 0,
wa_517t TYPE t517t.
DATA : it_519t TYPE STANDARD TABLE OF t519t INITIAL SIZE 0,
wa_519t TYPE t519t.
START-OF-SELECTION.
*
*Select the data for tree
PERFORM fetch_data.
* *Build the hierarchy for tree
PERFORM build_hierarchy.
* *Build Tree for display
PERFORM build_tree.
FORM fetch_data .
*select data from PA0022
SELECT * FROM pa0022 INTO CORRESPONDING FIELDS OF TABLE it_0022
UP TO 50 ROWS.
* *select data from T517x
SELECT * FROM t517x INTO CORRESPONDING FIELDS OF TABLE it_517x
WHERE langu = 'E'.
* *select data from T517T
SELECT * FROM t517t INTO CORRESPONDING FIELDS OF TABLE it_517t
WHERE sprsl = 'E'."*select data from T519t
SELECT * FROM t519t INTO CORRESPONDING FIELDS OF TABLE it_519t
WHERE sprsl = 'E'.ENDFORM. " fetch_data
FORM build_hierarchy ."*Building the nodes and hierarchy for tree
CLEAR : it_node[], wa_node. wa_node-type = 'T'.
wa_node-name = 'Education'.
wa_node-tlevel = '01'.
wa_node-nlength = '15'.
wa_node-color = '4'.
wa_node-text = 'Infotype 0022'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
LOOP AT it_0022 INTO wa_0022.
wa_node-type = 'P'.
wa_node-name = 'PERNR'.
wa_node-tlevel = '02'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_0022-pernr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node."*Filling the text of T517t
READ TABLE it_517t INTO wa_517t
WITH KEY slart = wa_0022-slart.
wa_node-type = 'P'.
wa_node-name = wa_0022-slart.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_517t-stext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
* *Filling the text of T519t
READ TABLE it_519t INTO wa_519t
WITH KEY slabs = wa_0022-slabs.
wa_node-type = 'P'.
wa_node-name = wa_0022-slabs.
wa_node-tlevel = '04'.
wa_node-nlength = '8'.
wa_node-color = '2'.
wa_node-text = wa_519t-stext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
READ TABLE it_517x INTO wa_517x
WITH KEY faart = wa_0022-sltp1.
wa_node-type = 'P'.
wa_node-name = wa_0022-sltp1.
wa_node-tlevel = '05'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_517x-ftext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node. wa_node-type = 'P'.
* wa_node-name = wa_0022-zzper.
wa_node-tlevel = '06'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = '% Completed'.
wa_node-tlength ='15'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node. ENDLOOP.
ENDFORM.
FORM build_tree .
* *Fm for constructing the tree
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_node.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* *FM for displaying the tree
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = sy-repid
check_duplicate_name = '1'
color_of_node = '4'
color_of_mark = '3'
color_of_link = '1'
color_of_match = '5'
node_length = 30
text_length = 75
use_control = 'L'.
ENDFORM.
Regards,
Umang Mehta
06-16-2011 8:00 AM
hello ,
Uman
thats not the one i want. i tied and execute ur code.
but thank for the try.
may be to be clear
>tree_node
.12345 5666 hgfdhghf 54365435 4564356
. ghfgf jfhgfhg jjhgjfhg jhgjfhg jhjhjhjhh
. hgfhg jhgjfhg ghfjhg jfhgjfhg jhgjfhgj hgjfh
this is what i want to show in ALV.
also where tree_node is the main node and when i expand that node i get the internal table data as the leaf nodes of this node.
also the internal table dats has some 3 to 4 coulmns which i need to display the way i have mentioned above.
thanks,
Also sandeep i think yes ALV is th best way to do it.
but can you help me with some code.
Thanks.
Kanchan.
06-16-2011 8:03 AM
There are so many demo programs provided by SAP .
Check with program names BCALV_EDIT*
06-16-2011 8:12 AM
Hi Sandeep,
i tried almost most of the BCALV_* programs.
but things are realy confusing and i dint got the exact thing which i wanted also ALV tree
is a vast topic i also refered BC412 but i guess thats not the one .
also using CL_GUI_COULUMN_Tree
i am alble to show it like a table in alv custom container.
but i want a node above it and when i expand i should be able to see the data which i am able to see now.
if you have access to ECA system .
please refer to my code in local objects - c5129636
Z_REDUCE_MAINTENANCE_EFFORT - program
transaction - ZRME.
and enter the test plan name as - 'TP_ID_BANK_DEPOSITS_MGMT_7.0_CBA_ADDON2_SP1'
but there is node main node.
only internal table data is displayed.
can you please help me out.
Thanks