24
Tue, Dec
1 New Articles

ILE CL

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

Brief: ILE is IBM's vision for the future of AS/400 application development. V3R1 includes a new compiler that brings CL into the family of ILE-compliant languages. This article tells you what you need to know to get started using ILE CL right away.

In V2R3 of OS/400, IBM introduced the concept of the Integrated Language Environment (ILE). One of the main reasons it developed this environment was to increase the performance of applications that use multiple programming languages. However, in that release the only ILE language available was ILE C/400. Now that V3R1 is available, new ILE languages are beginning to emerge, such as the long-awaited ILE RPG/400 and the soon-to-be-released ILE COBOL/400. But, without much fanfare, IBM has also rolled out another ILE language-ILE CL.

ILE CL is a significant step in the evolution of ILE since most applications contain some CL code along with another language. What this means is that you'll be able to write a single executable program that contains CL and andother language (e.g., RPG) RPG in the same program object. This has the potential to greatly increase the performance of certain types of application programs. In this article, I'll explain some of the benefits of ILE CL and show you how to implement it on your system. (For additional information on ILE, see "The Integrated Language Environment," MC, May 1993 and "An Introduction to Program Binding," MC, August 1994.)

ILE Benefits

One of the biggest advantages of ILE is that it significantly improves the performance of modular applications. The result from a design viewpoint is that you can break down your applications into small reusable modules without the overhead normally associated with external program calls.

This modular design means that your applications will tend to be easier to maintain and higher in quality. In a large program it's often difficult to determine the program logic. Smaller pieces of code are easier to understand. They're also easier to test and debug. If you make a change to a large program, you may inadvertently introduce errors in another part of the program. This is less likely to happen if you're only dealing with a single routine at a time. Also, compile time is often reduced since you may only need to recompile a single module rather than an entire program.

Another advantage of ILE is that IBM ships OS/400 with a collection of off-the- shelf ILE routines that you can incorporate into your programs. These routines are in the form of bindable APIs. Using these APIs, you'll have access to date and time routines, advanced mathematical calculations, and routines to perform dynamic screen manipulation. In the future, IBM will add new routines to this collection and you may be able to purchase sets of routines from third-party vendors.

ILE Concepts

Before jumping into the details of ILE CL, I'll give you a little background information on ILE concepts. When you compile a source member using an ILE compiler, it doesn't create a program. Instead, it creates a non-executable object called a module. You can then combine multiple modules created in different languages into a single executable program. There are two types of ILE programs you can create. One is the familiar program (*PGM) object and the other is an object type unique to ILE, called a service program (*SRVPGM). Both types of programs consist of one or more modules. Each module is made up of one or more procedures. A procedure is the result of binding a module into an ILE program using either the Create Program (CRTPGM) or Create Service Program (CRTSRVPGM) command.

With ILE CL, and most other ILE languages, a module can only contain one procedure. In this case, the module and procedure both have the same name. For this reason, the terms module and procedure are often used interchangeably. Currently, only an ILE C/400 module can contain multiple procedures.

When you use the CRTPGM command, you can specify the names of the modules you want to bind together. A copy of each module is created in the resulting program. This is called static binding (also known as bind by copy). With static binding, if two or more programs use the same module, then each program contains a copy of the module. This is a rather cumbersome method since you may end up with many copies of a module throughout your application. It can also make application maintenance difficult because, if you change a module, you'll have to update or recreate each program that uses that module.

A better approach is to create a service program. In this case, the module is only copied once. From then on, any ILE program can access the service program when it needs to execute one of its procedures. This is called dynamic binding (also known as bind by reference). Using this method, there is only a single copy of the executable code on the system. If you need to modify the code, you only need to replace it once in the service program and the programs that call it use the new copy without being updated or recreated.

ILE CL

Now that you've seen some of the benefits and concepts of ILE, I'll explain how ILE CL is implemented on the AS/400. ILE CL source code is stored in a source member with a member type of CLLE. After entering the source code, compile it with the Create CL Module (CRTCLMOD) command (or use option 15 against a CLLE member type in PDM).

To create an executable program you'll also need to run the CRTPGM command (or use option 26 against a *MODULE object in PDM). Here you specify the names of the modules used in the program. You can also specify the name of a service program that contains additional modules. If your program only has one module, you can combine this two-step process by using the Create Bound CL Program (CRTBNDCL) command (or running option 14 against a CLLE member type in PDM). This creates an executable program from a source member without requiring you to create the intermediary module object.

As an alternative to creating an executable program, you can place one or more modules into a service program. This gives other ILE programs access to those modules. To allow an ILE program to execute the procedures in a service program, specify the name of the service program in the BNDSRVPGM parameter of the CRTPGM command when you create the ILE program.

If a module already exists in a program or service program and you simply want to replace it with a newer version, you don't always have to recreate the program or service program. You can use the Update Program (UPDPGM) command to replace one or more modules of an ILE program with other modules on the system. Similarly, you can use the Update Service Program (UPDSRVPGM) command to replace modules of an ILE service program.

ILE CL Procedures

As I mentioned earlier, a procedure is created when you bind a module into an ILE program. You can think of these procedures as being similar to subroutines; they're small pieces of executable code within a program. When you want to execute one of these procedures from within a CL module (whether it's in the same program or an external service program) use the Call Bound Procedure (CALLPRC) command.

When you prompt the CALLPRC command, you'll notice that it looks very similar to the CALL command. The difference is that instead of requiring a program name it prompts you for a procedure name. The procedure must exist in the same program or in a service program specified when the program was created. The procedure name can be up to 256 bytes long and is case sensitive.

The procedure name is followed by a list of parameters you want to pass to the procedure. You can pass up to 300 parameters using the CALLPRC command; however, some languages limit the number of parameters a procedure can accept. For instance, a CL procedure accepts a maximum of 40 parameters. You can omit parameters by passing the special value *OMIT, in which case the procedure receives a null pointer as the parameter value. This can be useful when calling the OS/400 bindable APIs because the APIs often supply default values for omitted parameters.

Putting the Pieces Together

So far I've told you what you need to know to get started using ILE CL. Now I'll show you a working example to demonstrate how some of the pieces fit together. This example shows how to create a program containing a CL module that calls a procedure in a service program. 1 shows a conceptual view. I could have written this application using a single program containing two procedures, but I wanted to demonstrate the use of a service program since it's a better design approach, for reasons mentioned earlier.

So far I've told you what you need to know to get started using ILE CL. Now I'll show you a working example to demonstrate how some of the pieces fit together. This example shows how to create a program containing a CL module that calls a procedure in a service program. Figure 1 shows a conceptual view. I could have written this application using a single program containing two procedures, but I wanted to demonstrate the use of a service program since it's a better design approach, for reasons mentioned earlier.

Figures 2 and 3 show the source code for modules ILE001CL and ILE002CL. The purpose of these modules is to repeatedly perform a dynamically bound procedure call. ILE001CL passes a counter to ILE002CL, where the counter is incremented. When the counter reaches a value of 1000, the program ends.

To compile the example, perform the following steps:

1. Use the CRTCLMOD command to create module ILE001CL. 2. Use the CRTCLMOD command again to create module ILE002CL. 3. Use the CRTSRVPGM command to create the service program ILE002SV. In the MODULE parameter specify that you want the service program to contain module ILE002CL. (A service program can contain multiple modules.) 4. Use the CRTPGM command to create program ILE001PG. In the MODULE parameter specify that you want the program to contain module ILE001CL. In the BNDSRVPGM parameter specify that you want the program to be able to access procedures in the service program ILE002SV.

You have to create the service program ILE002SV before you create program ILE001PG. The reason for this is, if you specify the name of a service program on the CRTPGM command, the system checks to make sure the service program exists. If it does not, the command fails.

To test the difference in performance be-tween an ILE application and a non-ILE application, I wrote this example twice. One is the ILE version shown here, which uses the CALLPRC command. The other is a non-ILE program (not shown) that uses the traditional CALL command. The ILE version was almost twice as fast-it took 17 CPU seconds to execute, while the non-ILE version took 33 CPU seconds.

It's clear that ILE is the future of AS/400 application development, and ILE CL will play an important part in its success. With ILE CL, IBM has given us a powerful new tool to increase the performance, functionality, and quality of AS/400 application programs.

Robin Klima is a senior technical editor for Midrange Computing.

REFERENCES CL Reference (SC41-3722, CD-ROM QBKAUP00). ILE Application Development Example (SC41-3602, CD-ROM QBKAQ400).


ILE CL

Figure 1 ILE CL Example Overview

 UNABLE TO REPRODUCE GRAPHICS 
ILE CL

Figure 2 ILE CL Module ILE001CL

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLMOD MODULE(XXX/ILE001CL) SRCFILE(XXX/QCLSRC) */ /* */ /* CRTPGM PGM(XXX/ILE001PG) MODULE(XXX/ILE001CL) + */ /* BNDSRVPGM(XXX/ILE002SV) */ /* */ /*==================================================================*/ PGM DCL VAR(&COUNTER) TYPE(*DEC) LEN(10 0) LOOP: CALLPRC PRC(ILE002CL) PARM(&COUNTER) IF COND(&COUNTER *LT 1000) THEN(GOTO CMDLBL(LOOP)) ENDPGM 
ILE CL

Figure 3 ILE CL Module ILE002CL

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLMOD MODULE(XXX/ILE002CL) SRCFILE(XXX/QCLSRC) */ /* */ /* CRTSRVPGM SRVPGM(XXX/ILE002SV) MODULE(XXX/ILE002CL) + */ /* EXPORT(*ALL) */ /* */ /*==================================================================*/ PGM PARM(&COUNTER) DCL VAR(&COUNTER) TYPE(*DEC) LEN(10 0) CHGVAR VAR(&COUNTER) VALUE(&COUNTER + 1) ENDPGM 
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: