* obsolete Darstellung über die FuBas RS_TREE_CONSTRUCT und RS_TREE_LIST_DISPLAY
* besser ist die Nutzung der Klassen cl_salv_tree, cl_gui_simple_tree, cl_gui_column_tree, cl_gui_list_tree
SELECT kunnr,
land1,
name1,
ort01
INTO TABLE @DATA(it_kna1)
FROM kna1
UP TO 25 ROWS.
SELECT vbeln,
erdat,
erzet,
netwr,
waerk,
kunnr
INTO TABLE @DATA(it_vbak)
FROM vbak
FOR ALL ENTRIES IN @it_kna1
WHERE kunnr = @it_kna1-kunnr.
SELECT vbeln,
posnr,
matnr,
netwr,
waerk
INTO TABLE @DATA(it_vbap)
FROM vbap
FOR ALL ENTRIES IN @it_vbak
WHERE vbeln = @it_vbak-vbeln.
* Rootnode (Node-Level 1)
DATA(it_nodes) = VALUE snodetab( ( tlevel = 1
name = 'Kundenstamm'
nlength = 27
color = col_key
text = 'Verkaufs-Report'
tlength = 50
)
).
LOOP AT it_kna1 ASSIGNING FIELD-SYMBOL(<k>).
* Node-Level 2
DATA(lv_node_2) = VALUE snodetext( tlevel = 2
name = <k>-kunnr
nlength = 19
color = col_key
text = <k>-land1
tlength = 5
tcolor = col_normal
text1 = <k>-name1
tlength1 = 40
tcolor1 = col_normal
text2 = <k>-ort01
tlength2 = 25
tcolor2 = col_normal
).
APPEND lv_node_2 TO it_nodes.
LOOP AT it_vbak ASSIGNING FIELD-SYMBOL(<v>) WHERE kunnr = <k>-kunnr.
* Node-Level 3
DATA(lv_node_3) = VALUE snodetext( tlevel = 3
name = <v>-vbeln
nlength = 15
color = col_positive
text = <v>-erdat
tlength = 12
tcolor = col_normal
text1 = <v>-erzet
tlength1 = 10
tcolor1 = col_normal
text2 = <v>-netwr
tlength2 = 15
tcolor2 = col_total
text3 = <v>-waerk
tlength3 = 5
tcolor3 = col_total
).
APPEND lv_node_3 TO it_nodes.
LOOP AT it_vbap ASSIGNING FIELD-SYMBOL(<p>) WHERE vbeln = <v>-vbeln.
* Node-Level 4
DATA(lv_node_4) = VALUE snodetext( tlevel = 4
name = <p>-posnr
nlength = 11
color = col_group
text = <p>-matnr
tlength = 23
tcolor = col_normal
text1 = <p>-netwr
tlength1 = 15
tcolor1 = col_total
text2 = <p>-waerk
tlength2 = 5
tcolor2 = col_total
).
APPEND lv_node_4 TO it_nodes.
ENDLOOP.
ENDLOOP.
ENDLOOP.
* Tree-Objekte in Funktionsgruppe SEUT
* Neue Hierarchie aufbauen bzw. Teilbaum einfügen
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_nodes
EXCEPTIONS
tree_failure = 1
id_not_found = 2
wrong_relationship = 3
OTHERS = 4.
IF sy-subrc = 0.
* Konstanten sind in Typgruppe STREE definiert
* Hierarchie anzeigen
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = sy-repid
callback_user_command = 'ON_USER_COMMAND' " Formroutine für Callback-Funktion für Buttons und Mausklicks
status = 'STANDARD' " GUI-Status des Trees (wird für Callback benötigt, kann sonst weggelassen werden
use_control = stree_use_list. " stree_use_list (Liste), stree_use_list_print (Druckausgabe), stree_use_control (Fullscreen-Control), stree_use_in_dynpro (Dynpro)
ELSE.
WRITE: / 'Fehler:', sy-subrc.
ENDIF.
* Form ON_USER_COMMAND
* Callback-Funktion für Buttons und Mausklicks
FORM on_user_command TABLES node STRUCTURE seucomm
USING command
CHANGING exit
list_refresh.
* Messagetext ausgeben, um geklicktes Element zu identifizieren
MESSAGE |{ node-name }, { command }| TYPE 'S'.
ENDFORM.