Extracting UDAs from the Outline
First, hope everyone had a wonderful holiday weekend. Now it's back to real life...
I have been doing quite a bit with DRM for a while now and am currently migrating a Planning application to DRM. One of my most recent tasks was to load the UDA's into DRM. Now I am sure I probably could have saved myself a few minutes by using the Outline Extractor but I didn't remember my login and enjoy working with Python and XML.
One thing to note here is I used Python not Jython for this. Jython is great for a lot of things but there are some things where Python just easier and far faster. With the help of lxml, XML is one of those things.
So first things first, I exported a dimension from the outline in XML format. To do this I used my Jython implementation of Celvin's Essbase Member Operations Utility in which I have included a method for exporting the outline. This could have also been done via MaxL either through command line or EAS.
Next, I loaded the exported file into lxml.
from lxml import etree
root = etree.parse("outline-export1.xml")
lxml makes it really easy to look for things in a xml file so I used the xpath method to grab all the members in the xml file and looped through them. While looping I used the findall command to grab any UDA's assigned.
members = root.xpath("//Member")
for member in members:
udas = member.findall("UDA")
Finally, I looped through the UDA's and printed them to the console for easy copy and paste into Excel where I could turn the result into an action script.
if udas is not None:
for uda in udas:
print("%(member)s\t%(uda)s" % { "member" : member.attrib["name"], "uda" : uda.text } )
The complete result is below.
I could have gone a step further and had Python create the actionscript by setting the content of the print command to something like what's below but I got lazy. ;) (Also if you haven't noticed I prefer tabs in my actionscripts.)
"ChangeProp\tCurrent\tEntity\t%(member)s\tCOR.UDA\t%(uda)s" % { "member" : member.attrib["name"], "uda" : uda.text }