Tuesday, November 14, 2017

FDMEE - Dynamic Hierarchy Data Maps

The Business Case:

You need to set up Dynamic Data Maps based on a hierarchy in a given dimension like Cost Center or Entity (i.e. if the level 0 member value is a descendant of a given parent map it, otherwise IGNORE). 

The Problem:

Oracle doesn’t provide any documentation for how to read hierarchies to provide this type of dynamic mapping.  The hierarchies are in FDMEE as you can see from the selection box:

…but, how are you supposed to use the hierarchy in the mapping?

A Solution:

Well, this took a bit of trial and error within the FDMEE repository, but turns out, you can query the fully qualified path in the “AIF_TARGET_APPL_DIMENSIONS” table with a SQL Script in your data maps.  It’s actually quite straight forward with some nested queries.

Navigate to the Data Load Mapping and access the “LIKE” maps for the dimension you need.  Add 2 rows (at a minimum…  You can always add more).  The first one will be the SQL script, and the second one will be a default of “IGNORE”:

The idea here is that if we don’t map it with our script, we don’t want to load it to the Target Application.

Select the Pencil on our “#SQL” mapping line to add the CASE statement:

You’ll notice that we are doing some additional lookups for the Application ID and Dimension_ID in order to sync up with the correct hierarchy. 

I will note, that you will need to be careful with the Upper Level member “Like” characters if you have a lot of shared members.  You can add items there to make sure you are only searching your primary hierarchy.

It’s as simple as that…  Tack on an automated “REFRESH MEMBERS” function, and you are off to the races with your automation and dynamic hierarchy maps.

Hope this is helpful to you and good luck!

Wednesday, October 25, 2017

FDMEE/Jython: Automating “REFRESH MEMBERS” with a Script

The Business Case:

You have just gotten your FDMEE data loads set up and running, including DataMaps that are dynamic based on the hierarchies (i.e. if the level 0 member value is a descendant of a given parent map it, otherwise IGNORE).  You discover the handy “Refresh Members” button on an FDMEE target application:

…but, as the administrator, you don’t want to have to log into the system and click that button once a day, every other day, or every hour. 

The Problem:

Oracle doesn’t give you an any way to schedule this “Refresh Members” function, because why would you ever want to automate that? Right?!  …Sigh…

A Solution:

…and here comes the FDMEE REST API to the rescue!! 

Now, I had been mulling over this particular question for nearly a year, and finally came back to it in the last couple of weeks after I ran across this Refresh Members thread in the Oracle community where John Goodwin put an example REST post for refreshing the members.  If you want a lot of great information regarding REST and PBCS, John has several great blog posts on the subject…

So, armed with this new information, I set out to find a way to write the jython script to submit the REST request.  After digging around some python documentation, I did the right kind of search and came across one of Francisco’s REST API posts.  As always, he provided some great codes snippets to pretty much write the entire script (Using On-Prem Planning REST API to Import Metadata).  Of course, we aren’t using Planning, but we get a very good idea of how the script needs to go…

I’ll just pause here to say a huge “THANK YOU!” to these guys.  They have helped me so much with their insight and knowledge!

A lot of the following will be very close to Francisco’s post, with a couple of changes.

Steps to run the “REFRESH MEMBERS” Job

1.      Import  modules:

Note the first import for DwgObject, which is another gift from Franciso.  In one of his other blogs he talked about how to decode passwords from the ODI repository, so I have created a dummy data server in ODI to house my credentials to use for the authentication step, rather than a hardcoded UID and password.

2.      Establish variables and build the REST URL:

3.      Set up the “Payload” or “Data” for the request:

This is where I had some fun trying to figure out what was going on.  All the information seemed to indicate that the “urllib.urlencode()” was required.  However, I continued to receive a HTTP Error 400 – Incorrect Syntax error until I just passed the raw payload string. Once I commented out the urlencode line, voalĂ !  Job submitted successfully!

4.      Set the Authentication.  Again, I use the method of decoding credentials from ODI for this.

5.      Open the Request, add the Headers, and add the payload

There are a couple of methods for adding the payload/data and therefore causing the request to be a POST request.  The following seemed nice and clean:

The debug log entries for the request objects were very helpful in diagnosing my issues with getting the script to work properly.  The response may be parsed for different information like ProcessID and Status of the request.  Based on the status, the sky is the limit on where to go next.  You could even make this into a custom function to call from the BefImport event.

Hooray!  A working “REFRESH MEMBERS” jython script utilizing the REST API for FDMEE!  Hope this is helpful to you and good luck!