Essbase nested coding style examplesHere is a representative example of the nested coding style and the obvious benefits of employing such a method or style.. Initialize the API Login t
Trang 1Essbase nested coding style examples
Here is a representative example of the nested coding style and the obvious benefits
of employing such a method or style
Begin action 1
Begin action 2
Begin action 3
Perform action 3
End action 3
Begin action 4
Perform action 4
End action 4
End action 2
End action 1
This example should illustrate nicely why the nested style is the preferable code
writing style The next example will now put the previous example into Essbase
functionality context so it makes sense for you Most Essbase API functions usually must be started or opened and after completion of the task they must be ended
or closed
Initialize the API
Login to a server
Connect to a database
Open a database outline
Browse the outline
Close the outline
Open a report
Modify & save the report
Close the report
Disconnect from a database
Logout from the server
Terminate the API
Typically, the group of Essbase API calls or functions illustrated in the previous
example would be embedded in a VB subroutine so that it would actually look
more like this:
Sub BrowseOutlineAlterReport()
Initialize the API
Login to a server
Connect to a database
Open a database outline
Browse the outline
Close the outline
Trang 2Close the report
Disconnect from a database
Logout from the server
Terminate the API
End Sub
As you can see each Essbase API call has an ending or terminating call that must
be executed when the desired function has completed
Many code editors support the nested coding style by automatically indenting the next line of written code to the same indentation
as the previous line making nested code writing even easier The Visual Basic editor supports nested code writing and Oracle Essbase recommends you use the nested coding style when coding Essbase API functions
Essbase API function declarations
For your convenience your Essbase package comes with a VB code module that has all of the Essbase API functions and declarations already coded for you All you need
to do is add the module to your VB/VBA/COM+ project then start coding the API
calls and functions The file's name is esb32.bas and is a wonderful time saver
Trang 3As you can see in the previous screenshot, the Essbase supplied API declaration
module includes all of the necessary global variables and other API related
structures, as well as all of the API function calls What a nice thing to have!
How to code an API function
In the following example, we will code an Essbase API function that returns
database information into an Essbase private type structure named DBINFO:
Sub GetDataBaseInfo(Appname as String, DBName as String)
'Pass Application name and Database name to VB subroutine
Dim sts as ESB_STS_T 'Dimension return code variable
Dim hCtx as ESB_HCTX_T 'Dimension API handle context
Dim DbInfo as ESB_DBINFO_T 'Dimension DB information variable
sts = EsbGetDatabaseInfo (hCtx, Appname, DBName, DbInfo) 'Execute
'API function
If sts = ESB_STS_NOERR ' Test API function return code
Call DisplayDatabaseInformation 'Branch to new subroutine on
'satisfactory return code
End If
End Sub
After a successful call to the Essbase API EsbGetDatabaseInfo function, the DbInfo
structure will be populated with a variety of database information for the database
that was passed to the function The following is an example of the variable structure showing what database information is returned
Type ESB_DBINFO_T
DataFileCacheSetting As Long 'Data File Cache size database
Trang 4AppName As String * ESB_APPNAMELEN 'application name
Country As String * ESB_MBRNAMELEN 'country dimension
Category As String * ESB_MBRNAMELEN 'category dimension
CrPartition As String * ESB_MBRNAMELEN 'curr partition member
connected
End Type
There sure is a lot of information passed back from this call Now do you remember back a little bit that the variable name used in this API call is DbInfo? Yes, the
variable DbInfo, dimensioned using the variable structure above, now contains all
of the data that is listed in the ESB_DBINFO_T structure
To read any of the information returned in this structure, the steps are very easy
For instance, if you want to read how many users are connected to the database you returned the information from just code: variable = DbInfo.nConnects and your variable will now contain the number of users connected to the database You can
also use DbInfo.nConnects elsewhere in your program depending on how you
dimensioned it
Essbase API code sample blocks
It seems that for most good programmers, the only difference between programming languages is the syntax of the code itself Let's face it, logic is logic, and If means
If and End If means End If in all programming languages The syntax may vary
though, as we've all seen End If or End-If or ENDIF
Trang 5You have probably sensed that Oracle has created quite a product with Essbase and you are correct You have probably also gotten the idea that Oracle is very thorough and has prepared well written and easy to understand system documentation Well, we'd have to say you are correct once again The following is a picture of a typical
API function reference found in the Oracle Essbase API Reference that can be found online or accessed through the EAS tool
The following example is an exact representation of how the Essbase API Function
Reference looks, when accessed through EAS It also looks very similar when
accessed through the Internet