‎2007 Jul 10 1:55 PM
hi,
i have one problem.
i have displayed an alv grid.now i want when user select any
row the corresponding value
of that particular row should display in tree like structure
under different heading i.e. under one heading there should be
some field ,under another heading some other field and so on.
also with expand node and compress node .
can u plz provide any sample program.i want it with function module.
like rs_tree_construct' and others.
‎2007 Jul 12 10:11 AM
REPORT ZTEST13 MESSAGE-ID znew .
TREE HIRRARCHY REPORT **********************
TABLES : vbak.
DATA: BEGIN OF mylist OCCURS 50. " Internal table hierarchy
INCLUDE STRUCTURE snodetext.
DATA: END OF mylist.
DATA: f15 TYPE c.
DATA : BEGIN OF gt_sales OCCURS 0,
vbeln LIKE vbak-vbeln,
kunnr LIKE vbak-kunnr,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
ERNAM LIKE VBAK-ERNAM,
END OF gt_sales.
*SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD S_VBELN.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN OBLIGATORY.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
V_TEXT1 = 'SALES ORDER NO'.
START-OF-SELECTION.
SET PF-STATUS 'ZTREE1'. " create in t-code se41
SET TITLEBAR 'T1'.
PERFORM fill_itab.
PERFORM main.
FORM fill_itab .
SELECT vkvbeln vkkunnr VKERNAM vpmatnr vp~arktx INTO CORRESPONDING
FIELDS OF
TABLE gt_sales
FROM ( vbak AS vk INNER JOIN vbap AS vp ON vkvbeln = vpvbeln )
WHERE vk~vbeln IN s_vbeln.
SORT gt_sales BY vbeln kunnr.
mylist-name = 'Report Tree List'.
mylist-color = 1.
mylist-intensiv = '1'.
mylist-text = 'Report Tree List'.
mylist-tlength = 16.
mylist-tlevel = 1.
mylist-tcolor = 1.
mylist-tintensiv = '1'.
*mylist-text1 = 'using "RS_TREE_CONSTRUCT" function'.
mylist-tlength1 = 50.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
LOOP AT gt_sales.
ON CHANGE OF gt_sales-vbeln.
mylist-name = 'level1'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = 'Sales Document no:'.
mylist-tlength = 20.
mylist-tlevel = 2.
mylist-tcolor = 7.
mylist-tintensiv = '1'.
mylist-text1 = gt_sales-vbeln.
mylist-tlength1 = 30.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDON.
ON CHANGE OF gt_sales-kunnr.
mylist-name = 'level2'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = 'Customer no:'.
mylist-tlength = 20.
mylist-tlevel = 3.
mylist-tcolor = 5.
mylist-tintensiv = '1'.
mylist-text1 = gt_sales-kunnr.
mylist-tlength1 = 30.
mylist-tcolor1 = 3.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDON.
mylist-name = 'level3'.
mylist-color = 0.
mylist-intensiv = '0'.
*mylist-text = gt_sales-matnr.
mylist-tlength = 15.
mylist-tlevel = 4.
mylist-tcolor = 4.
mylist-tintensiv = '0'.
mylist-text1 = gt_sales-arktx.
mylist-tlength1 = 30.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
MYLIST-COLOR = 2.
MYLIST-INTENSIV = '0'.
MYLIST-TEXT = GT_SALES-ERNAM.
MYLIST-TLENGTH = 20.
*MYLIST-TLEVEL = 4.
APPEND mylist.
*MYLIST-NAME = 'LEVEL4'.
*MYLIST-COLOR = 2.
*MYLIST-INTENSIV = '0'.
*MYLIST-TEXT = GT_SALES-ERNAM.
*MYLIST-TLENGTH = 20.
*MYLIST-TLEVEL = 4.
*APPEND MYLIST.
ENDLOOP.
ENDFORM. " FILL_ITAB
*
*
FORM main .
PERFORM hierarchy. " construct & draw the tree
ENDFORM. " MAIN
*
FORM hierarchy .
PERFORM build_tree.
PERFORM draw_tree.
ENDFORM. " HIERARCHY
----
FORM BUILD_TREE *
----
FORM build_tree.
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = mylist
EXCEPTIONS
tree_failure = 1.
ENDFORM. "build_tree
----
FORM DRAW_TREE *
----
FORM draw_tree.
sy-lsind = 0.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = 'Ztest13'
callback_user_command = 'NODE_SELECT'
*(001)
IMPORTING
f15 = f15.
ENDFORM. "draw_tree
‎2007 Jul 12 10:11 AM
REPORT ZTEST13 MESSAGE-ID znew .
TREE HIRRARCHY REPORT **********************
TABLES : vbak.
DATA: BEGIN OF mylist OCCURS 50. " Internal table hierarchy
INCLUDE STRUCTURE snodetext.
DATA: END OF mylist.
DATA: f15 TYPE c.
DATA : BEGIN OF gt_sales OCCURS 0,
vbeln LIKE vbak-vbeln,
kunnr LIKE vbak-kunnr,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
ERNAM LIKE VBAK-ERNAM,
END OF gt_sales.
*SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD S_VBELN.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN OBLIGATORY.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
V_TEXT1 = 'SALES ORDER NO'.
START-OF-SELECTION.
SET PF-STATUS 'ZTREE1'. " create in t-code se41
SET TITLEBAR 'T1'.
PERFORM fill_itab.
PERFORM main.
FORM fill_itab .
SELECT vkvbeln vkkunnr VKERNAM vpmatnr vp~arktx INTO CORRESPONDING
FIELDS OF
TABLE gt_sales
FROM ( vbak AS vk INNER JOIN vbap AS vp ON vkvbeln = vpvbeln )
WHERE vk~vbeln IN s_vbeln.
SORT gt_sales BY vbeln kunnr.
mylist-name = 'Report Tree List'.
mylist-color = 1.
mylist-intensiv = '1'.
mylist-text = 'Report Tree List'.
mylist-tlength = 16.
mylist-tlevel = 1.
mylist-tcolor = 1.
mylist-tintensiv = '1'.
*mylist-text1 = 'using "RS_TREE_CONSTRUCT" function'.
mylist-tlength1 = 50.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
LOOP AT gt_sales.
ON CHANGE OF gt_sales-vbeln.
mylist-name = 'level1'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = 'Sales Document no:'.
mylist-tlength = 20.
mylist-tlevel = 2.
mylist-tcolor = 7.
mylist-tintensiv = '1'.
mylist-text1 = gt_sales-vbeln.
mylist-tlength1 = 30.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDON.
ON CHANGE OF gt_sales-kunnr.
mylist-name = 'level2'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = 'Customer no:'.
mylist-tlength = 20.
mylist-tlevel = 3.
mylist-tcolor = 5.
mylist-tintensiv = '1'.
mylist-text1 = gt_sales-kunnr.
mylist-tlength1 = 30.
mylist-tcolor1 = 3.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDON.
mylist-name = 'level3'.
mylist-color = 0.
mylist-intensiv = '0'.
*mylist-text = gt_sales-matnr.
mylist-tlength = 15.
mylist-tlevel = 4.
mylist-tcolor = 4.
mylist-tintensiv = '0'.
mylist-text1 = gt_sales-arktx.
mylist-tlength1 = 30.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
MYLIST-COLOR = 2.
MYLIST-INTENSIV = '0'.
MYLIST-TEXT = GT_SALES-ERNAM.
MYLIST-TLENGTH = 20.
*MYLIST-TLEVEL = 4.
APPEND mylist.
*MYLIST-NAME = 'LEVEL4'.
*MYLIST-COLOR = 2.
*MYLIST-INTENSIV = '0'.
*MYLIST-TEXT = GT_SALES-ERNAM.
*MYLIST-TLENGTH = 20.
*MYLIST-TLEVEL = 4.
*APPEND MYLIST.
ENDLOOP.
ENDFORM. " FILL_ITAB
*
*
FORM main .
PERFORM hierarchy. " construct & draw the tree
ENDFORM. " MAIN
*
FORM hierarchy .
PERFORM build_tree.
PERFORM draw_tree.
ENDFORM. " HIERARCHY
----
FORM BUILD_TREE *
----
FORM build_tree.
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = mylist
EXCEPTIONS
tree_failure = 1.
ENDFORM. "build_tree
----
FORM DRAW_TREE *
----
FORM draw_tree.
sy-lsind = 0.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = 'Ztest13'
callback_user_command = 'NODE_SELECT'
*(001)
IMPORTING
f15 = f15.
ENDFORM. "draw_tree