Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Tree Problem

former_member216100
Participant
0 Likes
888

Dear all,

I use CL_GUI_SIMPLE_TREE and it works OK but

I need to add a node, I insert it into the internal table

node_tables but how I can refresh the screen that I

can see the new node ?

Please help.

Thanks.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
841

([SAP Tree and Tree Model (BC-CI)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCITREE/BCCITREE.pdf]

Did you set the UPDATE flag on so that changes to the tree control should be visible immediately.

CALL METHOD tree->set_screen_update
  EXPORTING
    UPDATE = UPDATE
  EXCEPTIONS
    failed = 1
    cntl_system_error = 2.

Regards

6 REPLIES 6
Read only

Former Member
0 Likes
841

hi check this example...

REPORT z_simpletree.

  • 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 : it_0022 TYPE STANDARD TABLE OF pa0022 INITIAL SIZE 0,

wa_0022 TYPE pa0022.

*Internal table and wa decl for text table t517x

DATA : it_517x TYPE STANDARD TABLE OF t517x INITIAL SIZE 0,

wa_517x TYPE t517x.

*Internal table and wa decl for text table t517T

DATA : it_517t TYPE STANDARD TABLE OF t517t INITIAL SIZE 0,

wa_517t TYPE t517t.

*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 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

&----


  • 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 = '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.

*Filling the values of internal table into tree

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.

*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-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. " 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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
843

([SAP Tree and Tree Model (BC-CI)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCITREE/BCCITREE.pdf]

Did you set the UPDATE flag on so that changes to the tree control should be visible immediately.

CALL METHOD tree->set_screen_update
  EXPORTING
    UPDATE = UPDATE
  EXCEPTIONS
    failed = 1
    cntl_system_error = 2.

Regards

Read only

0 Likes
841

I tried but dont work

I can see that the new node is in the internal table

but I can not see it on the screen.

Read only

0 Likes
841

How did you add the nodes, did you use

CALL METHOD simple_tree->add_nodes
  EXPORTING 
    table_structure_name = table_structure_name
    node_table = node_table
  EXCEPTIONS
    error_in_node_table = 1
    failed = 2
    dp_error = 3
    table_structure_name_not_found = 4.

Regards

Read only

0 Likes
841

No because I tried and I got a dump.

MESSAGE_TYPE_X

METHOD FLUSH .

do I need to call a flush first before I call add_nodes ?

I just filled the internal table with the new node.

if you can provide me a sample abap with adding

a new node would be great !!!

Thanks

Read only

0 Likes
841

Look at this program :[RSDEMO_DRAG_DROP_EDIT_TREE|http://help.sap.com/saphelp_erp2004/helpdata/en/c0/64b4c7c74411d2bd93080009b4534c/frameset.htm]

Also don't hesitate to use the SAP demo transactions

- SE83

- DEMO_TRANSACTION

- DEMO_SCREEN_FLOW

- DWDM, etc.

Regards