Published on System iNetwork (http://systeminetwork.com)
CL Command Defs Get a Face-Lift in i5/OS 6.1
By cbushong
Created Jul 17 2008 - 16:32

By:
Bob Cozzi [1]

You know, sometimes all you've got to do is ask.

As many of you know, I started using IBM's WDSc about a year ago. All the typical reasons were the cause of my delay: It was too fat, it was too slow, it was too difficult to install, I had written my own Windows-based RPG editor that worked better (okay, so that last point is bias).

One of the first things I did when I started using WDSc was ask the development team why it didn't do some of the basic editing functions that virtually any other contemporary editor does (including the one I wrote). They responded, "Nobody ever asked for that feature." You mean features like drag-and-drop editing and auto-correct weren't asked for yet? Yikes!

So it occurred to me that perhaps the old days of going to COMMON twice a year and submitting Resolutions (later renamed to "Requirements") were effectively over. Few, if any, end-user requirements were being implemented in IBM System i productions simply because end users were no longer submitting these requirements.

Jump ahead eight months. I get a prereview of the i5/OS 6.1 (aka "IBM i 6.1") operating system enhancements to CL (yes, CL not RPG IV). I read through the enhancements and said the usual things that veteran RPG programmers say about CL enhancements, "Wow, I wish we had this 20 years ago." But then I thought, why not see what they've done for commands. Yes, CL commands or user-written command definitions have had virtually no enhancements since they change the maximum number of entries from 50 to 300, long before PowerPC was a word. Sure, they added support for IFS paths/folder names, but no enhancements from which programmers would benefit.

After reviewing the CL enhancements, I called Greg Veal, author of "CL Programming for the IBM AS/400," who continues to be not only a great resource for System i development, but he stays in touch with IBM on the latest and greatest CL enhancements as well. I complained to Greg that I was disappointed that IBM had not yet implemented the ability to consolidate some of the compiler options for command definitions. It is a pain to remember to prompt the CMD compiler every time I create this or that CL command just to enter ALLOW(*IPGM *BPGM) and, more recently, ALLOW(*IPGM *BPGM *IMOD *BMOD). My request was to make the compiler figure it out and do it anyway.

Apparently, Greg shot my request off to IBM, who responded with a question or two, which I answered and sent back to them.

Jump Ahead to Current Day and IBM i 6.1

Today, as I started writing this article, I signed on to the newly installed Power system running i 6.1 and was about to write an example of how to pass a qualified file name using user-written CL command definitions to RPG IV. When I entered SEU (yes, it was SEU because I like the prompter better), I prompted the "CMD" command, which is the statement that allows you to enter a text description for the command. For example, the CPYF command would have "CMD PROMPT('Copy File')" specified as the CMD command statement. To my surprise, the command no longer had a single, lonely PROMPT parameter; it had many of the compiler parameters as its own parameters. This, like RPG IV's Header spec, allows you to embed compiler parameter right inside the source code. This is a huge benefit to the next person who needs to compile the source code.

Here's an example of the CMD command statement's prompt:

                            Command Definition (CMD)                            
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 Label  . . . . . . . . . . . . .              > DSPFILE                        
 Prompt text or message ID  . . . PROMPT       > 'Display Database File'        
                                                                                
 Message file for prompt text:    PMTFILE        __________                              
   Message file . . . . . . . . .                 __________                     
     Library  . . . . . . . . . .                  *LIBL                        
   Message text . . . . . . . . .                *STATIC                        
 Message file . . . . . . . . . . MSGF           __________                    
   Library  . . . . . . . . . . .                  *LIBL                        
 Text 'description' . . . . . . . TEXT           ______________________________
___________________                                                             
 Maximum positional parameters  . MAXPOS         __________
 Where allowed to run . . . . . . ALLOW          __________
                            + for more values    __________
 Mode in which valid  . . . . . . MODE           __________
                           + for more values     __________
                                                                        More... 

Paging down to page 2, gives us the following:

                            Command Definition (CMD)                    
                                                                        
 Type choices, press Enter.                                             
                                                                        
 Allow limited users  . . . . . . ALWLMTUSR       __________                       
 Threadsafe . . . . . . . . . . . THDSAFE         __________                      
 Multithreaded job action . . . . MLTTHDACN       __________            
 Validity checking program  . . . VLDCKR          __________            
   Library  . . . . . . . . . . .                  *LIBL                
 Prompt override program  . . . . PMTOVRPGM       __________            
   Library  . . . . . . . . . . .                  *LIBL                
 Help identifier  . . . . . . . . HLPID           __________            
 Help panel group . . . . . . . . HLPPNLGRP       __________            
   Library  . . . . . . . . . . .                  *LIBL                
 Help search index  . . . . . . . HLPSCHIDX       __________            
   Library  . . . . . . . . . . .                  *LIBL                
 Current library  . . . . . . . . CURLIB          __________            
 Product library  . . . . . . . . PRDLIB          __________
 Authority  . . . . . . . . . . . AUT             __________            
 

The big one for me is the ALLOW parameter, which I use whenever I write a CL command that can only run inside a CL program. Others I use often are PRDLIB and MAXPOS. Occasionally, I'll use the MSGF parameter as well.

A Big Thank You!

A big Thank You! goes out to IBM Rochester and Guy Vig for enhancing this subtle area of user-written command development. But it doesn't end here.

RPG TnT: 101 Dynamic Tips 'n Techniques with RPG IV by Bob Cozzi is available now.
[2] The latest book from author Bob Cozzi is 300-pages long and contains 101 example RPG IV Tips and Techniques for everyday programming tasks, from date calculations, to regular express searches, to using APIs. Cozzi wrote down every cool technique he's found over the years, updated them, and consolidated them into this compact book that is a great desktop companion -- and it includes full example source code. Order your copy today. [3]

CL Compiler Parameters

After discovering the enhancement to the CMD statement, I recalled hearing that IBM was adding this capability to CL itself. So I went into SEU and did a F4 (prompt) on a blank line. Then I selected option 1 to display a list of command by command name. First I tried "CMD*", but only the "CMD" command was listed. Then I tried "DCL*" and got lucky; the DCLPRCOPT (Declare Processing Options) keyword is the CL version of embedded compiler parameter. The prompted DCLPRCOPT command looks like this:

                     Declare Processing Options (DCLPRCOPT)                     
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 Label  . . . . . . . . . . . . .                                               
 Subroutine stack depth . . . . . SUBRSTACK      __________
 Log commands . . . . . . . . . . LOG            __________
 Allow RTVCLSRC . . . . . . . . . ALWRTVSRC      __________
 Text 'description' . . . . . . . TEXT           ______________________________
                                                                                
 User profile . . . . . . . . . . USRPRF         __________
 Authority  . . . . . . . . . . . AUT            __________ 
 Sort sequence  . . . . . . . . . SRTSEQ         __________  
   Library  . . . . . . . . . . .                  *LIBL                        
 Language ID  . . . . . . . . . . LANGID         __________
 Storage model  . . . . . . . . . STGMDL         __________
 Default activation group . . . . DFTACTGRP      __________
 Activation group . . . . . . . . ACTGRP         __________
                                                                                
                                                                                
                                                                        More... 
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display    
 F24=More keys                                                                  
                                                                                

Page 2 of the DCLPRCOPT Command

                     Declare Processing Options (DCLPRCOPT)                     
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 Bind service program:            BNDSRVPGM   _
   Service program  . . . . . . .                __________
     Library  . . . . . . . . . .                  *LIBL                        
   Activation . . . . . . . . . .                *IMMED                         
                           + for more values  _
 Binding directory  . . . . . . . BNDDIR         __________
   Library  . . . . . . . . . . .                  *LIBL                        
                           + for more values     __________
                                                   *LIBL                        
                                                                                
                                                                         Bottom 
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display    
 F24=More keys                                                                                                                                                  

Continue Enhancements

IBM Rochester seems committed to enhancing the operating system's scripting language (i.e., CL) after decades of neglect. I'm still not convinced that this means a whole lot to me, but I do think that adding the compiler parameters is a huge help. The more we can do to get rid of those pesky notes about how to compile this or that program, the better and more practical things will be. So, Thank You IBM!

Bob Cozzi is the host of RPG World Live [4], a live, weekly two-hour show on System i developments. It is aired each Friday from 10:00 AM to Noon, Central time on ustream.tv and on RPGWorld.com. Bob also produces RPG World, the most popular RPG IV developer conference of the year.

© 2010 Penton Media, Inc.

Source URL: http://systeminetwork.com/article/cl-command-defs-get-face-lift-i5os-61

Links:
[1] http://systeminetwork.com/author/bob-cozzi
[2] http://www.amazon.com/dp/1583041214?tag=rw0c-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=1583041214&adid=0FDDKRAMASMW6SZB3462&
[3] http://www.amazon.com/dp/1583041214?tag=rw0c-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=1583041214&adid=0FDDKRAMASMW6SZB3462&
[4] http://www.rpgworld.com