ARIS Report Scripting - Best Practices
ARIS Report Scripting - Best Practices
Contents
Contents ..................................................................................................................... I
1 Introduction .......................................................................................................... 1
I
REPORT SCRIPTING - BEST PRACTICES
1 Introduction
This document does not represent a comprehensive policy to the development of reports in the ARIS environment,
but it describes a series of "best practices" and "mistakes" in the report development, which base on experience.
Adherence to the guidelines described in this document does not necessarily secure the required and necessary
running time and memory features, because this depends on the application of the reports to be developed.
Completed reports should always be tested on their memory performance and quality.
1
REPORT SCRIPTING - BEST PRACTICES
Example:
var g_data_objDef;
var g_data_models;
...
function find() {
...
2
REPORT SCRIPTING - BEST PRACTICES
...
function find() {
...
3
REPORT SCRIPTING - BEST PRACTICES
Example:
function find() {
...
}
...
In the above example the variables "data_objDef" and "data_models" are implicitly defined globally
and therefore live up to the end of the report.
function find() {
...
}
...
4
REPORT SCRIPTING - BEST PRACTICES
Example:
main();
function main() {
if(containsMainSystem) {
// only result will be used
...
}
}
...
If, as in the example above, only the processing result of a larger amount of data is required for further processing, it
should be examined whether it is absolutely necessary to keep the entire data set in the "main" function.
5
REPORT SCRIPTING - BEST PRACTICES
Possible solutions here could be the outsourcing of the search in the "containsMainSystem" function or the
release of the search result. Details are described in the Clean-up and Using functions.
function main() {
if(containsMainSystem) {
// only result will be used
...
}
}
...
main();
function main() {
if(containsMainSystem) {
// only result will be used
...
}
}
...
function containsMainSystem() {
...
6
REPORT SCRIPTING - BEST PRACTICES
2.2 Clean up
In the development of reports, which operate on larger data sets it is important to release information that is no
longer used. In particular this is relevant for global variables.
The following sections describe the main procedures.
7
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function find() {
...
...
}
}
...
...
function find() {
data = null;
...
...
}
...
8
REPORT SCRIPTING - BEST PRACTICES
In the example above the data returned by the search processing are no longer needed after execution of function
“checkSearchResults()” and should therefore be released by setting the reference variable to "null".
9
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function main() {
if(data[i].TypeNum() != Constants.OT_ACTION) {
continue;
}
...
}
}
...
...
function main() {
if(data[i].TypeNum() != Constants.OT_ACTION) {
data[i] = null;
continue;
}
...
}
}
...
...
10
REPORT SCRIPTING - BEST PRACTICES
...
function main() {
process(data[i]);
data[i] = null;
}
}
...
11
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function main() {
// process actions
var actionsDefs = activeDatabase.Find(
Constants.SEARCH_OBJDEF,
Constants.OT_ACTION);
...
// process systems
var actionsDefs = activeDatabase.Find(
Constants.SEARCH_OBJDEF,
Constants.OT_APPL_SYS_TYPE);
...
}
...
12
REPORT SCRIPTING - BEST PRACTICES
...
function main() {
function processActions(activeDatabase) {
// process actions
var actionsDefs = activeDatabase.Find(
Constants.SEARCH_OBJDEF,
Constants.OT_ACTION);
...
fnction processSystems(activeDatabase) {
// process systems
var actionsDefs = activeDatabase.Find(
Constants.SEARCH_OBJDEF,
Constants.OT_APPL_SYS_TYPE);
...
function processProcSupportUnits(activeDatabase) {
// process process support units
var actionsDefs = activeDatabase.Find(
Constants.SEARCH_OBJDEF,
Constants.OT_PROCESS_SUPPORT_UNIT);
...
...
13
REPORT SCRIPTING - BEST PRACTICES
14
REPORT SCRIPTING - BEST PRACTICES
3 Working on reports
The following sections deal with simple and basic tools and guidelines for report development.
Example:
Filter ?
Report ?
Entire Method
Filter ?
Report ?
Report Method
15
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function main() {
}
...
In the example above all attributes of the object are read into memory by calling data[i].Attribute(
Constants.AT_NAME, Constants.LCID_GERMAN), and released from memory not until discarding of the
object from memory.
16
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function main() {
}
...
17
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function main() {
var xlsTemplate=Context.getFile(
"xxx.XLT",Constants.LOCATION_SCRIPT);
// process sheet
...
}
...
...
function main() {
var xlsTemplate=Context.getFile(
"xxx.XLT",Constants.LOCATION_SCRIPT);
// process sheet
...
}
...
18
REPORT SCRIPTING - BEST PRACTICES
...
function main() {
// process sheet
...
}
...
...
function main() {
// process sheet
...
}
...
19
REPORT SCRIPTING - BEST PRACTICES
3.4.1 Database.clearCaches()
If a variable is no longer in scope, the referenced data in the "Report OM" related to the variable are released.
This, however, does not mean that the referenced data in the "ARIS-OM" are also released.
To release them, too, the database method "clearCaches()" must be called explicitly. But this is only necessary if the
report holds large amounts of data such as a group with all their models, objects,...
Attention:
In combination with the use of the database method "Save()" and the parameter “SAVE_ONDEMAND”
(compare: ArisData.Save()) it have to be ensured that all desired objects have been stored in the database before they
are removed from the cache by using "clearCaches()".
20
REPORT SCRIPTING - BEST PRACTICES
Example:
...
}
...
21
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function getUniqueList(p_objList) {
p_objList = p_objList.sort();
if (p_objList.length > 1) {
var i = p_objList.length-1;
for (i = p_objList.length-1; i > 0; i--) {
if (p_objList[i].IsEqual(p_objList[i-1])) {
p_objList.splice(i,1);
}
}
}
return p_objList;
}
...
...
function getUniqueList(p_objList) {
return ArisData.Unique(p_objList);
}
...
In general, it should always be considered whether to call the method is really necessary and whether the list can
contain any duplicate at all.
The call of this method makes sense for example in the following cases:
But it makes no sense for example in the following cases because these lists can implicitly contain no duplicates:
22
REPORT SCRIPTING - BEST PRACTICES
3.4.3 ArisData.Save()
This method manages the storage property on changing accesses on ARIS elements.
• SAVE_AUTO: (Default setting) All changes are optimally stored in the database. In contrast to
SAVE_IMMEDIATELY, objects are stored in larger blocks just early enough before the next read operation
occurs. Resets "SAVE_ONDEMAND" to "SAVE_AUTO"
• SAVE_IMMEDIATELY: All changes will be stored immediately into the database. Resets "SAVE_ONDEMAND" to
"SAVE_IMMEDIATELY".
• SAVE_ONDEMAND: All subsequent changes to ARIS elements will be stored to the database when
Save(Constants.SAVE_NOW) is invoked for the next time.
• SAVE_NOW: Stores all changes after Save(Constants.SAVE_ONDEMAND). The storage mode
SAVE_ONDEMAND remains
It is only necessary to use the adapted storage behavior (SAVE_ONDEMAND) if large amounts of data should be
stored. In this case you should also try to separate reading and writing sections in your report as far as possible.
If you decide to use the adapted storage behavior (SAVE_ONDEMAND) in your report we suggest using it for the
whole report and the concrete storing (SAVE_NOW) at all relevant times.
Additionally you should call ‘SAVE_NOW’ at the end of the report (and maybe also at further times when you are not
really sure of report behavior) to ensure correct saving.
If components, such as ARIS Merge are used in a report the data is (internally) automatically stored before executing
to ensure that all data is available for this component.
In general save operations of models are expensive. Therefore models should be stored as one block – if possible it
even makes sense to store multiple models (e.g . up to 50 models) in one block
Ensure that you don’t delete and create the same occurrence or item in one storage block (not a must)
Attention:
• Unsaved items will not be found for example by Database.Find() and similar commands.
• In combination with the use of the database method "clearCaches()" (compare: Database.clearCaches())
and the adapted storage behavior (SAVE_ONDEMAND) it have to be ensured that all desired objects have
been stored in the database before they are removed from the cache.
• If you work on databases which you have opened via "ArisData.openDatabase()" you have to
change the storage behavior of this database. You can do this by calling
“<database>.getArisData().Save()”
• “ArisData.Save()” only manages the behavior of the login database.
23
REPORT SCRIPTING - BEST PRACTICES
Example:
...
ArisData.Save(Constants.SAVE_ONDEMAND);
...
/* Block of changes which should be stored */
...
ArisData.Save(Constants.SAVE_NOW);
...
ArisData.Save(Constants.SAVE_IMMEDIATELY);
...
24
REPORT SCRIPTING - BEST PRACTICES
Example:
...
function getAllGroups(p_oParentGroups) {
var oAllGroups = new Array();
...
25
REPORT SCRIPTING - BEST PRACTICES
This method offers a fast way to determine models contained in this group and (optionally) all its child groups where
the models need to match the given criteria.
Example:
...
26
REPORT SCRIPTING - BEST PRACTICES
This method offers a fast way to determine object definitions contained in this group and (optionally) all its child
groups where the object definitions need to match the given criteria.
Compare: Group.ModelList(…, ISearchItem p_searchSpec)
27
REPORT SCRIPTING - BEST PRACTICES
Example:
...
...
...
28
REPORT SCRIPTING - BEST PRACTICES
Example:
...
...
...
29
REPORT SCRIPTING - BEST PRACTICES
Example:
...
...
30
REPORT SCRIPTING - BEST PRACTICES
Example:
...
...
31
REPORT SCRIPTING - BEST PRACTICES
Additionally, the report flag "Opens dialogs" have to be deactivated, so that the report is available in the selection for
the scheduling:
32
REPORT SCRIPTING - BEST PRACTICES
3.4.13 ArisData.openDatabase()
You can log into the same DB as another user or with another filter or into further databases.
In this case don’t forget to close them afterwards by using “<database>.close()”.
try {
<your code which might throw exceptions>
}
catch(ex) {
var line = ex.lineNumber
var message = ex.message
var filename = ex.fileName
var exJava = ex.javaException
if(exJava!=null) {
var aStackTrace = exJava.getStackTrace()
for(var iST=0; iST<aStackTrace.length; iST++) {
message = message + “\n” + aStackTrace[iST].toString()
}
}
Dialogs.MsgBox(“Exception in file “+filename+”, line “+line+”:\n”+message )
}
33
REPORT SCRIPTING - BEST PRACTICES
4 Legal information
34
REPORT SCRIPTING - BEST PRACTICES
4.2 Support
If you have any questions on specific installations that you cannot perform yourself, contact
your local Software AG sales organization
(https://www.softwareag.com/corporate/company/global/offices/default.html). To get detailed
information and support, use our websites.
If you have a valid support contract, you can contact Global Support ARIS at: +800
ARISHELP. If this number is not supported by your telephone provider, please refer to our
Global Support Contact Directory.
ARIS COMMUNITY
Find information, expert articles, issue resolution, videos, and communication with other ARIS
users. If you do not yet have an account, register at ARIS Community.
TECHCOMMUNITY
On the TECHcommunity website, you can find documentation and other technical
information:
Use the online discussion forums, moderated by Software AG professionals, to ask questions,
discuss best practices, and learn how other customers are using Software AG technology.
Access articles, code samples, demos, and tutorials.
Find links to external websites that discuss open standards and web technology.
Access product documentation, if you have TECHcommunity credentials. If you do not,
you will need to register and specify Documentation as an area of interest.
35
REPORT SCRIPTING - BEST PRACTICES
36