The vast majority of AS/400 commands were written by IBM developers to perform system level tasks like compiling programs, backing up data, changing system configurations, displaying system object details, or deleting them. Commands are not limited to systems level concerns and can be drafted for user applications as well.
Table of contents |
2 Syntax 3 Prompting 4 Command Help 5 Creating new commands 6 Finding the right command |
Commands and programs
Parameters (aka arguments) defined in the main procedures of all traditional AS/400 programs are hard coded lists that are be made up of parameters that can be numeric, alphanumeric, boolean, etc and the order in which parameters are passed is important. This is a stark difference from the Unix & DOS words where the parameter list in Unix shell scripts and C programs is a set or array of character pointers and more often than not the parameters are not positionally dependent.
The AS/400 developer's solution to this problem was the command object (*CMD). Each parameter is definied to be passed in a specific order. The programmer can also define, among other things, the parameter's data type, unique parameter name, descriptive text (for prompting), default value (used only if the parameter isn't specified during execution), if the values are restricted to a certain set or range, if the data entered should be changed to another value before calling the program, etc.
At its most basic a command names a single program to call when the user types or prompts the command and presses the Enter key. The command takes all of the parameters typed by the user, and those not typed by the use, and builds a parameter list that it passes to the program when it's called.
Syntax
The BNF for a much simplified CL command syntax would be defined as follows:
The items above that end in -name follow AS/400 object naming conventions which, generally speaking, means the name starts with a letter and can be up to ten characters in length. (CL commands are also case-insensitive.)::= command-name [ ] [ ]
::= [ ]
::= parameter-name"(" ")" [ ]
::= [ ]
::= CL-name | qualified-CL-name | "*"special-value | generic-CL-name"*" | "'"alphanumeric-value"'" | numeric-value | "X'"hexadecimal-value"'"
A good example of a typical CL command is the Change Program (CHGPGM) command below:
CHGPGM MYPGM OPTIMIZE(*FULL) RMVOBS(*BLKORD *PRCORD) TEXT('My program.')
The above command is passing four parameters to the program that does Change Program processing and they are:
Prompting
All AS/400 commands can be prompted directly from the command line or within CL program source by typing the command and pressing the F4 function key. The system will then present a screen with the set of parameters that the program accepts/requires (required parameters are usually highlighted).
Prompting is further enhanced to allow the user to find what values are valid for each parameter. To do this during prompting the user would move the cursor to the parameter field in question and press F4 again. The system would then display a screen describing the type of data required and an optional list of allowable values.
There are other menus besides the Command Grouping Menus. The starting point for the menuing system can be accessed by pressing F4 on an empty command line.
In the bacground the system is using the SLTCMD command to perform this function. If one wants to select all commands in a library then prompt this command and enter the special value *ALL.Command Help
Cursor sensitive help can also be provided on AS/400 commands but it's not required. If help has been provided one can view help for a parameter by moving the cursor to the desired parameter field and pressing F1 (help). To get help for the entire command itself (and all of its parameters) the user would press F1 anywhere on the prompt display and then press F2 (extended help).Creating new commands
New commands can be created to call non-system programs and they will work exactly like the AS/400 variety. The Command Definition Language is described in the IBM iSeries CL Programmer's Guide. It's a good idea to create help screens for new commands and their parameters. All help screens use Panel Group objects (*PNLGRP) and these can be created using the UIM language described in the IBM AS/400 Application Display Programming manual.Finding the right command
There are hundreds and hundreds of commands on the AS/400, but finding them isn't all that hard because of several designs of the system that make life easier. These labor saving designs are: Standardized TLA's, Command Grouping Menus, and Command Selection.Standardized TLA's (Three Letter Acronyms)
The AS/400 developers standardized the Three Letter Acronyms used to create command names. Verbs likes change are always rendered as CHG, display as DSP, work as WRK, create as CRT, etc. Subjects like program are always PGM, user is USR, module is MOD, server is SVR, etc. You can see every possible verb and subject used on the AS/400 in the VERB and SUBJECT menus, just enter the commands GO VERB or GO SUBJECT.Command Grouping Menus
The VERB and SUBJECT menus are part of what are called the Command Grouping Menus. For every Three (or four) Letter Acronym there is a menus devoted to it that starts with the letters CMD. So to see all CHG commands the user would execute the command GO CMDCHG. For program commands the menu would be CMDPGM.Command Selection
If one only knows part of a command or if third party software is being used where the commands don't conform to the AS/400 TLA standard then you would enter that part of the command that is known, attach an asterisk (to make it generic), and press enter. The system will then display a list of commands in the job's library list that match the generic names just typed. One can then page through the list looking for the command needed and then select it using option 1.