Control Language (CL) commands are the building blocks of CL programming. They allow you to interact with the system, manage files, control jobs, and perform various system management tasks. In this section, we will introduce you to the basic concepts of CL commands, their structure, and how to use them effectively.

Key Concepts

  1. Command Structure: CL commands follow a specific syntax and structure. Understanding this structure is crucial for writing effective CL programs.
  2. Command Types: There are different types of CL commands, each serving a specific purpose. These include file management commands, job management commands, and system management commands.
  3. Command Parameters: Most CL commands have parameters that you can set to customize their behavior. Knowing how to use these parameters is essential for controlling the commands' actions.

Command Structure

A typical CL command consists of the command name followed by one or more parameters. The general syntax is:

COMMAND_NAME PARAMETER1(VALUE1) PARAMETER2(VALUE2) ...

Example

CRTCLPGM PGM(MYLIB/MYPGM) SRCFILE(MYLIB/QCLSRC)

In this example:

  • CRTCLPGM is the command name, which stands for "Create CL Program".
  • PGM and SRCFILE are parameters.
  • MYLIB/MYPGM and MYLIB/QCLSRC are the values for these parameters.

Common CL Commands

Here are some common CL commands you will encounter:

Command Description
CRTCLPGM Create a CL program
DLTF Delete a file
SBMJOB Submit a job
WRKJOB Work with a job
DSPMSG Display messages
CHGJOB Change job attributes
ENDJOB End a job
WRKSYSSTS Work with system status
SAVLIB Save a library
RSTLIB Restore a library

Practical Example

Let's look at a practical example of using a CL command to create a CL program.

Code Example

CRTCLPGM PGM(MYLIB/MYPGM) SRCFILE(MYLIB/QCLSRC)

Explanation

  • CRTCLPGM: This command creates a CL program.
  • PGM(MYLIB/MYPGM): Specifies the library (MYLIB) and the program name (MYPGM).
  • SRCFILE(MYLIB/QCLSRC): Specifies the source file (QCLSRC) in the library (MYLIB) where the source code is located.

Exercise

Task

Create a CL program named HELLOCL in the library MYLIB using the source file QCLSRC.

Solution

CRTCLPGM PGM(MYLIB/HELLOCL) SRCFILE(MYLIB/QCLSRC)

Explanation

  • CRTCLPGM: Command to create a CL program.
  • PGM(MYLIB/HELLOCL): Specifies the library (MYLIB) and the program name (HELLOCL).
  • SRCFILE(MYLIB/QCLSRC): Specifies the source file (QCLSRC) in the library (MYLIB) where the source code is located.

Common Mistakes and Tips

  1. Incorrect Parameter Values: Ensure that the values you provide for parameters are correct and exist in the system.
  2. Syntax Errors: Double-check the syntax of your commands. Missing parentheses or incorrect parameter names can cause errors.
  3. Library and File Names: Make sure the library and file names are correctly specified and exist in the system.

Tip

  • Use the WRKLIB command to list all libraries and verify the existence of the library and files you are working with.

Conclusion

In this section, we introduced the basic concepts of CL commands, their structure, and how to use them. We also provided a practical example and an exercise to help you get started with writing CL commands. Understanding these basics will prepare you for more advanced topics in the upcoming modules.

© Copyright 2024. All rights reserved