Register

Anaplan Connect: Master Script

Prerequisites:

  • This article is designed for those more advanced with Anaplan Connect.
  • Utilizing CA Certificates is the best practice for Anaplan Data Integrations. The Master Script is best leveraged with CA Certificate authentication in the individual scripts for security purposes. If you would like to learn more about CA Certificates, click on the guide here which I co-authored. Note: Basic Authentication used for demo purposes.

Imagine this scenario: You have an Anaplan Connect environment setup to run your daily processes. There are dozens of scripts in your folder that you need to schedule for the same recurring cadence. What do you do? 

Solution: Create a Master Script! The Master Script method allows you to bundle your scripts together and schedule them all at once. For Anaplan Connect administrators, this saves time upfront when scheduling your scripts and reduces the maintenance effort.

Here's how: creating a Master Script is an easy process! This will require some attention to detail.

  1. In your Anaplan Connect folder, create your individual scripts (these are your scripts that execute actions, imports, processes etc.)
  2. It is recommended that all of your individual scripts are saved with no spaces in the filename, this makes administration easier
  3. Create your Master Script. "Call" is an operator which triggers each individual script to run. Note: It is best practice to name your batch files with no spaces as spaces can sometimes introduce errors when executing Anaplan Connect (see example Master Script below).
MasterScript Example:
Call Example1
Call Example2
Call Example3
Call Example4
Call Example5

Your folder should look something like this:

dsoomar002_0-1613080216531.png

  • Ensure your individual scripts, from the first through the second to last script, do not contain the "pause" command at the end of the script. The "pause" command triggers a break and requires a manual trigger/input to move onto the next command.

For the purposes of the Master Script, we will not use the "pause" command in the individual scripts. You may choose to keep the "pause" command in the final individual script being run for testing purposes, to be able to review the command log at the end of the execution. In my example, I have kept the "pause" command at the end of Example5 as that is the last script in my MasterScript, for testing.

Notice the differences below between Example1-Example4 vs. Example5 with regards to the "pause" command. Also, notice how both scripts maintain a consistent template and structure; this is also another best practice that should be leveraged with all scripts. More on this to come in a future article.

Example1-Example4 Scripts
set AnaplanUser= your@emailaddress.com:yourAnaplanpassword
set WorkspaceId="YourWorkspaceID"
set ModelId="YourModelID"
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set ProcessName="Your Process"
set Chunksize=1 
set Operation= -debug -service %ServiceUrl% -auth %AuthUrl% -process %ProcessName% -execute
set Credentials= -User %AnaplanUser%
rem *** End of settings - Do not edit below this line ***
setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%

You can see that Example1-Example4 scripts do not have the "pause" command, whereas Example5 does. Once you are done testing the script to ensure it runs, you can then remove the pause command. In an automated and scheduled environment, the pause command is not needed.

Example5 Script:
set AnaplanUser= your@emailaddress.com:yourAnaplanpassword
set WorkspaceId="YourWorkspaceID"
set ModelId="YourModelID"
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set ProcessName="Your Process"
set Chunksize=1 
set Operation= -debug -service %ServiceUrl% -auth %AuthUrl% -process %ProcessName% -execute
set Credentials= -User %AnaplanUser%
rem *** End of settings - Do not edit below this line ***
setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%
pause

A word of caution: notice that the Anaplan Connect script contains a section that says, "do not edit below this line". If you are not confident or comfortable in creating scripts, you should truly not edit below the line.

This article is designed for those more advanced in Anaplan Connect. Anaplan does not support any custom Anaplan Connect scripting in which changes are made below the line in individual scripts or to the Client.bat file. If you are not advanced or proficient with Anaplan Connect, it is recommended you follow the examples provided in the examples folder as part of your Anaplan Connect download for individual scripts.

Your end result should look something like this (sanitized console output):

dsoomar002_1-1613080216542.png

Use Cases:

  • Any new Anaplan Connect environment that will contain multiple scheduled individual scripts.
  • Any existing Anaplan Connect environment running multiple scheduled individual scripts, that could be grouped together.
  • Any Anaplan Connect environment that contains multiple individual scripts that may have actions or processes in different models, that cannot be grouped in the same script.

Things to Consider:

  • Sometimes, there are benefits to not running every script at the same time, whether it be the order of operations, data availability, or data flow. However, there are times when maintaining hundreds of Anaplan Connect scripts individually can become burdensome.
  • It is best practice to schedule your scripts to run during off-peak hours when most users are offline, typically scripts should be scheduled overnight. This will help you avoid performance issues during the day when most users are online and enable an effective and efficient Anaplan Connect execution.
  • Another best practice is to leverage naming conventions for your scripts, such as titling each script with the model associated with the script. The possibilities with this method open up organizing scripts according to the "business process." In other words, if you have actions or processes across your Anaplan Ecosystem, you can perform them in a systematic manner such that you can follow the flow. You may very well have several actions/processes in a model but perhaps you don't need to run them all. Breaking out scripts by business process and naming scripts accordingly can help organize your scripts in a systematic manner. 

Each Anaplan Connect implementation is different. Evaluate your needs to see if you are able to administer your Anaplan Connect environment with a MasterScript or multiple MasterScripts.

The content in this article has not been evaluated for all Anaplan implementations and may not be recommended for your specific situation.
Please consult your internal administrators prior to applying any of the ideas or steps in this article.
About the Author