29
Fri, Nov
0 New Articles

ILE Is for CL Too

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Over the past 20 years, ILE for RPG has gone from being something new and startling to being almost legacy. Lots of us are now using RPG ILE concepts on a regular basis. But what about CL? Can it be ILE too?

Everyone knows about ILE for RPG.

Or at least everyone knows how to spell it, and a lot of people have adopted ILE practices as part of their regular routine. But I don't think the same can be said for CL. While most of us are now doing our programs in QRPGLESRC versus QRPGSRC, how many of those same people are still using QCLSRC for their Command Language source? My guess is quite a few.

But CL has an ILE side to it, one that has not gotten nearly as much press as its RPG cousin, and it's about time we took a look at it.

The Source File

The most obvious reminder that you're doing ILE is the naming of the source file where the programs are being kept.

On the RPG side of the house, we used to keep things in QRPGSRC, but now most people are doing their new program development in QRPGLESRC. And there's a CL parallel there. You can create a QCLLESRC source file, just like your RPG counterpart, and put your new CLs in it. This would be a 112-byte record versus the 92-character record that is being used currently in QCLSRC.

The object type in this new source file will be CLLE versus CL from the OPM type of source file.

One question that's liable to come up is "What do I do with my old QCLSRC CLs?" Many people will leave them in the current file and just put any new ones in the QCLLESRC file. The problem with that is now if you're looking for a CL and you don't know which of the two files it's in (and that can happen quicker than you think), then you have to check both source files. And that can get annoying. Unlike the RPG situation where you had to go through a conversion, you can just move your CLs from QCLSRC to QCLLESRC and recompile them in the new source file. That way, you always have everything together, and everything compiles as ILE. When you do the move, it will automatically reformat the CL into the 112-byte record and also automatically change the object type from CL to CLLE. What could be simpler?

Compile Commands

Of course, what makes a program ILE is not what source file it's stored in but rather the compile command that creates its object.

So, in RPG, OPM objects were created by the CRTRPGPGM command. It did not have any information in it about activation groups or binding, things that are central to the ILE experience.

And the situation is pretty much the same in CL. Up to this point, the default compile command was CRTCLPGM, and the object created was a straight OPM CL with no ILE icing.

To activate the ILE functionality in CL, you have to use either CRTBNDCL or the CRTCLMOD/CRTPGM combination. Both of these commands have a spot to determine if you want to use the default activation group (*DEFACTGRP = *YES or NO) or enter what activation group you want to use (*ACTGRP).

The interesting thing is that if you're still using PDM, then the commands associated with the 14 and 15 options are set based on the value of the object type. If it's CL, then it defaults to the OPM compile command, CRTCLPGM. But if you have set things up in QCLLESRC and the object type is CL, then the default for 14 is CRBNDCL, and for 15 CRTCLMOD.

Calling a CL Program from an RPG Program

Let's start with the simplest direction. You're in an RPG ILE program and you want to call an ILE CL program (or even an OPM CL program).

To do so, simply set up the Prototype D-spec (PR) for the name of the CL and the parms that need to be passed into it to get it to run.

D clname       PR        EXTPGM('clname')

D   Parm1           5    

D   Parm2           10  

Then add in the CALLP and call the CL.

CALLP 'clname' parm(Parm1: Parm2);

No changes or special setup are required. So it's pretty simple.

Calling a Subprocedure from a CL Program

There isn't nearly as much difference in the ILE version of CL as there is in RPG, which might be one reason that people haven't really embraced CL ILE the way they have RPG ILE.

But there's one new command that allows you to call a procedure from within an ILE CL program. This is the CALLPRC command. Basically, it looks like this.

Callprc prc('name of procedure')  +

       parm(&parm1 &parm2)       +

       rtnval(&field1)

Obviously, &Parm1k, &Parm2, and &Field1 must be defined in the CL.

The parms passed (&Parm1 and &Parm2) must match those of the PR in the procedure being called.

What is the rtnval (return value)? Good question. One parm that does not show up on this call is the parameter value parm, which defaults to "by reference." Hence, if you just use the defaults with this command, the parms that are passed are passed by reference, not value. As a result, any changes to &Parm1 and &Parm2 aren't returned to your CL program. This is just as it is in PHP, so if you're doing any coding in that area, this won't seem so weird. The upshot is that if you want to get any information back from the subprocedure, it will come back through the rtnval field (&Field1 in our example.

Need more than one field returned? Can't. You're limited to one field. But that field could be the concatenation of several fields, which you could then take apart once you get back in the CL.

Or you could just change the default on the parm value so that it sends things over by value, not by reference.

There's one very important caveat with respect to the CALLPRC command. If you're on a release below 6.1 and you put the CALLPRC command in a QCLLE, to get the CL to compile, you need to do CRTCLMOD and CRTRPG. Running just CRTBNDCL won't work. If, however, you're on 6.1 or above, using CRTBNDCL will work just fine.

Use as Directed

We still haven't answered the question of why more people don't use ILE techniques as much with CL as they do with RPG. And much of that may relate to how many people use CL.

CL is used mostly to run functions that aren't called directly from a menu or another app interface, things like reports, or SQL queries. And often that turns out to be a one-on-one type of situation; a given CL program will kick off one incidence of one or more output modules. You often just don't get the calling frequency that makes ILE worthwhile, cases where you're repeatedly calling a CL program from an RPG program or calling one or more subprocedures repetitively from a given CL program.

But the capabilities are there and available for you to use them. So keep an eye out for situations where this information could be of use. After all, CL and RPG both have specific situations that they're best for, so you might as well be ready to take advantage of it. Can't hurt.

David Shirey

David Shirey is president of Shirey Consulting Services, providing technical and business consulting services for the IBM i world. Among the services provided are IBM i technical support, including application design and programming services, ERP installation and support, and EDI setup and maintenance. With experience in a wide range of industries (food and beverage to electronics to hard manufacturing to drugs--the legal kind--to medical devices to fulfillment houses) and a wide range of business sizes served (from very large, like Fresh Express, to much smaller, like Labconco), SCS has the knowledge and experience to assist with your technical or business issues. You may contact Dave by email at This email address is being protected from spambots. You need JavaScript enabled to view it. or by phone at (616) 304-2466.


MC Press books written by David Shirey available now on the MC Press Bookstore.

21st Century RPG: /Free, ILE, and MVC 21st Century RPG: /Free, ILE, and MVC
Boost your productivity, modernize your applications, and upgrade your skills with these powerful coding methods.
List Price $69.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

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: