The AS/400 control language (CL) is reminiscent of JCL and consists of an ever expanding set of command objects (*CMD) used to invoke traditional AS/400 programs and/or get help on what those programs do. CL can also be used to create CL programs (congruent to shell scripts) where there are additional commands that provide program-like functionality (GOTO, IF/ELSE, variable declaration, file input, etc.)
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.
The AS/400 developer's solution to this problem was the command object (*CMD). While the parameters on the command can be specified in any order, each parameter is defined to be passed in a specific order to the program. 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 user, and builds a parameter list that it passes to the program when it's called.
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.)
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:
In reality the AS/400 will pass many more parameters than the four specified above. This is because the rest of the CHGPGM command's parameters were not specified, so default values will be passed instead. For every parameter on this, aside from the PGM parameter, that default is *SAME, meaning don't change it.
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 background 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.
PGM PARM(&IN &TYP)
DCL VAR(&IN) TYPE(*CHAR) LEN(6)
DCL VAR(&OUT) TYPE(*CHAR) LEN(8)
DCL VAR(&TYP) TYPE(*CHAR) LEN(1)
DCL VAR(&MSG) TYPE(*CHAR) LEN(80)
IF COND(&TYP = J) THEN(DO)
CVTDAT DATE(&IN) TOVAR(&OUT) FROMFMT(*MDY) +
TOFMT(*JUL) TOSEP(*NONE)
ENDDO
IF COND(&TYP = M) THEN(DO)
CVTDAT DATE(&IN) TOVAR(&OUT) FROMFMT(*JUL) +
TOFMT(*MDY) TOSEP(*NONE)
ENDDO
CHGVAR VAR(&MSG) VALUE('IN=' || &IN || ' OUT=' || +
&OUT)
SNDPGMMSG MSG(&MSG)
ENDPGM //optional
Command line interpreter for OS/400. Accessed through the OS/400 menu system; in general, most places where a menu option can be supplied a CL command can be entered instead.
Its provision of a fill-in form interface (for 5250 block terminals or emulators), in which the system understands the syntax of commands and guides the user through their use, is particularly interesting.
This article is licensed under the GNU Free Documentation License.
It uses material from the
"AS/400 Control Language".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world