Want to know The Truth About CPM?

12 August 2013

Two Planning updates this week


Two exciting (okay, I may be stretching the meaning of the word “exciting”) bits of Planning news this week.

Updated Planning security queries

I have expanded and modified part two and three of my Planning security query series.  Would you believe that I conceived of the modifications whilst shoveling gravel to fill in potholes?  No, this was not part of my prison-release program (note to everyone – that’s a joke, I have never been arrested, let alone convicted of anything, except being an Essbase/Dodeca/ODI/SQL geek and I am judge, jury, and executioner on that sentence), but instead what my bored mind was doing as I was trying to see if my shoulder really would separate if I picked up enough gravel with a shovel.  Note – so far, no replacement shoulder, so that gym time has paid off.  

In any case, as I was putting in my geeks-who-do-yardwork-for-other-people time, I had nothing much to actually think about (some call it thinking) and I started naturally (?) thinking about what the queries I had written for this series.  And then I realized – hey, I can improve these quite a bit by changing some of the CTEs and making the queries that much better.  And so I have.  Go back and take a look – I hope you’ll agree that the output is now more useful.

Changed time for Too Big for Kscope13 – Part 2 of Six Advanced Planning Topics

Continuing the theme of me not thinking (something I appear to be quite good at), this webinar was originally scheduled for tomorrow, 13 August 2013 at 12 noon Eastern – it is now scheduled for Wednesday, 14 August 2013 at 12 noon Eastern.  In other words, it is being held a day later.  And that’s my fault.  Oops.

I am travelling to my client (yes, I work and for some reason clients pay me for it) on Tuesday.  I completely forgot about this altered travel pattern (my usual on site schedule is Monday through Thursday but this was a client-requested exception) when I agreed to the webinar date.  However, I did oh-so-cleverly manage to remember this in the middle of a haircut last week.  What do you think about during a haircut?  Not much, right?  Well, in case you ever have the same brainwave, do not jump up in the middle of a haircut with an, “Oh, crap!” exclamation or you will receive the same, “WTH is your problem, Cameron?” response.  Oops again.

Hopefully you were there for Part 1 where Jessica and I covered general Planning implementation good practices, inherited security, and bringing metaread filters to Essbase datasources in Planining.

Part 2 should be just as interesting as it will cover:
  • Melding and Managing Forms, Task Lists, and Process Management
  • Making Planning Aggregations Better With Focused Aggregations
  • Automated LCM Migrations

I hope you can all make it to the slightly changed time and sorry to all for any inconvenience.

What’s next and a question

There’s one more Planning security query on offer – the creation of ASO (well, it could be for BSO but why?) reporting cube filters.   Hopefully that will be out in the next few weeks.

And I have a question for you, gentle reader, about a potential Kscope14 session.  Would you be interested in a session that goes under the covers of EPM and pulls out all kinds of information?  By that I mean I would include Planning but I’d also go after Shared Services, BI+ (Financial Reports), Calculation Manager, and EPMA.  The session would be a series of use cases, code examples (with the bits that were a total PIT-you-know-what highlighted), and sample output.  Is this something the ODTUG world would be interested in?  Let me know care of this blog.

07 August 2013

Stupid Planning security trick 3 of 4 - generating secfile.txt from SQL

Dumping LCM for security migration

Huh?  What?  Get rid of LCM for security migrations?  Is that a good idea?  Yes, in limited cases, it most certainly is.  Let me explain when, why, and most importantly for a blog post by Yr. Obdnt. Srvnt., how you would do such a thing.

Works when it’s small, unmanageable when it’s big or different

Shared Services’ LCM functionality allows the migration of Planning security.  This is a Good Thing.  Security migrations used to be called copy-the-Planning-schema-from-one-server-to-another.  Not Much Fun is another way to describe it.  So all in all, having a tool that will enable bulk migration of security and just about everything else in the Planning application is great.
But what happens when you need to migrate only part of a system’s security?  And the target largely differs from the source?  How do you selectively migrate that?  The short answer is, especially if you haven’t listened to your friendly consultant and used direct username security assignments (there, I made it bold red to give you the ever so subtle hint that this is a Bad Idea) is that you can’t.  Do you see the problem above?  It’s actually three problems in one.

The three problems

Users cannot be individually chosen

Do you see the check box for Users?  That’s all users and their directly assigned (Oh,I told you, I told you, I really did tell you not to do that but you did, didn’t you?  Tsk-tsk, now you’re stuck furiously scouring the web for ideas and have stumbled upon this blog.  For shame.) security definitions.  Those security assignments resolve to a single file.  Big deal you say?  What happens when that file is over 275,000 rows of simple XML?  Simplicity aside, how are you going to edit that for just some objects and just some users?  I have the answer to that – you aren’t, or you aren’t going to do it with any degree of correctness.

Groups are all or nothing

You can select individual groups as can be seen in the sample application above.  This is a good thing.  But you still can’t filter the objects or scope of the groups in questions and remember this all comes out as mildly nasty looking xml code as shown below.

It’s easy to edit a 43 line file – what happens when it too becomes a large file?  Bummer is what.

No way to tell who belongs to what

If you set Planning security up the right way, you have an inherited security model as I referenced in my last post.  How do you handle (or even know) inherited groups if you only want to migrate specific security, such as the security that goes with the users in the group PLN_CalcTest_Consol_EMEA?  I’m here to tell you that the users in that group are also, through inheritance, members in the PLN_CalcTest_Consol and PLN_CalcTest groups.  What about the security that goes with those groups?  Again, this is easy to figure out when the number of groups is small but not so easy when things begin to approximate the real world.  What oh what to do?

importsecurity.cmd + SQL = answer

It turns out that there is a Planning utility that has been around seemingly forever that can be the vessel for loading security into Planning.  I’m not going to repeat all of its functionality – for that have a read here of the documentation in the Planning administrator’s guide.

There are some restrictions on how importsecurity.cmd works:
  1. It must be run from the Planning server
  2. It must read from a file called “secfile.txt”
  3. It has a very specific format that is shared with no tool except of course exportsecurity.cmd

How oh how oh how would you generate a file that had follows all of importsecurity.cmd’s naming requirements and do so programmatically and even in a focused manner from a Planning application?  Why of course you would run a variation on last week’s SQL query but this time modify it to write out the correct format.  What other answer could there be in a four part SQL Planning security series?

The focused importsecurity.cmd query

 -- Dimensions and all of their members
    Dimensions AS
        O.OBJECT_NAME AS "Member",
            FROM HSP_OBJECT OB
            WHERE OB.OBJECT_ID = M.DIM_ID) AS "Dimension"
        HSP_MEMBER M
 -- All of the other object types, including the ones that aren't documented or in HSP_OBJECT_TYPE
 ObjType AS
       1 to 50 defined in HSP_OBJECT_TYPE
       103 = Menus
       107 = Composite forms
       115 = Deployed Business Rule
       116 = Looks like Business Rules, but don't exist in CM?  So orphaned?
       117 = Calculation Manager variables
       118 = Business Rule Folder
       119 = CalcMgrRulesets -- that's actually the OBJECT_NAME, so defined by system?
       120 = There are four valies in a three Plan Type Planning app:
       CONVERT(INT, '103') AS "OBJECT_TYPE",
       'Menu' AS "TYPE_NAME"
       CONVERT(INT, '107') AS "OBJECT_TYPE",
       'Composite' AS "TYPE_NAME"
       CONVERT(INT, '115') AS "OBJECT_TYPE",
       'Business Rule' AS "TYPE_NAME"
       CONVERT(INT, '118') AS "OBJECT_TYPE",
       'Business Rule Folder' AS "TYPE_NAME"
 --  Get every object in the application
 ObjectID AS
 -- This is almost the end of the road, but it doesn't take into account implicit security
 -- Stop here if that isn't important
 FinalCTE AS
       --OT.TYPE_NAME AS "Type",
       --  If the OBJECT_TYPE = 50 then it is a user-defined or custom dimension
       --  so do a subquery to pull the dimension name
         ELSE (SELECT D."Dimension"
                 FROM Dimensions D
                 WHERE O_ID.OBJECT_ID = D.OBJECT_ID)
       END AS "Type",
       O_ID.OBJECT_NAME AS "Object",
       -- Subquery to get user or group type
               FROM HSP_OBJECT OA
           WHEN 5 THEN 'User'
           WHEN 6 THEN 'Group'
       END AS "Security Type",
           WHERE OA.OBJECT_ID = AC.USER_ID) AS "User/Group Name",
           WHEN 1 THEN 'Read'
           WHEN 2 THEN 'Write'
           WHEN 3 THEN 'Write'
           WHEN 4 THEN 'Launch'
           WHEN -1 THEN 'Deny'
       END AS "Read/Write",
         WHEN 0 THEN '"' + O_ID.OBJECT_NAME + '"'
         WHEN 5 THEN '@CHI("' + O_ID.OBJECT_NAME + '")'
         WHEN 6 THEN '@ICHI("' + O_ID.OBJECT_NAME + '")'
         WHEN 8 THEN '@DES("' + O_ID.OBJECT_NAME + '")'
         WHEN 9 THEN '@IDES("' + O_ID.OBJECT_NAME + '")'
        END AS "Hierarchy function"      
     FROM ObjectID O_ID
 --  Figure out what the relationship is between users and groups
 --    All users in all groups
 SuperSet AS
       O1.OBJECT_NAME AS "Group",
       O2.OBJECT_NAME AS "User"
       ON G.USER_ID = O2.OBJECT_ID  
 --  Just the users in the specified group(s)
 --  NB -- This could be expanded to multiple groups if need be
 SpecificGroup AS
       O1.OBJECT_NAME AS "Group",
       O2.OBJECT_NAME AS "User"
       ON G.USER_ID = O2.OBJECT_ID  
 -- Use an IN statement with a subquery to limit the users from the SuperSet CTE to the users in the
 -- SpecificGroup CTE
 UsersInGroups AS
     FROM SuperSet S
     WHERE S."User" IN (SELECT "User" FROM SpecificGroup)      
 -- Use an IN statement with a subquery against a DISTINCT to limit the groups from the SuperSet
 -- CTE.  This will return all of the inherited groups.
 GroupsInGroups AS
        FROM SuperSet S
        WHERE S."User" IN (SELECT "USER" FROM SpecificGroup)
 -- Get the security that is specifically assigned to users
 -- Use an IN statement with a subquery to limit the users from the FinalCTE CTE to the users in the
 -- SpecificGroup CTE
 UserDefinedSecurity AS
       F."Security Type",
       F."User/Group Name",
       'User-assigned' AS "Parent Group",
       F."Hierarchy function"
   FROM FinalCTE F
        "Security Type" = 'User'
        AND F."User/Group Name" IN (SELECT "USER" FROM SpecificGroup)
 --  Get the security that is specifically assigned to groups
 --  The join between the CTE UsersInGroups and FinalCTE is the key to implicit security
 GroupDefinedSecurity AS
       F."Security Type",
       G."Group" AS "User/Group Name",
       F."User/Group Name" AS "Parent Group",
       F."Hierarchy function"
   FROM FinalCTE F
   INNER JOIN GroupsInGroups G
     ON G."Group" = F."User/Group Name"
 --  UNION the explicit to the user and the implicit via a group security
 UserAndGroupDefinedSecurity AS
   FROM UserDefinedSecurity  
   SELECT * FROM GroupDefinedSecurity
 --  Convert the output to SECFILE.txt format
 ImplictandExplicitSecurity AS
        CASE "Parent Group"
            WHEN 'User-assigned' THEN "User/Group Name"
            ELSE "Parent Group"
        END AS "User/Group Name",
   CASE "Read/Write"
       WHEN 'Read' THEN 'Read'
       WHEN 'Write' THEN 'ReadWrite'
       WHEN 'Deny' THEN 'None'
       ELSE "Read/Write"
   END AS "Permissions",
   "Hierarchy function" AS "AccessFlags",
   CASE "Type"
       WHEN 'Form' THEN 'SL_FORM'
       WHEN 'Composite' THEN 'SL_COMPOSITE'
       WHEN 'Business Rule' THEN 'SL_CALCRULE'
       WHEN 'Business Rule Folder' THEN 'SL_CALCFOLDER'
       ELSE ''
   END AS "Artifact Type"
   FROM UserAndGroupDefinedSecurity
    --"User/Group Name" || ',' || "Object" || ',' || "Permissions" || ',' || "AccessFlags" || ',' || "Artifact Type" AS "SecFile"
    "User/Group Name" + ',' + "Object" + ',' + "Permissions" + ',' + "AccessFlags" + ',' + "Artifact Type" AS "SecFile"
FROM ImplictandExplicitSecurity

secfile.txt as generated by the query


It’s ready to be read right into Planning via importsecurity.cmd just as soon as you copy and paste the contents into secfile.txt.  You’re welcome.

Don’t want just part of the security, or want to change the scope of the extract and eventual migration?  Simply change or comment out the WHERE clause in the SpecificGroup CTE.  In this example it’s pulling all of the security for users and groups that end in “EMEA”.

The important bit you need to understand

This code is really nice because it uses HSP_USERSINGROUPS and the CTE (somewhat confusingly named) GroupsInGroups to figure out what other groups the planners in PLN_CalcTest_Consol_EMEA are in.  That’s why the output of secfile.txt is 24 lines long, not five.  Again, good luck in figuring that out if you have a complicated inheritance model.

And a slightly funny story

There’s an error in the previous post on this subject – a very minor one, but one that ate half my day.  I wrote that that post’s query output was 26 lines long.  And I only get 24 from this query.  Something was very obviously wrong as this query was short two rows.  Only it wasn’t.  Why wasn’t this query somehow (it is largely the same query) wrong but the last one right?  Because the last post’s output count is in fact….24 rows.  Arrrrgh.  

Almost at the end

We’ve covered three of the four pieces of the Compleat Planning Security Query:

Is there nothing Planning + SQL cannot do?  Other than make coffee?

Be seeing you.