# Job Control Language - JCL

***MSGLEVEL*** - parameter controls the printing of job messages in the spool. It’s a keyword parameter and is optional.  
MSGLEVEL=(M1,M2)

M1 = 0 (Only job statements)  
1 (All statements)  
2 (Only jcl statements)

M2 = 0 (print allocation and termination messages only when job ended abnormally)  
1 (print allocation and termination messages when job ended either normally or abnormally)

***MSGCLASS*** - parameter is used to specify the output device to where the system or jcl messages are routed(written & printed). It’s used to hold the job log messages - JESMSGLG  
Default value is ‘A’ (spool).

***CLASS*** - parameter used to classify the jobs. is based on how much time they are running.

***PRTY/PRIORITY*** - parameter used to assign a selection priority to jobs within the same class. JES system uses the PRTY value to decide the execution sequence of the jobs when they have same CLASS value.  
JES2 = 0-15 JES3 = 0 - 14

***REGION*** - parameter used to specify the amount of central or virtual memory required to execute the job or step. REGION=NOLIMIT

***TIME*** - parameter used to specify the maximum CPU utilization time allowed for the job to execute. system will automatically cancel the job execution if time exceeds. TIME=1440/NOLIMIT means 24 hrs.

***Bind DB2 Program:-***  
Bind process builds a connection between Application program and its relational database.  
//BIND001 EXEC PGM=IKJEFT01  
//DBRMLIB DD DSN=ECO2069.SANTU.LOADLIB,DISP=SHR  
// DD DSN=SYS4.ENDVR.WMA.LEG2.UATWMAD.DBRMLIB,DISP=SHR  
//SYSPRINT DD SYSOUT=\*  
//SYSTSPRT DD SYSOUT=\*  
//SYSOUT DD SYSOUT=\*  
//SYSUDUMP DD SYSOUT=\*  
//SYSTSIN DD \*  
DSN SYSTEM(DB2M)  
BIND PACKAGE(AXACVY0C) -  
OWNER (AXAQVY0C) -  
QUALIFIER(AXAQVY0C) -  
MEMBER(IMDCAFFU) -  
SQLERROR(NOPACKAGE) -  
VALIDATE(BIND) -  
FLAG(I) -  
ISOLATION(CS) -  
EXPLAIN(NO) -  
CURRENTDATA(NO) -  
ENABLE(\*) -  
DYNAMICRULES(BIND) -  
ACTION(REPLACE)  
END

***<mark>Generation Data Group (GDG)</mark>*** - That allows organizing and managing datasets or files over time.  
A maximum of 255 generation are exists within a GDG.  
IDCAMS utility is used to create GDG Base. \*\* Can also be created using File-Aid tool.  
//Step01 exec pgm=idcams  
//sysin dd\*  
Define GDG(name(GDG-Name)-  
limit(nnn) -  
noempty|empty -  
scratch|noscratch)  
/\*\*  
Empty - All the existing generations are to be uncataloged whenever the generations of GDG matches the maximum limit.  
NOEMPTY - Only the latest generation is uncataloged when the GDG reaches maximum limit.  
Scratch - Generation should be deleted physically when uncataloged.  
Noscratch - Generation should not be deleted when uncataloged, can be accessed using UNIT and VOL parameters.

***<mark>Virtual storage access method (VSAM) </mark>*** \- Allows us to access the records and organise the records into disk dataset.  
VSAM works with the data that stores only on direct access storage device (DASDs).  
**KSDS** - Key Sequenced Dataset  
**ESDS** - Entry Sequenced Dataset  
**RRDS** - Relative Record Dataset  
**LDS** - Linear Dataset

**Vsam can access records in 3 ways:**  
Sequential  
Direct  
Dynamic or Skip Sequential  
  
***<mark>INCLUDE MEMBER:</mark>***  
  
**JCL** `INCLUDE` Statement – Example

#### **Scenario:**

You have multiple JCL jobs that require **common DD statements** (such as dataset allocations, SYSOUT definitions, or parameters). Instead of repeating the same statements in every JCL, you can **store them in a separate PDS member** and use `INCLUDE MEMBER=XXX` to insert them dynamically.

---

### **Step 1: Create a Common JCL Member**

1️⃣ **Create a JCL member (**`COMMONDD`) in a PDS (e.g., `MYPROCLIB.COMMONJCL`)  
This member will contain commonly used DD statements.

```plaintext
//SYSOUT   DD  SYSOUT=*                       
//SYSPRINT DD  SYSOUT=*                       
//SYSUDUMP DD  SYSOUT=*                       
//MYDATA   DD  DSN=MY.DATA.SET,DISP=SHR
```

---

### **Step 2: Use the** `INCLUDE` Statement in Your Main JCL

Now, in your **main JCL**, you can use `INCLUDE MEMBER=COMMONDD` instead of repeating the DD statements.

```plaintext
//MYJOB   JOB 'TEST',CLASS=A,MSGCLASS=X
//STEP1   EXEC PGM=IEFBR14
//        INCLUDE MEMBER=COMMONDD
```

---

### **Step 3: How the System Processes This JCL**

* When the system processes this JCL, it **replaces** the `INCLUDE MEMBER=COMMONDD` with the content of the `COMMONDD` member from `MYPROCLIB.COMMONJCL`.
    
* The final JCL submitted for execution will look like this:
    

```plaintext
//MYJOB   JOB 'TEST',CLASS=A,MSGCLASS=X
//STEP1   EXEC PGM=IEFBR14
//SYSOUT   DD  SYSOUT=*                       
//SYSPRINT DD  SYSOUT=*                       
//SYSUDUMP DD  SYSOUT=*                       
//MYDATA   DD  DSN=MY.DATA.SET,DISP=SHR
```

---

### **Benefits of Using** `INCLUDE` in JCL

✅ **Avoids duplication** – No need to rewrite common statements in multiple JCLs.  
✅ **Easier maintenance** – If you need to change SYSOUT or dataset details, update only the common member.  
✅ **Improves readability** – JCL is shorter and cleaner.

---
