2008 Jul 15 10:52 AM
Hi All,
Anybody plz explain me how would i get the display as metioned when using RS_TREE_LIST_DISPLAY FM.
Header1 Month Year Date
+item1 $xxxx $xxx $xxxx +item2 $xxxx $xxx $xxxx Header2 |
+item1
+item2
where xxxx are of currency fields ($records) and should get sum up for totals and grand totals.
Thanks.
Hi All,
Anybody plz explain me how would i get the display as metioned when using RS_TREE_LIST_DISPLAY FM.
Header1 Month Year Date
+item1 $xxxx $xxx $xxxx +item2 $xxxx $xxx $xxxx Header2 |
+item1
+item2
where xxxx are of currency fields ($records) and should get sum up for totals and grand totals.
Thanks.
2008 Jul 15 10:57 AM
HI
refer to this link
i hope it give u some lead in solving ur problem
http://www.saptechnical.com/Tutorials/ALV/ALVTreeDemo/demo.htm
Cheers
Snehi
Edited by: snehi chouhan on Jul 15, 2008 11:58 AM
2008 Jul 15 10:58 AM
Hi,
Goto se80 and check the SLIS package, you could get more standard report programs on ALV TREE, check them based on your requirement.
2008 Jul 15 11:01 AM
hi check this program..
TABLES: KNVH.
TYPES: BEGIN OF WORKTYPE,
LEVEL(2),
HKUNNR LIKE KNVH-KUNNR,
KUNNR LIKE KNVH-HKUNNR,
END OF WORKTYPE.
DATA: IT_KNVH TYPE TABLE OF WORKTYPE,
WA_KNVH LIKE LINE OF IT_KNVH,
IT_TEMP TYPE TABLE OF WORKTYPE,
WA_TEMP LIKE LINE OF IT_TEMP,
IT_WORK TYPE TABLE OF WORKTYPE,
WA_WORK LIKE LINE OF IT_WORK.
DATA : BEGIN OF IT_NODES OCCURS 0.
INCLUDE STRUCTURE SNODETEXT.
DATA : END OF IT_NODES.
CONSTANTS: NUMBER_OF_LEVELS TYPE I VALUE 6.
PARAMETER: P_HKUNNR LIKE KNVH-HKUNNR.
START-OF-SELECTION.
Parent = 1. hierarchy node
WA_TEMP-KUNNR = P_HKUNNR.
APPEND WA_TEMP TO IT_TEMP.
WA_WORK-KUNNR = WA_TEMP-KUNNR.
WA_WORK-LEVEL = 1.
APPEND WA_WORK TO IT_WORK.
Reading customer hierarchy (max. 6 level)
DO NUMBER_OF_LEVELS TIMES.
CHECK NOT IT_TEMP IS INITIAL.
SELECT KUNNR HKUNNR
FROM KNVH
INTO CORRESPONDING FIELDS OF TABLE IT_KNVH
FOR ALL ENTRIES IN IT_TEMP
WHERE HKUNNR = IT_TEMP-KUNNR.
LOOP AT IT_KNVH INTO WA_KNVH.
WA_KNVH-LEVEL = SY-INDEX + 1.
APPEND WA_KNVH TO IT_WORK.
ENDLOOP.
IT_TEMP[] = IT_KNVH[].
ENDDO.
Hierarchy nodes -> tree control
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 1.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 2 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 3 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 4 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 5 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 6 AND
HKUNNR = WA_WORK-KUNNR.
PERFORM MAKE_NODE.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Making the tree control
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
NODETAB = IT_NODES
EXCEPTIONS
TREE_FAILURE = 1.
Display the tree control
DATA : F15 TYPE C.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
CALLBACK_PROGRAM = SY-REPID
IMPORTING
F15 = F15 .
FORM MAKE_NODE.
IT_NODES-NAME = WA_WORK-KUNNR.
IT_NODES-COLOR = 1.
IT_NODES-INTENSIV = 1.
IT_NODES-TEXT = WA_WORK-KUNNR.
IT_NODES-TLENGTH = 16.
IT_NODES-TLEVEL = WA_WORK-LEVEL.
IT_NODES-TCOLOR = 1.
IT_NODES-TINTENSIV = 1.
APPEND IT_NODES.
ENDFORM.
2008 Jul 15 11:15 AM
Hi,
Please check the basic steps for creating the tree program.
Here i am giving the details using ALV Tree Program using Objects.
Build the Header table, Item tables , totals or grand totals into different tables. And maintain key relations in each table.
As given below in ADD_NODE method, get the node key from e_new_node_key parameter. And pass the parent node key to i_relat_node_key parameter to build the tree.
If it helps, please reward me with points.
Thanks.
Class declaration
DATA: cl_alv_tree TYPE REF TO cl_gui_alv_tree,
cl_custom_container TYPE REF TO cl_gui_custom_container.
&----
*& Form init_tree
&----
Initalize ALV Tree
----
FORM init_tree .
DATA: l_tree_container_name(30) TYPE c,
l_hierarchy_header TYPE treev_hhdr.
l_tree_container_name = 'CL_ALV'.
CREATE OBJECT cl_custom_container
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT cl_alv_tree
EXPORTING
parent = cl_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
PERFORM field_catalog.
CALL METHOD cl_alv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = l_hierarchy_header
CHANGING
it_outtab = it_display
it_fieldcatalog = it_fcat.
PERFORM create_hierarchy.
CALL METHOD cl_alv_tree->frontend_update.
ENDFORM. " init_tree
&----
*& Form build_hierarchy_header
&----
Build the header for the hierarchy
----
<--P_HIERARCHY_HEADER Hierarchy Header
----
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Class/Characteristic'.
p_hierarchy_header-tooltip = 'Characteristics for Class'.
p_hierarchy_header-width = 50.
p_hierarchy_header-width_pix = ' '.
ENDFORM. " build_hierarchy_header
&----
*& Form create_hierarchy
&----
Arrange data in the Hierarchy for Tree
----
FORM create_hierarchy .
DATA: l_node_text TYPE lvc_value,
l_relat_key TYPE lvc_nkey,
l_plint TYPE lvc_nkey,
l_layout_node TYPE lvc_s_layn,
l_layout_node1 TYPE lvc_s_layn,
l_clint TYPE lvc_nkey.
l_relat_key = ' '.
l_node_text = 'Classes'.
l_layout_node1-n_image = '@8H@'.
CALL METHOD cl_alv_tree->add_node
EXPORTING
i_relat_node_key = l_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_node_layout = l_layout_node1
IMPORTING
e_new_node_key = l_clint.
LOOP AT it_output INTO wa_output.
CLEAR: wa_output1,wa_output2.
MOVE-CORRESPONDING wa_output TO wa_output1.
AT NEW plint.
IF wa_output-clint = wa_output-plint.
l_relat_key = l_clint.
l_node_text = wa_output1-cname.
l_layout_node1-n_image = '@PL@'.
CALL METHOD cl_alv_tree->add_node
EXPORTING
i_relat_node_key = l_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = wa_output1
is_node_layout = l_layout_node1
IMPORTING
e_new_node_key = l_plint.
wa_output1-index = l_plint.
MODIFY it_output FROM wa_output1.
ENDIF.
ENDAT.
IF wa_output-flag = 'X' AND wa_output-prop = ' '.
CLEAR wa_output2.
READ TABLE it_output WITH KEY clint = wa_output-plint
INTO wa_output2.
Binary Search cannot be used because the records should be created
based on the tree hierarchy
l_relat_key = wa_output2-index.
l_node_text = wa_output-cname.
l_layout_node1-n_image = '@PL@'.
CALL METHOD cl_alv_tree->add_node
EXPORTING
i_relat_node_key = l_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = wa_output
is_node_layout = l_layout_node1
IMPORTING
e_new_node_key = l_plint.
wa_output1-index = l_plint.
MODIFY it_output FROM wa_output1.
CONTINUE.
ENDIF.
IF wa_output-prop = 'C'.
CLEAR wa_output2.
READ TABLE it_output WITH KEY clint = wa_output-plint
INTO wa_output2.
Binary Search cannot be used because the records should be created
based on the tree hierarchy
l_relat_key = wa_output2-index.
l_node_text = wa_output1-cname.
IF wa_output-hchar = 'X'.
l_layout_node-n_image = '@6X@'.
ELSE.
l_layout_node-n_image = '@6Y@'.
ENDIF.
CALL METHOD cl_alv_tree->add_node
EXPORTING
i_relat_node_key = l_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = wa_output
is_node_layout = l_layout_node.
ENDIF.
ENDLOOP.
ENDFORM. " create_hierarchy
2008 Jul 15 11:33 AM
Hi Deepthi ,
i think this code will help you ....check this..
and feel free to ask ..any query ....
Tree Alv
&----
*& Report ZPRITREE2
*&
&----
*&
*&
&----
REPORT ZPRITREE2.
parameters: p_werks like marc-werks.
type pool declarations for tree
*type-pools : fibs,stree.
*Data declaration for additional node information
data : t_node type snodetext.
*Internal table and wa decl for nodes
data : it_node like table of t_node initial size 0,
wa_node like t_node.
*Internal table and wa decl for Education table PA0022
data : itab_mara type standard table of marc initial size 0,
wa_mara like line of itab_mara .
*Internal table and wa decl for text table t517x
data : it_maktx type standard table of makt initial size 0,
wa_maktx like line of it_maktx.
*Internal table and wa decl for text table t517T
data : it_lgort type standard table of mard initial size 0,
wa_lgort like line of it_lgort.
*Internal table and wa decl for text table t519T
data : it_519t type standard table of t519t initial size 0,
wa_519t type t519t.
*initialization event
initialization.
*Start of selection event
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
&----
text
----
--> p1 text
<-- p2 text
----
form fetch_data .
*select data from PA0022
select * from marc into corresponding fields of table itab_mara up to 50
rows where werks = P_werks.
*select data from T517x
select * from makt into corresponding fields of table it_maktx .
where langu = 'E'.
*select data from T517T
select * from mard into corresponding fields of table it_lgort .
endform. " fetch_data
&----
*& Form build_hierarchy
&----
text
----
--> p1 text
<-- p2 text
----
form build_hierarchy .
*Building the nodes and hierarchy for tree
clear : it_node[], wa_node.
wa_node-type = 'T'.
wa_node-name = 'plant'.
wa_node-tlevel = '01'.
wa_node-nlength = '15'.
wa_node-color = '4'.
wa_node-text = p_werks.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
append wa_node to it_node.
clear wa_node.
*Filling the values of internal table into tree
loop at itab_mara into wa_mara.
wa_node-type = 'P'.
wa_node-name = 'material'.
wa_node-tlevel = '02'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_mara-matnr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
append wa_node to it_node.
clear wa_node.
*
*Filling the text of T517t
break devuser.
read table it_maktx into wa_maktx with key matnr = wa_mara-matnr.
wa_node-type = 'P'.
wa_node-name = 'description'.
wa_node-tlevel = '03'.
wa_node-nlength = '15'.
wa_node-color = '1'.
wa_node-text = wa_maktx-maktx.
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_lgort into wa_lgort with key matnr = wa_mara-matnr werks
= p_werks .
wa_node-type = 'P'.
wa_node-name = 'storage location'.
wa_node-tlevel = '03'.
wa_node-nlength = '25'.
wa_node-color = '2'.
wa_node-text = wa_lgort-lgort.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
append wa_node to it_node.
clear wa_node.
endloop.
endform. " build_hierarchy
&----
*& Form build_tree
&----
text
----
--> p1 text
<-- p2 text
----
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. " build_tree
thanks and regards
2008 Jul 15 11:43 AM
Hi
Pls find the below code to understand the concept of Alv Tree
&----
*& Report ZJITU_TREE_DEMO5
*&
&----
*&
*&
&----
REPORT ZJITU_TREE_DEMO5.
type-pools : stree.
DATA : t_node TYPE snodetext.
DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
wa_node LIKE t_node.
data : itab type table of mara.
data : wa_itab like line of itab.
data : itab2 like table of makt.
data : wa_itab2 like line of itab2.
data : itab3 like table of marc.
data : wa_itab3 like line of itab3.
INITIALIZATION.
SELECT-OPTIONS s_matnr FOR wa_itab-matnr.
START-OF-SELECTION.
PERFORM fetch_data.
PERFORM build_hierarchy.
PERFORM build_tree.
&----
*& Form fetch_data
&----
text
----
--> p1 text
<-- p2 text
----
form fetch_data .
select * into corresponding fields of table itab from mara where matnr
in s_matnr .
select * into corresponding fields of table itab2 from makt.
select * into corresponding fields of table itab3 from marc.
endform. " fetch_data
&----
*& Form build_hierarchy
&----
text
----
--> p1 text
<-- p2 text
----
form build_hierarchy .
CLEAR : it_node[], wa_node.
wa_node-type = 'T'.
wa_node-name = 'Material'.
wa_node-tlevel = '01'.
wa_node-nlength = '15'.
wa_node-color = '4'.
wa_node-text = 'Material Info'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the values of internal table into tree
LOOP AT itab INTO wa_itab.
wa_node-type = 'P'.
wa_node-name = 'Material Number'.
wa_node-tlevel = '02'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_itab-matnr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
wa_node-type = 'P'.
wa_node-name = 'Unit'.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_itab-meins.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
wa_node-type = 'P'.
wa_node-name = 'Type'.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_itab-mtart.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
read table itab2 into wa_itab2 with key matnr = wa_itab-matnr.
wa_node-type = 'P'.
wa_node-name = 'Description'.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_itab2-maktx.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
read table itab3 into wa_itab3 with key matnr = wa_itab-matnr.
wa_node-type = 'P'.
wa_node-name = 'Location'.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_itab3-werks.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
wa_node-type = 'P'.
wa_node-name = 'Status'.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_itab3-pstat.
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.
**
***Filling the text of T517x
**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.
clear wa_itab.
clear wa_itab2.
clear wa_itab3.
ENDLOOP.
endform. " build_hierarchy
&----
*& Form build_tree
&----
text
----
--> p1 text
<-- p2 text
----
form build_tree .
CALL FUNCTION 'RS_TREE_CONSTRUCT'
EXPORTING
INSERT_ID = '000000'
RELATIONSHIP = ' '
LOG =
TABLES
nodetab = it_node
EXCEPTIONS
TREE_FAILURE = 1
ID_NOT_FOUND = 2
WRONG_RELATIONSHIP = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
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. " build_tree
Regards
Jatender
2008 Jul 15 11:51 AM
Please follow the Forum Guidelines and Close all the thread.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |