* ----------------------------------------------------------------------
* This program is another type of nodes tree (hierarchical nodes) for
* displaying information on the screen related in some way father-son.
* No need to create a screen nor draw objects on it, but it is desi-
* rable to create a GUI-status (STATUS-100) with some buttons for
* user interaction.
* ----------------------------------------------------------------------
REPORT ztest NO STANDARD PAGE HEADING.
TABLES: sflight, scarr.
DATA: BEGIN OF mytable OCCURS 100,
CARRID like sflight-CARRID,
FLDATE like sflight-FLDATE,
PRICE like sflight-PRICE,
CURRENCY like sflight-CURRENCY,
PLANETYPE like sflight-PLANETYPE,
SEATSMAX like sflight-SEATSMAX,
END OF mytable.
DATA: text1(50), text2(50), text3(50), text4(50),
color1 TYPE i, color2 TYPE i, color3 TYPE i, color4 TYPE i,
level TYPE i,
len1 TYPE i, len2 TYPE i, len3 TYPE i, len4 TYPE i,
mytree TYPE TABLE OF snodetext WITH HEADER LINE.
* ----------------------------------------------------------------------
* Selection screen
* ----------------------------------------------------------------------
SELECTION-SCREEN: BEGIN OF BLOCK marco WITH FRAME TITLE text-001,
SKIP.
SELECT-OPTIONS: pcarrid FOR sflight-carrid,
pfldate FOR sflight-fldate.
SELECTION-SCREEN: END OF BLOCK marco.
* ----------------------------------------------------------------------
* Read data
* ----------------------------------------------------------------------
SELECT carrid fldate price currency planetype SEATSMAX
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE mytable
WHERE carrid IN pcarrid
AND fldate IN pfldate.
* ----------------------------------------------------------------------
* Build the tree
* ----------------------------------------------------------------------
SORT mytable BY carrid fldate.
LOOP AT mytable.
AT FIRST.
text1 = 'Listing of Airlines'.
len1 = 50.
color1 = 2.
level = 1.
PERFORM fill_treetab.
ENDAT.
AT NEW carrid.
select single CARRNAME from scarr
into scarr-CARRNAME
where carrid = mytable-carrid.
CONCATENATE mytable-carrid scarr-CARRNAME
INTO text1 separated by space.
len1 = 25.
color1 = 3.
level = 2.
PERFORM fill_treetab.
ENDAT.
AT NEW fldate.
concatenate 'Flight date: ' mytable-fldate+6(2) mytable-fldate+4(2)
mytable-fldate+0(4) into text1 separated by space.
len1 = 22.
color1 = 4.
level = 3.
PERFORM fill_treetab.
ENDAT.
text1 = mytable-price.
condense text1.
len1 = 12.
color1 = 5.
text2 = mytable-currency.
len2 = 5.
color2 = 5.
text3 = mytable-planetype.
len3 = 10.
color3 = 5.
text4 = mytable-SEATSMAX.
condense text4.
len4 = 7.
color4 = 5.
level = 4.
PERFORM fill_treetab.
ENDLOOP.
*----------------------------------------------------------------------
* Build a hierarchy here
*----------------------------------------------------------------------
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = mytree
EXCEPTIONS
tree_failure = 1.
SET PF-STATUS 'STATUS-100'.
*----------------------------------------------------------------------
* Display the created hierarchy
*----------------------------------------------------------------------
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = 'ZTEST'
callback_user_command = 'SELECT_NODE'
return_marked_subtree = 'X'
layout_mode = 'X'.
*----------------------------------------------------------------------
* User interaction when working with the nodes tree
*----------------------------------------------------------------------
FORM select_node TABLES knoten STRUCTURE seucomm
USING command
CHANGING exit list_refresh.
exit = ' '.
list_refresh = 'X'.
CASE command.
WHEN 'EXPAND'.
CALL FUNCTION 'RS_TREE_EXPAND'
EXPORTING
node_id = 1
all = 'X'
EXCEPTIONS
not_found = 1
OTHERS = 2.
WHEN 'COLLAPSE'.
CALL FUNCTION 'RS_TREE_COMPRESS'
EXPORTING
node_id = 1
EXCEPTIONS
not_found = 1
OTHERS = 2.
ENDCASE.
ENDFORM.
*----------------------------------------------------------------------
* FORM FILL_TREETAB
*----------------------------------------------------------------------
FORM fill_treetab.
mytree-name = text1.
mytree-color = color1.
mytree-intensiv = '1'.
mytree-text = text1.
mytree-tlength = len1.
mytree-tlevel = level.
mytree-tcolor = color1.
mytree-text1 = text2.
mytree-tlength1 = len2.
mytree-tlevel = level.
mytree-tcolor1 = color2.
mytree-text2 = text3.
mytree-tlength2 = len3.
mytree-tlevel = level.
mytree-tcolor2 = color3.
mytree-text3 = text4.
mytree-tlength3 = len4.
mytree-tlevel = level.
mytree-tcolor3 = color4.
APPEND mytree.
CLEAR: text1, text2, text3, text4,
color1, color2, color3, color4.
ENDFORM.
02/08/2010
Another Type of Nodes Tree
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário