cancel
Showing results for 
Search instead for 
Did you mean: 

Org Chart in tree structure

Former Member
0 Kudos

Hi Friends,

How to Create a tree structure for org. unit in web dynpro ABAP

and call the tree in F4 Help of a input box.

Accepted Solutions (0)

Answers (2)

Answers (2)

Madhu2004
Active Contributor
0 Kudos

HI Lalsha,

Create a new webdynpro component which has the org unit tree strucure view.Thsi component should implement the interface IWD_VALUE_HELP.

In the new web dynpro component donot load the complete data at one go but load them on expanding the tree.

Reuse this component in your main component and for the attribute chnage the value help mode as freely programmed value help and give the name of the reused component.

In the value help component on selecting the org unit bind the value to mainattribute.

refer WDR_TEST_CUSTOM_VHELP for new value help component and WDR_TEST_ADOBE for the usage of the freely programmed value help.

Regards,

Madhu

ChrisPaine
Active Contributor
0 Kudos

Hello Lalsha,

There is no standard solution for this, you will need to code your own custom value help.

there is an article that deals with the use of a tree and organisational structure data:

[DISPLAYING DYNAMIC RECURSIVE TREE WITH TABLE IN WEB DYNPRO ABAP|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/10f794ed-7811-2d10-30b7-9fdd89e269a6] But I would strongly recommend that you do not use the code in this article to retrieve the organisational structure data. (For the reasons I commented on the article review.)

Instead use the standard FMs RH_STRUC_GET_MULTIPLE_ROOTS or RH_STRUC_GET. (Search SCN if you're not sure how to use them, there should be plenty of references).

I also would be reluctant to spend a lot of time coding any solution, as it is likely that EhP5 will deliver some WDA functionality in this area which you could then reuse (I certain can't guarantee that statement, and goodness only knows when EhP5 is going to be available).

I've built solutions that do exactly what you are wanting in both WDJ and WDA and I have one recommendation: Don't attempt to render the entire structure immediately. Instead make use of the expand node events to read the data for a given node and just load what you need to to display information to the user. If you try to load the entire structure and just have the nodes collapsed the user will be waiting a very long time for the WDA to render.

Hope this helps,

Chris

SamuliKaski
Active Participant
0 Kudos

Good advice there guys.

I myself just finished such an implementation at one of my customers. It took 2 days to complete. I can't give you the solution as the customer retains the immaterial rights for the solution but I thought I would tell you the steps involved to get you on the right track.

1. Context. Build a context node that on the top level has the orgunit, it's attributes (such as otype, objid, stext, etc) and the recursive node that points to the orgunit node. Inside the orgunit create a node for the position. Inside the node place the attributes for the position (like before) and a recursive node that points to the position node. Finally inside the position node place a node for the person and it's attributes (like before), but no recursion node this time.

2. Layout: Place a tree element in your view. Inside the tree element insert two node types and one item type. First node is for orgunit, second one is for position. The only item is for the person. You might want to add respective icons, to get nicer UI. Add the load children action for orgunit and position. Depending on what you want to select from the tree, add a select action for either orgunit, position or person.

3. Code #1: as Chris points out, use RH_STRUC_GET to get the organization tree. I myself used O_S_P. You might want to create a FM that returns all 3 itabs returned by RH_STRUC_GET to the WDA. Create a freely programmed value help as suggested in many threads, it's pretty straight forward. In the WDA utilizing the VH, mark one or more items in the context as freely programmed VH and connect to your implementation.

4. Code #2: At start up, for example in the WDDOINIT method, create only the root node and call it for example "All organization units". Then create one action that is called when children nodes have to be loaded, one method for figuring out what do when a child is being requested (and what kind of child: orgunit, position or person) and finally a method for actually creating the node.

5. Code #3: The magic comes from RH_STRUC_GET. Use the STRUC itab at runtime to find the objects at certain levels and to determine their parent(s) and children. The most important values in the STRUC itab in this case are LEVEL, OTYPE, OBJID and PUP.

Pretty straight forward and the solution is quite nice indeed. I'm sorry if I forgot something, I wrote this without access to the system.