Mass Editing of QVW Script (2024)

Summary: In this post I describe a process using freely available tools to apply changes to all scripts in a set of QVW files.

So you have a lot of QVWs. And now you are asked to identify and make updates to all scripts to support changes such as:

  • A change in QVD or other file naming.
  • Changes in file paths due to a server move or directory restructuring.
  • Updating file paths to use variables.

If you are super cool, all those itemsare represented by variables, changes are handled by updating a single include file and you can relax and stop reading this post. For the rest of us, read on.

You can scan and search all your script using my Script Repository tool. That will allow to identify where changes are required, but do you have time to edit every QVW and make the changes? Easy enough for a few, but what about when you have dozens?

QlikView Desktop has a useful facility we can leverage for mass changes; the “-prj” folder. If a folder named qvwname-prj (case sensitive) exists in the same folder as the QVW, when the QVW is saved, QV Desktop will write a set of text files representing the structure of the QVW to the -prj folder. One of those files is “LoadScript.txt” which contains the load script.

When QV Desktop opens a file, it checks for the existence of a companion -prj. If found, it populates the QVW with the contents of the files in the -prj. If we change one of those files, for example “LoadScript.txt”, that change will be inherited by the QVW.

Let’s walk thorough a scenario where we can utilize this feature to update the scripts of an entire set of QVWs. I’ll utilize free tools thatwill make the process easier.

My sample problem is this: I have inconsistent QVD naming conventions. We’ve decided that “DimCustomer.qvd” shall henceforth be known simply as “Customer.qvd”. I’ll need to update the script that generates the QVD as well as all readers of the QVD.

I will accomplish this update in four steps:

  1. Create -prj folders for all QVWs.
  2. In the “LoadScript.txt” files replace “DimCustomer.qvd” with “Customer.qvd”.
  3. Rebuild the QVWs with the updated -prj.
  4. (Optional) Delete the -prj files.

The sample I’ll use for this post is relatively small to keep the demo simple. But I’ve used this technique to process hundreds of QVWs at a timeincorporating several different script edits.

I have a directory of QVWs that looks like this:

In the SubFolder “Loaders”,there areadditional QVWs.

I’ll need a -prj folder for each QVW. I can create the -prj manually, but this is where I can leverage the PrjTool to make life easier. You can download the PrjTool from the Tools section of this site. (Note: If you received a copy of PrjTool from the Masters Summit, please download this newer version as it contains important updates.)

PrjTool requires a Directory as input and the selection of one of three functions:

  • BuildPrj: For all QVW files found in the specified Directory, create a -prj folder. This includes opening and saving the QVW to populate the -prj.
  • CreateFromPrj: For all -prj folders found in the specified Directory, open and save the QVW to update the QVW with contents of the -prj. If no QVW exists, a new one will be created.
  • DeletePrj: Delete all -prj folders found in thespecified Directory.

I’llstart by specifying the Directory that holds our QVWs and selecting the BuildPrj function. Press the Execute button and the script will launch. The execution may take some time as each QVW has to be opened and saved. Good time to go for a coffee.

When the execution completes the log window will be filled with messages listing the -prj folders created by the tool.

If we examine the directory again we will see the new -prj folders.

Our next task is to edit the LoadScript.txt files. We can use any editor capable of searching and replacing across multiple files. For this demo I will use the free NotePad++ editor. From the NotePad++ menu, launch “Search” , “Find in File”. In the search dialog I specify the Directory and the search and replace strings. I’ll also limit the search to the LoadScript.txt files.

After pressing “Find All”, I’ll get a list of search results. I can double click any of the results to open the file for further examination.

When I’m satisfied that I’m going to make the correct updates, I again launch “Find in Files” and press “Replace in Files” to perform the update.

Now I’ll use the PrjTool again to update the QVWs with the updated -prj files. I run the tool again, this time selecting the “CreateFromPrj” function. Again, if you have a lot of large QVWs, be patient while the tool runs. The resulting log messages will inform me of the updates.

We’re done! All QVWs now contain the updated load script. Optionally we can run the tool again with the “DeletePrj” function to delete the generated -prj folders.

You should always perform this kind of mass update activity on copies of QVWs and audit the results. Also, never use -prj folders in production. Server reloads do not recognize -prj folders.

-Rob

Mass Editing of QVW Script (2024)
Top Articles
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 5842

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.