AS/400 Control Language - Syntax

Syntax

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.

Read more about this topic:  AS/400 Control Language