JCL Code Explanation examples

Examples

2.1.0+

Given here is an example for the different levels of AI-generated explanations from watsonx Code Assistantâ„¢ for Z using the following JCL step.

Example: Selected JCL step

//SORT1 EXEC PGM=SORT 
//SORTIN DD DSN=IBMUSER.WCAZDAT.RAW(NMPHN1),DISP=OLD 
//SORTOUT DD DSN=IBMUSER.WCAZDAT1.SORTED,DISP=SHR 
//SYSPRINT DD SYSOUT=* 
//SYSOUT DD SYSOUT=* 
//SYSIN DD * SORT FIELDS= (1,20, CH, A, 21,10, FI, A) 
//*

Example 1: Simple JCL explanation

Summary: 
This JCL step uses the SORT program to sort the input dataset and store the output in a new dataset. 
The SORT command in this code specifies the fields to sort on, which are specified in the FIELDS parameter: FIELDS=(1,20,CH,A,21,10,FI,A) 
Each input record requires four facts specified in the FIELD control statement: 
p - the position of the field within the record 
m - the length of the field 
f - the format of the data in the field 
s - the sequence into which the field is to be sorted 
Position (p): specifies the position of the field within the record to be sorted. 
Length (m): specifies the length of the field to be sorted. 
Format (f): specifies the format of the data in the field. The valid formats are CH (character), ZD (zoned decimal), PD (packed decimal), FI (fixed-point), FL (floating-point). 
Sequence (s): specifies the sequence in which the field is to be sorted. The valid sequences are A (ascending) and D (descending). 

In this example, the input dataset is IBMUSER.WCAZDAT.RAW(NMPHN1), the output dataset is IBMUSER.WCAZDAT1.SORTED, and the SYSOUT dataset is used for printing and other system messages. 
The SORT command in this code specifies that the first input record to sort is in position 1, the max length of the record is 20, the CH format of the data in the fields, and the A sequence for sorting the data in the fields. 
The second input record to sort is in position 21, the max length of the record is 10, the FI format of the data in the fields, and the A sequence for sorting the data in the fields.
Example 2: Detailed JCL explanation
Summary of the SORT program: 
The SORT program sorts records in a dataset on a mainframe system. In this specific step, the SORT program is used to sort a dataset that contains phone numbers and names. The input dataset is named SORTIN and the output dataset is named SORTOUT. 
The SORT program is invoked with specific control statements, which specify the fields to sort on, the input and output datasets, and other parameters related to sorting. 
The SORT command in this step specifies that the first 20 characters of each record should be sorted in ascending order, and the second 10 characters should be sorted in ascending order. 

Key input datasets: 
The input dataset for this SORT program is named SORTIN and contains phone numbers and names. 

Key output datasets: 
The output dataset for this SORT program is named SORTOUT. After the records are sorted, they are written to this output dataset. 

Control statements: 
The control statements for this SORT program include: 
- SORTIN DD specifies the input dataset, which is named SORTIN. 
- SORTOUT DD specifies the output dataset, which is named SORTOUT. 
- SYSPRINT DD directs the output from the SORT program to the system printer. 
- SYSOUT DD directs the output from the SORT program to the system output device. 
- SYSIN DD specifies the input for the SORT program, which includes the SORT command with the FIELDS parameter. The FIELDS parameter specifies the fields to sort on, which are the first 20 characters of each record in ascending order, and the second 10 characters in ascending order.