AS/400 Control Language

AS/400 Control Language

Infobox programming language
name = AS/400 Control Language

paradigm = imperative
year =
designer = IBM
developer = IBM
latest_release_version =
latest_release_date =
latest_test_version =
latest_test_date =
typing =
implementations =
dialects =
influenced_by = Job Control Language
influenced = Windows PowerShell
operating_system = IBM AS/400
license =
website =
The AS/400 Control Language (CL) is a scripting language for the IBM AS/400 midrange platform bearing a resemblance to the IBM Job Control Language and consisting 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.

Commands and programs

Parameters (command-line arguments) defined in the main procedures of all traditional AS/400 programs are hard coded lists that are 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 and DOS worlds 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). 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.

yntax

The BNF for a much simplified CL command syntax would be defined as follows:

::= command-name [] []

::= []

::= parameter-name"(" ")" []

::= []

::= CL-name
qualified-CL-name
"*"special-value
generic-CL-name"*"
"'"alphanumeric-value"'"
numeric-value
"X'"hexadecimal-value"'"

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:

* MYPGM: A positional parameter (PGM), and the only required parameter. In this case it's the name of the program being changed. Positional parameters are always first. Once a named parameter appears all parameters that follow must be named parameters.
* OPTIMIZE(*FULL): A named parameter specifying a single element which is a special value. In this case it will change the program to be fully optimized.
* RMVOBS(*BLKORD *PRCORD): A named parameter (Remove Observability) specifying multiple special values. In this case telling it to remove two kinds of profiling data from the program.
* TEXT('My program.'): Another named parameter specifying a single alphanumeric value. In this case it's changing the descriptive text of the program.

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

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. An OS/400 command can also be prompted by typing a ? before the command.(This is useful in an interactive program which cues a command string, having already filled in some values.)

The system will then present a screen with the set of parameters that the program accepts/requires (required parameters are usually highlighted).

Required parameters are listed first, and parameters with system-supplied default values are listed last of all. To see all parameters, press F10. If any one choice requires further selections, those are cued as you select that value for that parameter, by appearing onscreen.

Prompting is further enhanced to allow the programmer 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 input required and an available list of allowable values.

To enter a longer name, or extend the list to allow you to enter extra values, type a plus sign instead of a value. (As when listing names of objects to be saved or restored.)

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 [http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/sm14/c4157215.pdf 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 [http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c4157150.pdf 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 Abbreviations, Command Grouping Menus, and Command Selection.

tandardized abbreviations

The AS/400 developers standardized the abbreviations 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 abbreviation there is a menu 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.

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.

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 abbreviation 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.

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.

ample code

The following is a sample of CL programming. The program interactively converts dates from julian to mdy and vice versa. Results are displayed on line 24 of the terminal. It accepts two parameters. The &IN parameter which is the date string to be converted. If a julian stringit should be in the format yynnn where yy is the year number and nnn is the day number of the year. If a MDY string it must be in the format mmddyy. The second parameter is &TYP which is the type of date to be converted to. It must be 'J' (julian) or 'M' (mdy). For example: the command CALL PGM(ICVTDATC) PARM('04180' 'M') will convert the julian date 04180 to 062804 (June 28, 2004).

PGM (&IN &TYP)

DCL &IN *CHAR 6 DCL &OUT *CHAR 8 DCL &TYP *CHAR 1

IF (&TYP = J) + DO CVTDAT DATE(&IN) TOVAR(&OUT) FROMFMT(*MDY) + TOFMT(*JUL) TOSEP(*NONE) ENDDO

ELSE IF (&TYP = M) + DO CVTDAT DATE(&IN) TOVAR(&OUT) FROMFMT(*JUL) + TOFMT(*MDY) TOSEP(*NONE) ENDDO

SNDPGMMSG MSG('IN=' || &IN || ' OUT=' || &OUT) + MSGTYPE(*COMP)

ENDPGM

References


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Operational Control Language — (OCL) is the control language of the IBM System/34 and System/36 minicomputer family. Other control languages include CL (System/38 and AS/400), JCL (System/370), and REXX (AS/400). The facility of DOS to use batch files is also control language …   Wikipedia

  • AS/400 — System i Modell 570 mit Power 6 Prozessoren (Oktober 2007) i5 Modell 570 (2006) System i (frühere Namen AS/400 oder eServer iSeries oder System i5) ist eine Computer Baureihe der Firma IBM. IBMs Systeme i …   Deutsch Wikipedia

  • AS/400 object — On most other platforms everything is a file. On the AS/400 everything is an object. This seems to be the same as object oriented programming, but with the AS/400 it s different. The similarity is that when storage is allocated for something,… …   Wikipedia

  • AS/400 — Debian GNU/Linux en un IBM iSeries modelo 9406 520 El sistema AS/400 es un equipo de IBM de gama media y alta, para todo tipo de empresas y grandes departamentos. Se trata de un sistema multiusuario, con una interfaz controlada mediante menús y… …   Wikipedia Español

  • Origin of language — The origin of language is the emergence of language in the human species. This is a highly controversial topic, empirical evidence being so limited that many regard it as unsuitable for serious scholars. In 1866, the Linguistic Society of Paris… …   Wikipedia

  • Spanish language — Castellano and Español redirect here. For the village in Italy, see Castellano, Trentino. For people with the surname Castellano, see Castellano (surname). Castilian castellano Pronunciation [kasteˈʎano] Spoken in …   Wikipedia

  • Comparison of revision control software — The following is a comparison of revision control software. The following tables includes general and technical information for notable revision control and software configuration management (SCM) software. This is an incomplete list, which may… …   Wikipedia

  • Dacian language — Dacian Spoken in Romania, northern Bulgaria, eastern Serbia; also (possibly): Moldova, SW Ukraine, eastern Hungary, southern Bulgaria, northern Greece, European Turkey, NW Anatolia (Turkey) Extinct probably by the 6th century AD …   Wikipedia

  • List of Pokémon (381-400) — At the core of the multi billion dollarcite web|url=http://sev.prnewswire.com/entertainment/20051004/LATU06404102005 1.html|title=Pokémon Franchise Approaches 150 Million Games Sold|publisher=PR Newswire|accessdate=] Pokémon media franchise of… …   Wikipedia

  • Cg (programming language) — Cg (short for C for Graphics) is a high level shading language developed by Nvidia in close collaboration with Microsoft[1][2] for programming vertex and pixel shaders. It is very similar to Microsoft s HLSL. Cg is based on the C programming… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”