//HPUROUT JOB (ACCT),'HPU REORG',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*********************************************************************
//* JCL TO INTEGRATE IBM HIGH PERFORMANCE UNLOAD (HPU) *
//* WITH DB2 REORG TABLESPACE UTILITY USING INZUTILB IN UNLOAD PHASE *
//* DB2 12 FOR Z/OS CONTEXT *
//*********************************************************************
//REORGEXEC EXEC DSNUPROC,SYSTEM=DB2A,UID='REORGHPU'
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSALLDA,SPACE=(CYL,(1,1)),DISP=(NEW,DELETE)
//SORTOUT DD DSN=&&SORTOUT,UNIT=SYSALLDA,SPACE=(CYL,(1,1)),DISP=(NEW,DELETE)
//SYSLIN DD DSN=&&SYSLIN,UNIT=SYSALLDA,SPACE=(CYL,(1,1)),DISP=(NEW,DELETE)
//SYSREC DD DSN=&&SYSREC,UNIT=SYSALLDA,SPACE=(CYL,(1,1)),DISP=(NEW,DELETE)
//SYSPUNCH DD DSN=&&SYSPUNCH,UNIT=SYSALLDA,SPACE=(CYL,(1,1)),DISP=(NEW,DELETE)
//SYSCNTL DD DSN=&&SYSCNTL,UNIT=SYSALLDA,SPACE=(CYL,(1,1)),DISP=(NEW,DELETE)
//SYSIN DD *
REORG TABLESPACE DBNAME.TSNAME
UNLOAD EXTERNAL
SHUTDOWN PROGRAM(INZUTILB)
WORKSIZE(nnnn) <-- Optional, specify if needed for HPU work files
COPYDDN(SYSCOPY)
LOG NO
STATISTICS TABLE(ALL) INDEX(ALL)
SORTDEVT SYSDA
SORTNUM 30
/*
//SYSCOPY DD DSN=YOUR.IMAGE.COPY.DATASET(+1),
// DISP=(NEW,CATLG,DELETE),UNIT=SYSALLDA,
// SPACE=(CYL,(10,10)),DCB=(RECFM=U,BLKSIZE=0)
//UNLOADDD DD DSN=YOUR.REORG.UNLOAD.OUTPUT.DSN,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSALLDA,
// SPACE=(CYL,(100,100)),DCB=(RECFM=VB,LRECL=32756,BLKSIZE=0)
//INZPARMS DD *
// HPU control statements for INZUTILB
// These statements tell HPU what to unload.
// Replace TABLESPACE_NAME, TABLE_NAME, SCHEMA, etc. with your actual values.
UNLOAD DEVICE(SYSREC)
SELECT *
FROM TABLESPACE_NAME.TABLE_NAME
;
/*
//*********************************************************************
//* NOTE: *
//* - Replace 'DB2A' with your Db2 Subsystem ID. *
//* - Replace 'DBNAME.TSNAME' with your actual database and tablespace. *
//* - Adjust 'WORKSIZE', 'SORTNUM', 'SYSUT1', 'SORTOUT', etc. as needed. *
//* - 'YOUR.IMAGE.COPY.DATASET' should be a valid dataset name for the *
//* image copy created by REORG. *
//* - 'YOUR.REORG.UNLOAD.OUTPUT.DSN' is the dataset where HPU will *
//* write the unloaded data. Make sure it's large enough. *
//* - The 'INZPARMS' DD contains the HPU control statements. *
//* Customize the UNLOAD and SELECT statements based on your needs. *
//* For example, you can specify specific columns, WHERE clauses, etc. *
//* - Ensure that your STEPLIB concatenation includes the necessary *
//* Db2 and HPU libraries. *
//*********************************************************************
//```
**Explanation of Key JCL Sections:**
* **`//REORGEXEC EXEC DSNUPROC,SYSTEM=DB2A,UID='REORGHPU'`**:
* `DSNUPROC` is the standard Db2 utility procedure.
* `SYSTEM=DB2A` specifies your Db2 subsystem ID.
* `UID='REORGHPU'` is an optional utility ID for logging.
* **`//SYSIN DD *`**: This is where the `REORG TABLESPACE` utility control statements are provided.
* `REORG TABLESPACE DBNAME.TSNAME`: Specifies the tablespace to be reorganized.
* `UNLOAD EXTERNAL`: This is crucial! It tells `REORG` *not* to perform its own internal unload but to instead use an external utility for this phase.
* `SHUTDOWN PROGRAM(INZUTILB)`: This is the key to integrating HPU. It specifies that `INZUTILB` should be called during the `SHUTDOWN` phase of the `REORG` utility. `INZUTILB` then acts as the interface to HPU.
* `WORKSIZE(nnnn)`: Optional parameter to specify the size for HPU's work files. You might need to adjust this based on the volume of data.
* `COPYDDN(SYSCOPY)`: Specifies the DD name for the image copy dataset.
* `LOG NO`: Disables logging during the `REORG`. Use with caution based on your recovery strategy.
* `STATISTICS TABLE(ALL) INDEX(ALL)`: Updates statistics after the `REORG`.
* **`//UNLOADDD DD DSN=YOUR.REORG.UNLOAD.OUTPUT.DSN,...`**:
* This DD statement defines the sequential dataset where HPU will write the unloaded data.
* **Important:** This DD name (`UNLOADDD` in this example) should be referenced in your HPU control statements within `INZPARMS` (e.g., `UNLOAD DEVICE(UNLOADDD)`). In the provided example, I used `SYSREC` which is a common HPU output DD. Make sure they match.
* **`//INZPARMS DD *`**:
* This DD statement provides the HPU control statements to `INZUTILB`.
* `UNLOAD DEVICE(SYSREC)`: This tells HPU to unload data to the `SYSREC` DD name. Make sure this matches the actual DD name you want to use for the unload output. In my example, I've mapped `SYSREC` to `YOUR.REORG.UNLOAD.OUTPUT.DSN` implicitly through HPU's internal handling, but explicitly defining it as `UNLOADDD` and then referencing `UNLOADDD` in your HPU control statements might be clearer for some. If you use a different DD name (like `UNLOADDD` above), you would specify `UNLOAD DEVICE(UNLOADDD)`.
* `SELECT * FROM TABLESPACE_NAME.TABLE_NAME;`: This is a basic HPU SELECT statement. **You must customize this** to specify the actual table(s) within your tablespace that you want to unload. You can also add `WHERE` clauses, select specific columns, and use other HPU options here. Refer to the IBM Db2 High Performance Unload documentation for the full syntax.
**Before Running:**
1. **Customize:**
* Replace `DB2A` with your actual Db2 subsystem ID.
* Replace `DBNAME.TSNAME` with the actual database and tablespace you intend to reorganize.
* Provide valid dataset names for `YOUR.IMAGE.COPY.DATASET` and `YOUR.REORG.UNLOAD.OUTPUT.DSN`.
* **Crucially, review and customize the HPU control statements within `INZPARMS` to accurately reflect the data you want to unload.**
2. **STEPLIB:** Ensure your JCL's `STEPLIB` concatenation includes the necessary Db2 load libraries (e.g., `DSN.SDSNLOAD`) and the HPU load libraries (e.g., `INZ.SINZLOAD`). This is critical for `DSNUPROC` and `INZUTILB` to find their respective programs.
3. **Authorization:** The user ID running this JCL must have the necessary Db2 privileges to execute `REORG TABLESPACE` and access the tablespace, as well as the necessary authorizations for HPU.
4. **Testing:** It's highly recommended to test this JCL in a non-production environment first, ideally with a small tablespace, to ensure everything works as expected.
5. **HPU Documentation:** Always refer to the official IBM Db2 High Performance Unload for z/OS documentation for the most accurate and up-to-date information on HPU control statements and integration with Db2 utilities.
This sample provides a solid starting point. You will need to adapt it to your specific environment and requirements.