For the operating system batch file, you can use ESSCMD command return values to control the flow of scripts that the batch file executes.
An ESSCMD program returns an integer value upon exiting. This value represents the status of the last executed command. You can set up your batch file to test for this value, and if the test fails, branch to a response. For information about handling errors in script files, see Handling Command Errors in a Script File.
For example, a batch file could contain three scripts: an ESSCMD batch file that loads data, a calc script, and a report script. If the load batch file fails, the calculations and reporting also fail. In this case, it would be best to stop the batch file and correct the error. If your batch file tests for the return value of the load process, and this return value indicates failure, the batch file can jump to the end of the file and stop or execute some other error-handling procedure, rather than attempting to calculate data that did not load.
The following example shows a Windows operating system batch file and the contents of one of the ESSCMD scripts it runs, LOAD.SCR. Because error-checking requirements vary, the syntax in this example may not correspond to that of your operating system. See your operating system documentation for error checking in batch files.
ESSCMD LOAD.SCR If not %errorlevel%==goto Error ESSCMD CALC.SCR If not %errorlevel%==goto Error ESSCMD REPORT.SCR If not %errorlevel%==goto Error Echo All operations completed successfully EXIT :Error Echo There was a problem running the script
Sample Script: Scheduling Report Printing
Suppose you need a file that:
Logs in to Essbase Server.
Selects an application and database.
Assigns reports that output to files for later printing.
Exits ESSCMD.
The following script file does the job:
LOGIN "Poplar" "TomT" "Password"; SELECT "Sample" "Basic"; RUNREPT 2 "REP1" "REP1.OUT"; RUNREPT 2 "REP2" "REP2.OUT"; RUNREPT 2 "REP3" "REP3.OUT"; EXIT;
On Windows, SAMPLE3.SCR is available in \ARBORPATH\APP\SAMPLE\BASIC. On UNIX, SAMPLE3.SCR is in /$ARBORPATH/app/Sample/Basic.