Thu, Dec
5 New Articles

V6R1 CL: The Story Continues

  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
You'll find changes to the DCLPRCOPT, INCLUDE, and CMD commands and so much more!


Control Language (CL) has seen many significant enhancements in recent releases. With V5R3, CL was enhanced with structured programming constructs such as DOFOR, DOUNTIL, and DOWHILE and the associated commands ITERATE and LEAVE; SELECT and the associated commands WHEN, OTHERWISE, and ENDSELECT; etc. V5R4 followed with additional enhancements, such as subroutines with the command CALLSUBR and the associated SUBR and ENDSUBR controls; data structures with the support of STG(*DEFINED) variables on the DCL; the ability to define compiler options in the CL source using DCLPRCOPT, etc. V6R1 continues this trend with several significant enhancements that impact the development and problem determination associated with CL applications.


Three of my personal favorites in the area of CL enhancements are the support for more compiler options with DCLPRCOPT, the ability to include CL source during compilation using the INCLUDE command, and the ability to specify compiler options with the CMD statement. These three enhancements should go a long way toward reducing the frequency of "oversight" errors when using CL.


Declare Processing Options (DCLPRCOPT)

The DCLPRCOPT command allows you to control the behavior of the CL compiler and do so from a source statement within the procedure or program being compiled. No longer do we have to remember what activation group to specify on the CRTBNDCL or, when binding to a *SRVPGM, use CRTCLMOD and then CRTPGM in order to reference a *SRVPGM or *BNDDIR. We can specify these, and more, on the DCLPRCOPT command within the source we are compiling. This capability to store compile options within the CL source is similar to ILE RPG's H-spec capability and ILE COBOL's PROCESS statement.


While DCLPRCOPT in V5R4 only supported the parameter Subroutine stack depth (SUBRSTACK), V6R1 supports the specification of Log commands (LOG), Allow RTVCLSRC (ALWRTVSRC), Text (TEXT), User profile (USRPRF), Authority (AUT), Sort sequence (SRTSEQ), Language ID (LANGID), Storage model (STGMDL), Default activation group (DFTACTGRP), Activation group (ACTGRP), Bind service program (BNDSRVPGM), and Binding directory (BNDDIR). This capability should greatly reduce the frequency of errors due to compile option mistakes, mistakes that can sometimes lead to very long problem determination procedures as many developers tend to look first at the source of a problem program, not the attributes of the program.


Here's an example of using DCLPRCOPT to specify that binding directory MYBNDDIR in library MYLIB is to be used when resolving procedure calls:




Include CL Source (INCLUDE)

The INCLUDE command allows you to include, into the current CL compilation, source statements from one or more other CL source members. This capability is similar to RPG's /COPY, COBOL's COPY, and C's #include support. We can now include both common data definition DCLs for simple variables, parameters, and data structures and common program logic directly into the main line of the CL procedure, a subroutine of the procedure, or entire subroutines. This enhancement should reduce the type of errors found when data and/or logic definitions exist in multiple locations and a change is needed to the data or logic. It's just too easy to forget some infrequently used program that has duplicated the data definition or logic processing. We will still need to recompile any programs that utilize the INCLUDE command, but that's a whole lot easier to manage than performing manual copy/paste procedures and then recompiling.


The INCLUDE command supports two parameters. The first, SRCMBR, allows you to specify what source member you want to include. The second parameter, SRCFILE, allows you to specify the source file to be used when locating the source member. The default SRCFILE is the source file specified on the CRTBNDCL or CRTCLMOD command.


This is an example of using INCLUDE to include CL source member MYDATADFN in source file QCLSRC of library MYLIB:




Related to this new include capability, the RTVCLSRC command has the new parameter Retrieve included source (RTVINCSRC). This parameter controls whether an INCLUDE statement should be retrieved (*NO) or the source statements referenced by the INCLUDE statement should be retrieved (*YES).


Command Definition (CMD)

Very similar to the DCLPRCOPT enhancement to control the behavior of the CL compiler, the CMD command now allows many of the parameters of the CRTCMD command to be specified within the source of the command being created. No longer do we have to remember what help panel group to specify on the CRTCMD or, when creating a command that is not supported in all environments, to specify the appropriate ALLOW values. We can specify these, and more, on the CMD statement within our source.


While CMD in previous releases only supported the parameter Prompt text or message ID (PROMPT), V6R1 supports the specification of Message file for prompt text (PMTFILE), Message file (MSGF), Text description (TEXT), Maximum positional parameters (MAXPOS), Where allowed to run (ALLOW), Mode in which valid (MODE), Allow limited users (ALWLMTUSR), Thread safe (THDSAFE), Multithreaded job action (MLTTHDACN), Validity checking program (VLDCKR), Prompt override program (PMTOVRPGM), Help identifier (HLPID), Help panel group (HLPPNLGRP), Help search index (HLPSCHIDX), Current library (CURLIB), Product library (PRDLIB), and Authority (AUT) on the CMD statement. This enhancement should greatly reduce the frequency of errors due to command creation mistakes.


Followng is an example of using CMD to specify that command prompt text is found in MYMSGF and that help panel group MYAPPHELP is to be used for command help text:




In addition to eliminating many mistakes in the creation of a command, the new option of *DYNAMIC on the PMTFILE parameter is a key enabler for the future that might be easily overlooked. Available on both the CRTCMD command and CMD, *DYNAMIC allows the prompt text for a command to be retrieved at run time rather than at compile time. The default value, *STATIC, maintains the previous method of embedding the prompt text at compile time.


For software providers that support multiple National Language Versions (NLVs), this *DYNAMIC capability means that rather than having one command in each secondary language library, they can now have one command in their product library and translated prompt text in each secondary language library that is retrieved through the jobs library list at run time. If the software provider then wants to add a new parameter to an existing command, they can, with one PTF, change the command definition and command processing program (CPP) in order to add that new parameter. In the case of i5/OS, this for instance enables the adding of a new OPTION parameter such as this...




...to an existing command with one PTF to the command and CPP rather than the 50+ PTFs (one for the CPP, one for each NLV) that would have been necessary in previous releases. This should encourage IBM, and other software providers, to be much more willing to PTF new command function into a release rather than waiting for the next release of the product. This potential should excite any user of the system. The new parameter's prompt text would be in English until the next release, but having the function available earlier may well be worth the inconvenience of English text (and if it's not, then don't apply the PTF).


Close (CLOSE) Providing Improved Database File Access

 The CLOSE command allows you to explicitly close a file that was implicitly opened with a previous RCVF operation. That may not seem like a big item at first, but the beauty of CLOSE is that it resets the database file so that the next RCVF operation to the closed database file will cause the file to be reopened. What that means is that, after all of these years, we finally have a way to reset End-Of-File within a CL program. No more need to write and call secondary CL programs in order to repetitively loop through the entire reading of a file. Now we can directly reset end of file within a CL program, and that is good news for many CL developers: less programs and less code.


An example of using CLOSE to allow a CL program to repeatedly read all records of the file MYLIB/MYFILE is shown below. The program, after encountering each end of file message (CPF0864: "End of file detected for file &1 in &2"), closes the file and then retrieves the job's end status. If a controlled end of the job, the subsystem the job is running in, or the system itself is found, the program ends. Otherwise, the program reads MYFILE again by resuming the DoWhile loop and the RcvF operation.



DclF       File(MyLib/MyFile) OpnID(MyFile)              

Dcl        Var(&CnlSts) Type(*Char) Len(1) Value('0')    


/* Loop until a controlled cancel of job or subsystem        */

DoWhile    Cond(&CnlSts = '0')                            

           RcvF OpnID(MyFile)                            

           MonMsg MsgID(CPF0864) Exec(Do) /* Monitor for EOF */

                  Close OpnID(MyFile)                    

                  RtvJobA EndSts(&CnlSts)                

                  Iterate      /* Return to top of DoWhile   */


           /*                                                */

           /* Process record from MyFile                     */

           /*                                                */





Note that if you decide to run the above program, you need to create the file MYFILE in library MYLIB. The command CRTPF MYLIB/MYFILE RCDLEN(80) is sufficient to create the file, and you can then use a utility such as DFU to load a few records into the file. The program, once called, will run in a continuous loop. If run interactively, the program can be canceled with a System Request option 2. If run in batch, the ENDJOB command can be used.                                               

And Much, Much More

Besides the new capabilities reviewed above, there are also many additional new and changed CL capabilities related to CL application development. Some that may be of special interest are these:


•·         DSPPGMREF now supports returning file usage information on *QRYDFNs. This can be quite useful for impact analysis if users are allowed to create queries and you need to change file layouts. *QRYDFNs created on V6R1 will automatically provide DSPPGMREF the file usage information. *QRYDFNs migrated to V6R1 from earlier releases will need to be processed one time by an API in order to extract the file usage information. See the V6R1 Memo to Users for further information on this API.


•·         CPYSRCF allows you to retain source change date and member-level identifier when copying source members. This can be useful when utilizing many change management procedures. Along the same lines, CPYLIB and CRTDUPOBJ allow you to retain file and member-level identifiers when copying database files to a newly created file.


•·         CRTPGM and *SRVPGM entries added to a *BNDDIR allow you to specify when *SRVPGMs are to be activated. This can provide a performance improvement when initially calling a *PGM that is bound to several *SRVPGMs.


•·         ADDMSGD supports new Message data field formats (FMT) of *UTC, *UTCD, and *UTCT. These formats allow an application to work with UTC-based time values and have those values automatically converted to the time zone in effect for the current job when the message is displayed. The formats *UTC, *UTCD, and *UTCT correspond respectively to displaying both date and time, date only, and time only. In all cases an 8-byte system timestamp is sent as message data.


•·         In V5R4, the command definition statements PARM and ELEM supported a CCSID parameter, allowing a parameter to be defined as Unicode-enabled. This enabled characters from multiple languages to be specified concurrently for a parameter. In V6R1, many of the IFS-related commands now support a multi-lingual path name parameter.


That's a rather quick review of some of the V6R1 CL enhancements related to CL application development. There are, as with every release, also many new commands and changed commands that relate to specific application requirements. To get an idea of what else has changed, I suggest using the CL command finder function of the IBM i5/OS Information Center. Within the CL command finder, you will find the ability to list all new and all changed commands. Have fun with V6R1. There are a lot of very useful functions that you will find in this release.

More CL Questions?             

Wondering how to accomplish a function in CL? Send your CL-related questions to Bruce at This email address is being protected from spambots. You need JavaScript enabled to view it.. He'll see what he can do about answering your burning questions in future columns.

Bruce Vining

Bruce Vining is president and co-founder of Bruce Vining Services, LLC, a firm providing contract programming and consulting services to the System i community. He began his career in 1979 as an IBM Systems Engineer in St. Louis, Missouri, and then transferred to Rochester, Minnesota, in 1985, where he continues to reside. From 1992 until leaving IBM in 2007, Bruce was a member of the System Design Control Group responsible for OS/400 and i5/OS areas such as System APIs, Globalization, and Software Serviceability. He is also the designer of Control Language for Files (CLF).A frequent speaker and writer, Bruce can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it.. 

MC Press books written by Bruce Vining available now on the MC Press Bookstore.

IBM System i APIs at Work IBM System i APIs at Work
Leverage the power of APIs with this definitive resource.
List Price $89.95

Now On Sale



Support MC Press Online

$0.00 Raised:

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: