At times, it is mandatory to use the same set of code at different places in the script. To achieve this, developers will sometimes use a copy and paste approach. However, this makes it difficult to maintain and read the script. It is always advised to create subroutines and then simply call them as and when needed.
In the following recipe, we use subroutines to create QlikView Data (QVDs) file and store them in a specific folder. We also generate fields using various functions within the subroutines, which also helps in auditing the QVD files.