
This blog will guide you through scanning a source physical file and explain the potential advantages of performing this scan.

Here are some tools you can build using the scan technique:

A library can contain multiple source files, and each source file may include several members, as shown below:

IBM provides Catalog files that contain metadata about system objects, such as their names, types, creation dates, and other attributes. These files help in managing and querying object information efficiently. Some Catalog file are as below:

Lets start, on how to perform scan step by step:
Retrieve all member names from the source physical file and store them in a temporary database in QTEMP.

To do this use below query:

Next step is to read this file and process each record:

How to process each record:
- Read 1st record from file which is o/p of step 1 and create alias on record 1 (i.e. member1).
- By leveraging an alias, the complete source code of the member will be copied into a temporary table
- Now that the entire source of Member 1 is available in the file, we can read each record and perform operations as needed.


Sample queries which can be run on member is given below:

All this can be achieved by using REGEX as shown below:

It’s up to the developer how to use this technique. You can build tools like a static code analyser, a code modifier, or even an impact analysis tool.
Happy Coding…