The goal of every QlikView developer is to do as little work as possible.  When you notice that you are writing the same instructions in multiple app scripts, the notion of re-use is a red flag that flies with great fervor.  QlikView’s Include statement provide just such an ability.

The advantages of re-using scripts between multiple apps has several advantages:

  • Complex scripts can be used by multiple people with superficial knowledge of the script’s logic.
  • Include files ensure business process consistency when performing similar actions across multiple apps.
  • Include files expedite script maintenance because the script need only be updated once (in the Include file) and all scripts pointing to the file will automatically incorporate the updates the next time a Reload is executed.

As with anything in life, every “pro” must be accompanied by a commensurate “con”.  In this case, the risk of using Include files to re-use script code lies in the fact that the file containing the script must remain in the same location and the file’s name must remain unchanged.  If either of these two events occurs, the portion of the script pointed to by the Include statement will not execute.

The problem is that QlikView will not present any form of complaint if this file cannot be located.  Granted, other processes dependent on the Include script may fail and generate fault messages, but if the Include script has no successor dependencies the script will load without any apparent issue.

Making the script fail

To ensure a fault message is generated when an Include file cannot be located, change the INCLUDE statement to a MUST_INCLUDE statement.

Example:

(The file containing the recycled code is named “MyAwesomeCode.qvs”)

Original Script Code:

$(Include=MyAwesomeCode.qvs);

Updated Script Code:

$(Must_Include=MyAwesomeCode.qvs);

Instead of the script load proceeding without an apparent error, the program will generate a Script Error notifying you of the issue and listing the name of the unobtainable Include file.

MustInclude1