Skip to content

CMD_as_JCL

stockiNail edited this page Oct 12, 2015 · 3 revisions

Windows CMD as JCL

(quoted from Windows CMD definition in Wikipedia)

Command Prompt, better known as cmd.exe or just cmd (after its executable file name), is the command-line interpreter on OS/2 and eComStation, Windows CE and Windows NT operating systems (including Windows 2000 and later). It is the analog of COMMAND.COM in DOS and Windows 9x systems (where it is also called "MS-DOS Prompt"), or of the Unix shells used on Unix-like systems.

cmdis a native Windows application usually running in Win32 console. This allows it to take advantage of features available to native programs on the platform that are otherwise unavailable to DOS programs.

Windows CMD file can be used as JEM JCL, adding metadata like comments to the script. The metadata could be the JEM properties, data descriptions and locks.

Special Tokens

All necessary information, which must be read by JEM to execute the script, are passed by comments inside the script. But JEM needs to be aware that what is managing is a Windows CMD file. For this reason, all metadata written as comment must be included in 2 token (XML like):

rem
rem <JEM-CMD>
rem jem.job.name=JOB-NAME
rem jem.job.affinity=JOB-AFFINITY
rem jem.job.user=JOB-USER
rem </JEM-CMD>
rem
....
...

JEM is able to read all comments, reading and using all information between <JEM-CMD> and </JEM-CMD> token. All properties are managed at row level, that means the JEM reads and interpret every line (not multi line properties). BE aware that Windows CMD file will be executed inside of ANT file.

Properties definition

To use Windows CMD file inside JEM, the file must contain the mandatory and optional properties that JEM needs, described in JCL Reference, as following:

  • Job Name is optional string property, called for Windows CMD jem.job.name . If missing, the file name will be used.
  • Environment is optional string property, called for Windows CMD jem.job.environment.If missing, the JEM node environment definition is used.
  • Domain is optional string property, called for Windows CMD jem.job.domain. If missing, default value (***) will be used.
  • Affinity is optional string property, called for Windows CMD jem.job.affinity. If missing, default value (***) will be used.
  • User is optional string property, called for Windows CMD jem.job.user. If missing, default value (null) will be used. An exception occurs if the user, who submitted the job, is not authorized to change the user job execution.
  • Locking Scope is optional string property, called for Windows CMD jem.job.lockingScope. If missing, default value (job) will be used. If the value is not equals to one the possible values (job, step , task), an exception occurs.
  • Hold is optional boolean property, called for Windows CMD jem.job.hold. If missing, default value (false) will be used.
  • Priority is optional integer property, called for Windows CMD jem.job.priority. If missing, default value (10) will be used (highest priority is 1).
  • Memory is optional integer property, called for Windows CMD jem.job.memory. If missing, default value (128) will be used. Be aware the unit is MegaBytes.
  • Classpath is optional string property, called for Windows CMD jem.job.classPath. Defining a classpath, it will be able to import ANT task definitions of 3rd parties. The value is a string and the files are separated by semicolons ;. If the file doesn't represent an absolute path, JEM will use relative position from jem.classpath folder. You could use variables that JEM substitutes in string value. If missing, default value (null) will be used. The paths will be added at the end of default classpath, build by JEM.
  • Prior Classpath is optional string property, called for Windows CMD jem.job.priorClassPath. Defining a classpath, it will be able to import ANT task definitions of 3rd parties. The value is a string and the files are separated by semicolons ;. If the file doesn't represent an absolute path, JEM will use relative position from jem.classpath folder. You could use variables that JEM substitutes in string value. If missing, default value (null) will be used. The paths will be added at the beginning of default classpath, build by JEM.
  • Emails Notification is optional string property, called for Windows CMD jem.job.emailsNotification. If missing, default value (null) will be used.

Here is the sample about the properties definition, in Windows CMD file as comments:

rem
rem <JEM-CMD>
rem jem.job.name=JOB1
rem jem.job.environment=ENV1
rem jem.job.domain=domain
rem jem.job.affinity=classA
rem jem.job.priority=99
rem jem.job.user=newUSER
rem jem.job.lockingScope=task
rem jem.job.hold=true
rem jem.job.memory=1024
rem jem.job.classPath=/test/ant-taskdefs-lib.jar
rem jem.job.priorClassPath=/test/commons.jar
rem jem.job.emailsNotification=m1@pepstock.org;m2@pepstock.org
rem </JEM-CMD>
rem

Data Descriptions and Datasets in Windows CMD

Data descriptions and datasets are implemented by properties, together with all the other properties (between <JEM-CMD> and </JEM-CMD> token). Data descriptions could be defined as following:

rem <JEM-CMD>
rem ...
rem jem.dataDescription.name-of-data-description=SYSOUT,DISP=NEW
rem jem.dataDescription.name-of-data-description=DSN=datasetName,DISP=NEW/MOD/OLD/SHR
rem jem.dataDescription.name-of-data-description=DSN=gdgName,DISP=NEW/MOD/OLD/SHR
rem jem.dataDescription.name-of-data-description=DSN=@@temp,DISP=NEW
rem ...
rem </JEM-CMD>

Data description needs a mandatory name, which must be inside of key name. All properties name for data descriptions, start with jem.dataDescription..

This name is used inside the Windows CMD file to access to datasets therefore this name must be unique in the task definition. The SYSOUT attribute is optional one that if there is means that the data description is a sysout. The DISP attribute is optional and must be a valid value, one of the following string enumeration: NEW, MOD, OLD or SHR.

Datasets could be defined as following:

DSN=dsn, DISP=NEW/MOD/OLD/SHR

Datasets could represent:

  • file name (absolute or relative path), composed by properties if necessary. If it's a relative path, JEM adds the content of jem.data variable, used to identify the global file system with all data.
  • GDG file name, following the same rules of a normal file name (see previous item).
  • Temporary prefix file name
  • if the text assigned to the property doesn't match with the abpve description, a INLINE file will be created, with the content of the property

Using data descriptions, the programmer is able to develop own job batch programs, avoiding strong references with physical files but logical ones, by environment variables. To reduce the risk to use variables already used on system, all variables names have DD_prefix.

Here is an example, how to access to data description:

rem <JEM-CMD>
rem ...
rem jem.dataDescription.INPUT=DSN=/gdg/jemtest(0),DISP=SHR
rem jem.dataDescription.OUTPUT=DSN=/gdg/jemtest(+1),DISP=NEW
rem ...
rem </JEM-CMD>

copy %DD_INPUT% %DD_OUTPUT#

Locks in Windows CMD

Locks are implemented by specific propertie. They could be defined as following:

rem <JEM-CMD>
rem ...
rem jem.locks=LABEL1, LABEL2
rem ...
rem </JEM-CMD>

Lock names are defined a value, comma-separated, of a property named jem.locks. These names are used to create a lock inside the JEM environment in exclusive. This name must be unique in the task definition.

Clone this wiki locally