Create a Web Dynpro Tree from an XML file
This weblog is the following of my previous weblog which deals with the creation of a Web Dynpro Tree. The next parts of this weblog explain how to import an XML file in the context (link to weblog), to create the WDP tree from this file and possible applications.
Benefits of this are less coding, no user information in the code (but in the XML), and an easier maintenance , you only change the XML file to change the tree, you don’t need to change the code.
Part 3: Creating WDP tree from XML the file
Part 4: Applications
When you want to create a tree in a WDP application, instead of coding everything you can use a really usefull method, that is to create the WDP tree from an XML file. You just have to define in your XML the nodes you want to see in your WDP tree and their values.
Here is an example which show a CV in a Web Dynpro application from an XML file:
Tree From the XML file
Let’s now detail how to create this WDP tree from the XML file.
Creating WDP tree from the XML file
Using XML manipulation libraries like DOM (Document Object Model) or SAX (Simple API for XML), depending if your application processes small or huge files, you create a function which go through all the XML nodes.
For each visited node in the XML, you create a node in the resulting Web Dynpro Tree.
DOM is efficient with small XML files because the document is fully loaded in memory.
SAX works differently and is efficient with bigger documents. The SAX parser goes through the XML nodes and for each node it calls an event so the document is not fully loaded in memory.
For more information go to this link:
We can imagine a lot of applications to this process. For example:
As shown at the begining of the Weblog, you can have a look on a CV in a Web Dynpro application.
Web site menu maintenance
You can maintain all your menus in an XML file, it’s easier than change everything in the code.
Represent SAP Products by familly
You can create an XML file for SAP products sorted by familly. With the application you have a graphical and hierachical representation of all products.
There are a lot of possible applications. The purpose of this weblog was just to explain how and why create a tree in a WDP application from an XML file.
For the CV example, without this methodology you have to hard code every information for each user. Using this methodology allows you to store CVs in a repertory and then the rest is done by your application.
From my point of view this method could be very usefull and you can have a kind of “web service manner” to proceed your WDP application. You can also reuse XML response files directly from a web service to have a quick graphical view of the web service response.
One leak would be that it doesn’t take into account the attributes of XML tags into the WDP tree struture, it could be one improvement.