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:
DCLPRCOPT BNDDIR(MYLIB/MYBNDDIR)
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:
INCLUDE SRCMBR(MYDATADFN) SRCFILE(MYLIB/QCLSRC)
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:
CMD PROMPT(MSG0013) PMTFILE(MYMSGF *DYNAMIC) HLPID(*CMD) HLPPNLGRP(MYAPPHELP)
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...
PARM KWD(OPTION) TYPE(*CHAR) LEN(5) PROMPT('Option')
...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.
Pgm
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 */
EndDo
/* */
/* Process record from MyFile */
/* */
EndDo
EndPgm
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
LATEST COMMENTS
MC Press Online