Creating IMS Projects
Overview
IMS Explorer for VS Code allows you to create IMS projects to execute SQL queries against IMS databases, run IMS type-1 and type-2 commands, and edit DBD fields and database definitions. Use the following steps to create IMS projects in the IMS Projects view and to work with SQL, command, and DBD files within those projects.
Step 1: Open the IMS Projects View
- In Visual Studio Code, open the IMS Projects view from the Activity Bar.
This view allows you to create, edit, and organize SQL, command, and DBD project files used with IMS databases.
Step 2: Create a New IMS Project
- In the IMS Projects view, click Create Project.
- Provide a project name when prompted.
The project appears in the view. You can create multiple projects to manage SQL files.
Step 3: Create SQL Files in the Project
- Right-click the new project and select New SQL File.
- Enter a name for your SQL file.
The file opens in the editor, where you can structure SQL queries.
Step 4: Import DBDs and PSBs from Catalog
- Right-click the project and select Import from Catalog. Or alternatively, select the Import from catalog button next to the project name.
- Select an IMS database connection to import from.
- Filter and select DBDs and PSBs to import.
- Optionally, choose to import referenced DBDs.
- Edit any project files as needed:
- Open SQL files to write or edit SQL statements.
- Open DDL or source code files to edit database definitions.
Imported DBDs and PSBs can be viewed and edited within the project. SQL syntax highlighting and validation are provided by the IMS Explorer extension. Note: Source and DDL views display a snapshot of the current state that can be edited within the editor. If you edit these files, the views will not automatically refresh another.
Step 5: Execute SQL Against an IMS Connection
- Ensure you have created an IMS database connection in the IMS Connections view.
- Select the IMS database connection you wish to execute the SQL query on in the status bar or by using the IMS Connections view.
- Run SQL directly from the SQL editor using the Run button at the top-right of the editor window.
- Query results appear in a results view where you can sort, filter, and download rows as CSV.
Executing SQL requires an IMS database connection. To create a connection, see Creating IMS Connections.
Step 6: Add IMS DDL Files (optional)
IMS projects support editing and executing IMS DDL statements to create or modify DBD and PSB definitions.
- In the IMS Projects view, right-click your project and select New SQL File.
- Enter a name for the file (for example,
create-dbd). - Write the IMS DDL statements in the file. The DBD definition (all
CREATE DATABASE,CREATE TABLESPACE, andCREATE TABLEstatements) must be submitted as one unit ending withCOMMIT DDL. The PSB definition must be submitted in a separate, subsequent run after the DBD has been committed and imported. - At the top of the file, select the IMS Connection CodeLens to associate an IMS database connection.
- Click the Execute button to run the DDL against the selected connection.
- After a successful
COMMIT DDL, issue anIMPORT DEFN SOURCE(CATALOG)command to activate the changes in IMS.
Note: The PSB program view must use
DFSCP001as the user PSB. For full details and code examples, see Editing and Executing IMS DDL.
Step 7: Add IMS Command Files (optional)
IMS projects also support IMS type-1 and type-2 command execution through a COMMAND folder.
Prerequisite: An IMS command connection must be configured in the IMS Connections view before you can run commands. See Creating IMS Connections.
- In the IMS Projects view, right-click the COMMAND folder inside your project.
- Select Add IMS Command File from the context menu.
- Enter a name for the file (for example,
db-status). - The file opens in the editor, ready for you to write commands.
You can create multiple command files to organize commands by task—for example, separate files for database commands, transaction commands, and program commands. Command files are plain-text files stored in your project folder and can be kept in source control alongside your SQL files.
For full details on writing and running commands, see Executing IMS Commands.