About CL : IBM i Control Language
IBM i Control Language (CL) is a powerful scripting language for the IBM AS/400, IBM iSeries and IBM i Systems. It's got roots in the older IBM Job Control Language and it works as a simple way to script commands, instructions and other functions into an easy-to-understand programs. Sometimes we can create simple business functions purely in CL - without the need for more complex RPG logic.
- A CL source program is a set of CL source statements that can be compiled into either an original program model (OPM) program or an Integrated Language Environment® (ILE) module.
- A CL program or CL procedure is a group of CL commands that tells the system where to get input, how to process it, and where to place the results.
- The program or procedure is assigned a name by which it can be called by other procedures or bound into a program and run.
- As with other kinds of procedures, you must enter, compile, and bind CL source statements before you can run the program or procedure.
- When you enter CL commands individually (from the Command Entry display, for instance, or as individual commands in an input stream), each command is separately processed.
- When you enter CL commands as source statements for a CL program or procedure, the source remains for later modification if you choose; the commands are compiled into a module if you use the ILE compiler. This module remains as a permanent system object that can be bound into other programs and run. Thus, CL is actually a high-level programming language for system functions.
- CL program or procedure ensure consistent processing of groups of commands.
CL Programming for Beginners
If you’re brand new to programming and want a gentle, practical introduction to the IBM‑i ecosystem, this CL Programming course is an ideal starting point. We take you from the absolute basics to a solid working understanding of how Control Language operates on the system, all at a pace designed for true beginners.
For experienced software developers who are expanding their skillset, this course offers a straightforward way to add CL to your toolkit. You’ll quickly see how CL fits into the broader IBM‑i workflow and how it can streamline automation, job control, and system operations. Even if you already know other languages, you’ll find plenty of value here.
If you’re an old‑school RPG programmer, this course will help you broaden your programming style and deepen your understanding of how CL complements RPG applications. Many RPG developers use CL every day without ever exploring its full potential and this course fills in those gaps and strengthens your overall IBM‑i proficiency.
And if you’ve dabbled in CL before but never taken the time to explore its more advanced features, this training is absolutely for you. We’ll walk through practical examples, real‑world scenarios, and techniques that help you write cleaner, more powerful, and more maintainable CL programs.
Module Content
IBM i Control Language (CL) is a powerful scripting language for the IBM AS/400, IBM iSeries and IBM i Systems. It's got roots in the older IBM Job Control Language and it works as a simple way to script commands, instructions and other functions into an easy-to-understand programs. Sometimes we can create simple business functions purely in CL - without the need for more complex RPG logic.
Welcome to IBM-i CL (Control Language)
Control Language is the command‑line scripting backbone of the IBM i, a tool that’s been shaping system operations since the AS/400 era and remains just as essential today. While RPG and COBOL focus on building applications, CL is designed for directing the system itself—running commands, managing errors, coordinating jobs, and interacting with objects and files. Its real power shows up in everyday work: automating backups, monitoring queues, streamlining repetitive tasks, and stitching together complex workflows with minimal effort. It’s quick to write, straightforward to troubleshoot, and deeply integrated into the platform. For anyone administering or developing on IBM i, skipping CL is like trying to operate the system without the controls that make it all run smoothly.
Control Language (CL) is a set of commands used to control operations and request system-related functions on the IBM i System, and on the earlier generation AS400 and iSERIES machines. The purpose of CL is comparable to Job Control Language (JCL) on mainframe computers, but CL offers greater functionality.
Ever asked yourself, "what is CL?" - or - "Is AS400 CL the same as iSeries CL?" - or - "Does old CL work on modern IBM i Systems?" then let's have a quick look at what CL is and what it's for...
Control Language (CL) has a clean, command‑driven structure that’s easy to read once you get used to its style. A CL program is made up of simple, English‑like commands, each one performing a specific task on the IBM i system. Most commands follow a verb–noun pattern, such as SNDMSG (Send Message), CPYF (Copy File), or DLTF (Delete File). Parameters are written in a keyword format, making the intent of each line very clear.
Programming with IBM-i CL (Control Language)
“Want to learn to program in CL on the venerable IBM i System?” becomes an inviting doorway into one of the platform’s most practical and empowering skills: mastering Control Language. CL is the glue that holds IBM i workflows together, orchestrating jobs, automating processes, and giving developers precise control over the system’s inner workings. Framing it this way signals that learners aren’t just picking up another syntax, they’re stepping into a tradition of rock‑solid engineering where even small scripts can have a big impact. It sets the tone for a journey that blends legacy wisdom with modern relevance, making the IBM i feel both historic and surprisingly alive.
CL Basics - It's time to write a very simple CL program and talk about the grass root basics of Control Language
CL Basics – Enhancing the Simple CL Program invites learners to take their first modest CL script and begin shaping it into something more capable, readable, and genuinely useful on the IBM i. This lesson builds on the foundational structure of a basic CL program and shows how small, thoughtful enhancements (like adding variables, leveraging messages, introducing simple logic, and improving flow) quickly transform a bare‑bones routine into a practical tool. It’s the moment where CL starts feeling less like a list of commands and more like a language you can use to automate real‑world tasks with confidence and clarity.
It's time to upload a file from our PC to our IBM-i System... and let's do these files two ways: one as a flat file, and one as a comma separated file.
Let's look at a slightly more complicated CL program: In this example we will write a Control Language Program which will look through an Output Queue and email the information to a lucky recipient.
It's time to look through the EMLOUTQ Control Language code, line by line, while slurping some tea. This lesson introduces you to a practical, real‑world example of Control Language (CL) programming on the IBM i. The video walks through a CL program named EMLOUTQ, explaining how it works, why it’s structured the way it is, and how each command contributes to the overall workflow. It’s designed to help beginners understand the flow of a typical CL program while giving more experienced developers a refresher on best practices. Programmers rejoice!
Control Language (CL) Program Template
Let's play with a Control Language (CL) program template. This template will fit as a starting point for most of your adventures when programming in IBM i CL Language
It's time to go through the CL TEMPLATE in all it's glory. We will look at the advantages of COPY/PASTING using RDi vs SEU. Then go through the entire template line by line discussing what it's doing and how it might fit your needs
Intermediate Control Language (CL) Programming
Control Language used the Declare CL Variable (DCL) command to define the Control Language (CL) program variables that are used in your CL program or ILE CL procedure. CL variables are used to store and update data and to receive parameters from another program on a call. CL variables are known by name only within the program that declares them.
Let's take an IBM i File (SQL Table), convert it to a comma separated spreadsheet (CSV) and email it!
This CONTROL LANGUAGE code example submits a job, then uses the program message queue to retrieve the information for that submitted job and share it back to the user. This is also added into my standard CL TEMPLATE - in this video I will walk you through the entire thing and explain how it works.
This CONTROL LANGUAGE code example sends a message to the USER. Waits for his/her reply and acts upon it. This is based on a request from a subscriber who wanted to "ask the user which iASP they want to use during their signon process" as part of a Proof of Concept. It's quick and dirty - but works great.
To list all files in an IFS (Integrated File System) folder using QSHELL on an IBM i system, you can use the "ls" command. Here's a simple example:
1. Open QSHELL:
QSH
2. Navigate to the desired directory:
cd /path/to/your/IFS/folder
3. List all files:
ls -a
If you want to list files with specific details or in a sorted manner, you can modify the command. For example, to list all files including hidden ones and sort them, you can use:
ls -al | sort
This command will list all files (-a), provide detailed information (-l), and sort the output.
This command checks whether a subsystem is active and returns a simple YES/NO answer in a CL variable. It uses the modern SQL SUBSYSTEM_INFO view, so it’s clean, fast, and easy to maintain.
In this lesson on CL programming for IBM i, we explore how to configure job descriptions to include an Initial Independent Auxiliary Storage Pool (iASP) group, a key step for applications that rely on data or libraries stored in an iASP rather than the system basic ASP (SYSBAS).