Working with Large Object Hierarchies (Siebel Objects)
I received an e-mail from Suni Reddy, who asked me to share with her an easy way of working with Siebel objects – primarily because of their giant object hierarchy. I have thought about it several times, but because our work on Siebel goes on a temporary basis, I was never able to come up with something. Until now. This news story will portray how you can generate a single library with all the parent objects and call those objects on demand.
Normally, if you would like to select an item from a SiebList, you would do something like:
SiebApplication("MyApplication").SiebScreen("MyScreen").SiebView("MyView")_
.SiebApplet("MyApplet").SiebList("MyList").Select "Open"
The above hierarchy can be greatly simplified – and this editorial will show a few ways how it can be achieved. Also, the way we’re going to structure our hierarchy, changing two object in a single place will account for an overall alter. In other words, in lieu of changing a single object multiple times (because something changed in the application) we’ll alter it only two times.
With Statements
This is by far the most common approach used when dealing with large hierarchies, and quite simple too. However, as the parent objects change, we end up creating more and more blocks of such statements. An example of With..End With statement in use:
- With SiebApplication("MyApp").SiebScreen("MyScreen1").SiebView("MyView").SiebApplet("MyApplet")
- .SiebList("MyList").Select "Open"
- .SiebButton("MyButton").Click
- End With
- 'SibScreen changes from MyScreen1 to MyScreen99: re-write.
- With SiebApplication("MyApp").SiebScreen("MyScreen99").SiebView("MyView").SiebApplet("MyApplet")
- 'your code
- End With
Using Functions to Build Sieb Hierarchy
This technique uses several functions to create an entire hierarchy, but the result is good. Moreover, it also simplifies how events are performed on objects. Let's start building our first function of the database object (SiebApplication):
- 'Base Object: SiebApplication
- Function oSiebApplication
- Set oSiebApplication = SiebApplication("MyApp")
- End function
- Let’s create instances for our Child objects:
- 'oSiebScreen retrieves its parent (oSiebApplication) from the function above
- Function oSiebScreen
- Set oSiebScreen = oSiebApplication.SiebScreen("MyScreen")
- End Function
- 'oSiebView_ retrieves its parent (oSiebScreen) from the function above
- Function oSiebView
- Set oSiebView = oSiebScreen.SiebView("MyView")
- End Functions
- 'oSiebApplet retrieves its parent (oSiebView) from the function above
- Function oSiebApplet
- Set oSiebApplet = oSiebView.SiebApplet("MyApplet")
- End Function
- To demonstrate, if we want to set a value in the “lstApplication1″ SiebList, we can simply do the following:
- oSiebApplet.SiebList("lstApplication1").Select "Urgent"
Using Classes
This is my favorite, and very similar to what we have above, but the advantage of using this technique is that we have several multiple parenting classes or one class to the group at all. Suppose we have the following hierarchy, with an even
- SiebApplication("MyApp").SiebScreen("MyScreen").SiebView("MyView")_
- .SiebApplet("MyApplet").SiebList("lstApplication1").Highlight
- First, let’s create a sample class for the Base object(s) that will be common for all classes.
- 'Demo class for the top-most object (Parent Class)
- Class clsSiebApplication
- Public Property Get oSiebApplication
- Set oSiebApplication = SiebApplication("MyApp")
- End Property
- End Class
- Now, let’s build the child classes, that will use the base class to complete object hierarchies:
- 'Child Class: Derives its Base Object from clsSiebApplication (Parent Class)
- Class clsSiebObjects
- Private oShared
- 'We will reuse the Base class to retrieve some common objects
- 'An instance of the base class will be initialized as the class loads
- Private Sub Class_Initialize
- Set oShared = new clsSiebApplication
- End Sub
- 'Terminate the instance while exiting.
- Private Sub Class_Terminate
- Set oShared = Nothing
- End Sub
- 'oSiebScreen Property will retrieve its parent from oSiebApplication
- Public Property Get oSiebScreen
- Set oSiebScreen = oShared.oSiebApplication.SiebScreen("MyScreen")
- End Property
- 'oSiebView Property will retrieve its parent from oSiebScreen (above)
- Public Property Get oSiebView
- Set oSiebView = oSiebScreen.SiebView("MyView")
- End Property
- 'oSiebApplet Property will retrieve its parent from oSiebView (above)
- Public Property Get oSiebApplet
- Set oSiebView = oSiebView.SiebApplet("MyApplet")
- End Property
- End Class
This can be used in a way that makes it very easy for the reader to understand the objects with which the script is working. We will use the same example we used above with the "lstApplication1" SiebList:
- Dim oSieb
- 'Create an instance of clsSiebObjects
- Set oSieb = New clsSiebObjects
- 'Performing an event on the SiebList Object
- oSieb.SiebApplet.SiebList("lstApplication1").Highlight
Using an Object Dictionary
This technique is based on Article Meir, Implementation of a layer of graphical user interface classes. I would recommend you read the article to better understand this approach. I used a high-level approach to this concept, and to better utilize this process, the article should be read carefully. This technique can be used as follows to simplify a large object hierarchy:
- Class clsSiebObjects
- Private m_htContext
- 'Loads the Object Dictionary
- Public Function Load
- LoadContext
- Set Load = m_htContext
- End Function
- 'Represents the Object Context
- Private Function LoadContext
- m_Context = CreateObject("Scripting.Dictionary")
- 'Loading objects in the dictionary.
- With m_Context
- 'SiebApplication
- .Add "SiebApplication", SiebApplication("MyApp")
- 'SiebScreen (Parent: SiebApplication)
- .Add "SiebScreen", .Item("SiebApplication").SiebScreen("MyScreen")
- 'SiebView (Parent: SiebScreen)
- .Add "SiebView", .Item("SiebScreen").SiebView("MySiebView")
- 'SiebApplet (Parent: SiebView)
- .Add "SiebApplet", .Item("SiebView").SiebApplet("MySiebApplet")
- End With
- End Function
- 'Property Get/Let m_Context
- Private Property Let m_Context(ByVal Val)
- Set m_htContext = Val
- End Property
- Private Property Get m_Context()
- Set m_Context = m_htContext
- End Property
- End Class
- The snippet below shows usage of the above class to simplify Siebel Hierarchy:
- Dim oSieb
- 'Instance of the Class
- Set oSieb = New clsSiebObjects
- Set oSieb = oSieb.Load
- oSieb.Item("SiebApplet").SiebPickList("lstApplication1").Select "Open"
Summary
In the examples above, you may notice why only the top 4 objects (Application, Screen, View, Applet) of the hierarchy have been included. This is because, including all the objects will water your libraries and make spotting the right object a cumbersome task. Thus, by including only the top 4 hierarchies, they can simplify our work on a great scale. If the hierarchy changes, they would basically need to alter the elements at one place, only.
For developers who wish to use descriptive programming with Siebel applications, please note that you will have to write descriptions of the objects of the parents only once. When these changes in the descriptions, the update in one place will be the only maintenance required. I am using descriptive programming 100%, with our Siebel application and techniques in this article have really simplified my job much care only for the parent objects.
I hope Automation Developers using Siebel with QTP find this news story useful. Thanks for visiting Relevant Codes.














