Database Reference
In-Depth Information
9.5.3 Selecting Members
Several methods of retrieving member information are detailed in the previous chapter.
here we demonstrate using the one that allows us to get a list of members using our
familiar calc script member set functions. We retrieve and print the level-0 descendants
of the “East” member in Sample.Basic.
import com.essbase.api.session.IEssbase
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
essSvr = essHome.signOn('user', 'pass', false, null, 'embedded',
'ess_server')
essCube = essSvr.getApplication('Sample').getCube('Basic')
mbrSel = essCube.openMemberSelection('default')
mbrSel.executeQuery('<OutputType Binary <SelectMbrInfo
(MemberName)', '@RELATIVE("East", 0)')
mbrs = []
mbrSel.members.all.each { mbrs << it.name } // append to list
println mbrs
mbrSel.close() // must be closed or we get orphaned connections
essCube.clearActive(); essSvr.disconnect(); essHome.signOff();
In this query, we only ask that the IEssmember objects we get from Essbase have one
piece of data in them (membername). There are over 30 other items to choose from,
such as memberAliasname, ChildrenCount, and uDAList. We can put as many of these
as we need in the query, separated by commas.
9.5.4 Processing an Export File
This recipe piggy-backs on the previous one, referencing the member list retrieved there
while processing a data file. The Calcdat.txt data file we loaded to Sample.Basic in recipe
9.5.1 is in the same format as an Essbase export file, if the “column format” option were
not selected when the data was exported. here, we assume that we want to reload only
some of the data in the file. Suppose the database has undergone extensive updates dur-
ing the day, and the manager for all of “East” wants to go back to the day's starting point.
The format of the file makes this a little difficult. Data lines do not have a member of the
“market” dimension in them. rather, Essbase applies the data to the “market” member
most recently mentioned on a previous line. We can use this knowledge of the file for-
mat to figure out which data lines we need. The following code is meant to be pasted in
a script immediately below the code in the previous recipe.
inf = new File ("Calcdat.txt") // input file
outf = new File ("Calcdat_Filtered.txt") // output file
outf.delete() // make sure output file is empty
inf.withReader { outf.append it.readLine() + '\n' } // copy 1st
line from inf to outf
copying = false // flag indicating whether we are currently copying
lines
inf.eachLine { line ->
if (line[1] =~ /\d/) { //quick way to i.d. Product/Market lines
copying = (mbrs =~ line.tokenize('"')[2]) as Boolean //decide
whether to turn on the flag
}
if (copying) outf.append line + '\n' // copy line to outf
}
Search WWH ::




Custom Search