Você está na página 1de 161

JOB CONTROL LANGUAGE JCL is the interface between the programs and the MVS operating system JCL

CL is needed to run programs on IBM Mainframes Typically these programs work with files - Input and Output Files These programs are non interactive -- they are batch Consider the following examples: 1. Print employee list Needs input employee file and output report file (file or spoor to printer) 2. Payroll processing: Assume Employee Master file with salary and allowances is available. Monthly additions to the payroll is available as a transaction file.
Page 1 TSO-JCL-VSAM HTC Confidential

The following would be a typical sequence of steps for the payroll processing: a. Validate payroll transactions and print validation report b. Backup Employee Master file c. Update Employee Master File with transaction information d. Calculate Payroll e. Print Pay slips f. Write Payroll History

Page 2

TSO-JCL-VSAM

HTC Confidential

JCL FEATURES Files needed by programs can be provided through JCL Parameters can be provided to programs through JCL Some of the programs need parameters. E.g. Employee list print program To Print all employees of a given department - needs department number as a parameter To Print all employees whose names start with a given string - needs name string as a parameter JCL provides mechanism to provide parameters to programs.
Page 3 TSO-JCL-VSAM HTC Confidential

Conditional Execution of programs In a Job where many programs need to be run in sequence, there exists a need to execute or skip programs based on the status of the prior program execution. To facilitate this, programs can set what is called a 'return code or condition code which can be tested by JCL to execute or skip programs. E.g. If there is a validation error in the payroll transaction validation program, the rest of the payroll processing should be skipped or by passed.
Page 4 TSO-JCL-VSAM HTC Confidential

Page 5

STRUCTURE OF A JOB A JCL program also known as a JOB contains: Job Statement (Only one) Identifies the user to the system Facilitates security checking Provide Accounting Information to MVS and a few other parameters EXEC Statement(s) (One for each program or step) Identifies the program to be executed Optionally specifies the parameters to be passed to the program and a few other parameters. DD Statement (s) (For each program) One Statement for each file needed by the program (E.g.) To run employee list program we need to code a JOB Statement an EXEC Statement to run the program a DD statement for the input employee file and a DD statement for the output report file
TSO-JCL-VSAM HTC Confidential

OUR FIRST JCL PROGRAM The EMPRPT program for which we will be writing JCL is given in APPENDIX B. Input file: HTC.CHENNAI.EMPFILE Output: Printer //HTCU1 JOB //********************************************************* //* This job produces employee report //********************************************************* //STEP1 EXEC PGM=EMPRPT //EMPFL DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //RPTFL DD SYSOUT=A //SYSOUT DD SYSOUT=A

Page 6

TSO-JCL-VSAM

HTC Confidential

NOTES JCL statements shown above contain // in first two columns. // is immediately followed by a name referred to as label. Next on the JCL statements in an operator JOB or EXEC or DD with at least a space separating the label and operator. Parameters follow the operator with at least one space in between the operator and the parameters. Comments are coded with a '//*' in the first three columns

Page 7

TSO-JCL-VSAM

HTC Confidential

EXPLANATION OF THE JCL STATEMENTS JOB Statement Denotes the beginning of a JOB Gives name to a JOB(HTCU1 in this case) Further details of JOB statement will be discussed later. EXEC Statement Executes a program coded in the 'PGM' parameter. (e.g.EMPRPT) Gives a name to the step (STEP1) DD Statement Label on the DD statement is called DD Name. DD Name corresponds to the file specified in the program. Consider the following statement in the INPUT-OUTPUT SECTION of EMPRPT program: SELECT EMP-FILE ASSIGN TO EMPFL.
Page 8 TSO-JCL-VSAM HTC Confidential

EMPFL is the DD Name which should be specified as a label on the DD statement corresponding to the employee file. The corresponding DD statement in the JOB is : //EMPFL DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR DSN Data Set Name DISP DISPosition SYSOUT writes data into SPOOL (Simultaneous Peripheral Operation On-line). Value of the SYSOUT parameter denotes a class to which the output should be spooled to. DD statements link datasets to programs. DD statements make programs device and file independent. The program does not know the name or the location of the files.

Page 9

TSO-JCL-VSAM

HTC Confidential

Let us change the JCL to write the report to a disk file rather than to spool: //HTCU1 JOB //********************************************************** //* This job produces employee report //********************************************************** //STEP1 EXEC PGM=EMPRPT //EMPFL DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //RPTFL DD DSN=HTC.CHENNAI.EMPRPT, // DISP=(NEW,CATLG), // UNIT=SYSDA, // SPACE=(TRK,(1,5)), // DCB=(RECFM=FB,LRECL=133,BLKSIZE=1330) //SYSOUT DD SYSOUT=A
Page 10 TSO-JCL-VSAM HTC Confidential

Statement Continuation : Statements are continued on to the next lines by coding a ',' at the end of the parameter fields in each line. // needs to be coded on the continuation lines as well. DD Statement Parameters : The DISP parameter is coded with two sub-parameters. First one is for current disposition of the dataset. The second sub parameter indicates the disposition of the file after normal completion of the step. SYSDA includes one or more DASD units (Direct Access Storage Device). UNIT=TAPE or UNIT=CART can be coded to create the file on tape or cartridge respectively.

Page 11

TSO-JCL-VSAM

HTC Confidential

DCB PARAMETER The data control block parameter supplies information about the physical characteristics of the data in a data set to the program. These physical characteristics must correspond with those specified in the DATA DIVISION of the COBOL program. FD for REPORT-FILE in EMPRPT program is coded as : FD REPORT-FILE BLOCK CONTAINS 0 RECORDS. 01 REPORT-REC PIC X(133). RECFM - Record format (F, FB, V, VB) LRECL - Logical record length BLKSIZE - Block size If any value other than 0 is coded in BLOCK CONTAINS clause, the value must correspond to the block size given in the JCL. BLOCK CONTAINS 0 RECORDS causes program to use block size specified in JCL. Code BLOCK CONTAINS 0 RECORDS to make the COBOL Program independent of the actual block size of the physical file.
TSO-JCL-VSAM HTC Confidential

Page 12

SPACE PARAMETER If a file is being created on a DASD, we need to indicate to MVS exactly how much of space to be allocated. The first sub parameter is the unit of measurement. It is indicated as tracks or cylinders or block size. The second sub parameter specifies the space to be allocated in terms of the unit of measure. Primary quantity is allocated when the file gets allocated. The secondary quantity is allocated dynamically during program execution on the need basis. This allocation is done for a maximum of 15 times. Non availability of space on a volume or insufficient allocation provided in the SPACE parameter will result in an abnormal termination or (ABEND) of the program.

Page 13

TSO-JCL-VSAM

HTC Confidential

To instruct the system not to delete the file, even after the abend, we make following changes to the DD statement. //RPTFL DD DSN=HTC.CHENNAI.EMPRPT, // DISP=(NEW,CATLG,CATLG), // UNIT=SYSDA, // SPACE=(TRK,(1,5)), // DCB=(RECFM=FB,LRECL=133,BLKSIZE=1330) The third sub-parameter in the DISP parameter instructs the system on the steps to be taken with the dataset upon the abnormal termination of the step.
Page 14 TSO-JCL-VSAM HTC Confidential

PARAMETER PASSING Consider the same Employee report example. Let us pass department code parameter to the EMPRPT program to produce report for a given department. We receive parameters in linkage section of COBOL program. COBOL Program CHANGES: LINKAGE SECTION. 01 PARM-REC. 05 PARM-LEN PIC S9(04) COMP. 05 PARM-DEPT-CODE PIC X(03).

Page 15

TSO-JCL-VSAM

HTC Confidential

We need to change the Procedure Division statement as follows: PROCEDURE DIVISION USING PARM-REC. Parameters are passed using PARM keyword on EXEC statement as follows: // EXEC PGM=EMPRPT,PARM=XXX System prefixes the parameters coded in the PARM field with length of the parameter and sends it to the program. It is a good practice to check for this length before using the parameter field, in the COBOL program. If length is zero, accessing the parameter would cause the program to terminate abnormally as these data areas are not addressable. The revised program is shown in APPENDIX B as EMPRPTP.

Page 16

TSO-JCL-VSAM

HTC Confidential

The following is the revised JCL: //HTCU1 JOB //********************************************* //* This job produces employee report //******************************************** //STEP1 EXEC PGM=EMPRPTP, PARM='D03' //EMPFL DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //RPTEL DD SYSOUT=A //* REPORT written to spool //SYSOUT DD SYSOUT=A Display outputs Parameters are passed to the program via PARM sub-parameter of the EXEC statement. The parameter string needs to be enclosed within quotes, if it contains special characters. A maximum of 100 characters can be sent as parameters. The program being executed, receives the parameters with a 2 byte length prefix in the linkage section.
Page 17 TSO-JCL-VSAM HTC Confidential

MULTI-STEP JCL A Job can contain more than one STEP, executed in sequence. Let us modify the employee report job to select employees based on certain criteria from the employee file and then print only those employees. We can use the same EMPRPT program to print. We need to write a program that selects the employees based on certain criteria. The following diagram describes the job flow:

Page 18

TSO-JCL-VSAM

HTC Confidential

htc.chennai .empfile

EMPSEL

htc.parmlib

(empselp)

htc.temp.e mpfile
EMPRPT

htc.chennai .emprpt

Page 19

TSO-JCL-VSAM

HTC Confidential

Page 20

//HTCU1 JOB //* Step1 EMPSEL selects employees based on criteria. //* Step2 EMPRPT produces report of the selected employees //STEP1 EXEC PGM=EMPSEL //EMPIN DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //EMPOUT DD DSN=HTC.TEMP.EMPFILE, // DISP=(NEW,PASS,DELETE), // UNIT=SYSDA, SPACE=(TRK,(1.5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SELPARM DD DSN=HTC.PARMLIB(EMPSELP),DISP=SHR //SYSOUT DD SYSOUT=A //STEP2 EXEC PGM=EMPRPT //EMPFL DD DSN=HTC.TEMP.EMPFILE,DISP=OLD //RPTFL DD DSN=HTC.CHENNAI.EMPRPT, // DISP=(NEW,CATLG), // UNIT=SYSDA, SPACE=(TRK,(1.5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSOUT DD SYSOUT=A
TSO-JCL-VSAM HTC Confidential

IN-STREAM DATA SETS JCL provides a mechanism to provide data to the programs in the job stream itself. In-stream data can be coded as follows: //SELPARMS DD * XXX /* '*' in the parameter fields of the DD statements indicates that the data is provided in JCL stream itself, immediately following the DD statement and up to the next JCL statement. There is also an explicit terminator or the end-of-file indicator for the instream datasets, which is '/*'. The use of '/*' after the selection criteria is optional, but recommended. '/*' or '//' in first two columns delimit the data, i.e., end the in-stream dataset.

Page 21

TSO-JCL-VSAM

HTC Confidential

If the data itself contains '/*' in the first two columns we cannot use the default delimiters. In which case we need to specify a delimiter for the in-stream data as follows: //INDATA DD *,DLM='$$' d001 xyz 1234 oracle /* xxx abc $$ If data contains '//' in the first two columns we needs to use DATA instead of * as //INDATA DD DATA,DLM='$$' D123 xyz oracle //abcdf $$

Page 22

TSO-JCL-VSAM

HTC Confidential

JCL WITH AN IN-STREAM DATASET EXAMPLE //HTCU1 JOB //STEP1 EXEC PGM=EMPSEL //EMPIN DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //EMPOUT DD DSN=HTC.TEMP.EMPFILE, // DISP=(NEW,PASS,DELETE), // UNIT=SYSDA, // SPACE=(TRK,(1,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SELPARM DD * XXXX XXX XXX XXX XXX /* //SYSOUT DD SYSOUT=A //STEP2 EXEC PGM=EMPRPT //EMPFL DD DSN=HTC.TEMP.EMPFILE,DISP=OLD //RPTFL DD DSN=HTC.CHENNAI.EMPRPT,DISP=OLD //SYSOUT DD SYSOUT=A
Page 23 TSO-JCL-VSAM HTC Confidential

TEMPORARY FILES A temporary dataset is one that is created during job execution and deleted after job completion. JCL recognizes a temporary data set based on the following: If the DSN parameter is omitted. If the DSN starts with two ampersands (&&) followed by 1 to 8 characters. The dataset containing selected employees can be coded as temp dataset. The following is the revised JCL:

Page 24

TSO-JCL-VSAM

HTC Confidential

//HTCU1 JOB //STEP1 EXEC PGM=EMPSEL //EMPIN DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //EMPOUT DD DSN=&&EMPDATA,SPACE=(TRK,(1,5)), // DISP=(NEW,PASS),UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SELPARM DD DSN=HTC.PARMLIB(EMPPRMS1),DISP=SHR //SYSOUT DD SYSOUT=A //STEP2 EXEC PGM=EMPRPT //EMPFL DD DSN=&&EMPDATA,DISP=OLD //RPTFL DD DSN=HTC.CHENNAI.EMPRPT, // DISP=(NEW, CATLG),UNIT=SYSDA, // SPACE=(TRK,(1,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSOUT DD SYSOUT=A
Page 25 TSO-JCL-VSAM HTC Confidential

CONDITIONAL EXECUTION OF STEPS JCL has mechanism to execute steps conditionally based on condition codes (or return codes) set by prior steps. If the employee selection program does not select any records, there is no need to run the report program. To facilitate this we need to change EMPSEL program to set a condition code, say 99, if the program does not select any records. change the JCL to skip executing STEP2, if condition code of STEP1 is 99. COBOL provides a data name (special register) called RETURN-CODE with the following properties: Value of the data name RETURN-CODE at the time program finishes execution is the return code or condition code of the step. RETURN-CODE is not defined in the program. Range of values that can be moved into return code is 0 to 4095

Page 26

TSO-JCL-VSAM

HTC Confidential

Page 27

JCL EXAMPLE with COND parameter The following JCL skips step2 based on the condition codes set by step1. //HTCU1 JOB //STEP1 EXEC PGM=EMPSELC //EMPIN DD DSN=HTC.CHENNAI.EMPFILE.DISP=SHR //EMPOUT DD DSN=&&EMPDATA, DISP=(NEW,PASS), // UNIT=SYSDA, SPACE=(TRK,(1.5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) // SELPARM DD DSN=HTC.PARMLIB(EMPSELP),DISP=SHR //* //SYSOUT DD SYSOUT=A //STEP2 EXEC PGM=EMPRPT,COND=(99,EQ) //EMPFL DD DSN=&&EMPDATA,DISP=OLD //RPTFL DD DSN=HTC.CHENNAI.EMPRPT, // DISP=(NEW, CATLG), // UNIT=SYSDA, SPACE=(TRK,(1.5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SYSOUT DD SYSOUT=A
TSO-JCL-VSAM HTC Confidential

COND PARAMETER COND=(99,EQ), instructs the system to bypass executing the step if 99 equals the condition code of prior step, i.e., STEP1. The value of the condition code that can be coded is between 0 and 4095. Conditional operators are: GE Bypass current step, if value Coded is greater than or equal to the return code GT Bypass current step, if value coded is greater than the return code LE Bypass current step, if value coded is less than or equal to the return code LT Bypass current step, if value coded is less than the return code EQ Bypass current step, if value coded is equal to the return code NE Bypass current step, if value coded is not equal to the return code
Page 28 TSO-JCL-VSAM HTC Confidential

DATA SET CONCATENATION Let us consider the scenario of HTC having one employee file for each branch as follows: HTC.HQ.EMPFILE for Headquarters HTC.CHICAGO.EMPFILE for Chicago branch HTC.SJ.EMPFILE for San Jose branch HTC.GR.EMPFILE for Grand Rapids branch HTC.CHENNAI.EMPFILE for its SDC at Chennai, India Also assume that all these files are of the same format Our requirement is to find HTC employee with a given skill irrespective of the branch they are in. We can accomplish this without changing the EMPSEL program.

Page 29

TSO-JCL-VSAM

HTC Confidential

EMPIN DD can be coded in the following way concatenating all the employee files: //EMPIN // // // // DD DD DD DD DD DSN=HTC.HQ.EMPFILE,DISP=SHR DSN=HTC.CHICAGO.EMPFILE,DISP=SHR DSN=HTC.SJ.EMPFILE,DISP=SHR DSN=HTC.GR.EMPFILE,DISP=SHR DSN=HTC.CHENNAI.EMPFILE,DISP=SHR

Only the first file in the concatenation would have a DD have coded on it, in the name field. All other files concatenated with it are coded one after the other without the DD name. But the operator DD has to be coded for every dataset.

Page 30

TSO-JCL-VSAM

HTC Confidential

PARAMETER DUMMY ON THE DD STATEMENTS TorunEMPSELprogramwithnoparameters ProvideanemptyparameterfileintheSELPARMS DDstatement -or CodeSELPARMSasaDUMMYdatasetasshown below: //SELPARMSDDDUMMY CharacteristicsofDDDUMMY: Fileopenandclosewillbesuccessful. Firstreadoffilesignalsendoffilecondition Anynumberofwritestothefilewillbesuccessful.
Page 31 TSO-JCL-VSAM HTC Confidential

Revised JCL: //STEP1 EXEC PGM=EMPSELC //EMPINDD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //EMPOUT DD DSN=&&EMPDATA, // DISP=(NEW,PASS), // UNIT=SYSDA,SPACE=(TRK,(1,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) //SELPARM DDDUMMY

Page 32

TSO-JCL-VSAM

HTC Confidential

IEFBR14 ReruntheJCLtoprintemployeereport. WithDISP=NEW,JCLerroroccursasthefile HTC.TEMP.EMPFILEalreadyexists. IfDISPischangedtoOLD,JCLerrorwilloccurwhenwerunthe jobfortheveryfirsttimeorwhenHTC.TEMP.EMPFILEdoesnot exist. Toovercometheproblem,codeanadditionalsteptodeletethe dataset, ifitexists,andexecutethatstepasthefirststepinthejob. IEFBR14isanassemblerprogramwhichdoesnothingotherthan returning0asthereturncode. EveniftheprogramdoesnotopenthedatasetstheDDstatements willbeusedandthedatasetswillbecreated,deletedetc.as specified. CodeastepasfollowstodeleteHTC.TEMP.EMPFILE,ifitexists.
Page 33 TSO-JCL-VSAM HTC Confidential

//CLEANUP //X // //

EXEC DD

PGM=IEFBR14 DSN=HTC.TEMP.EMPFILE, DISP=(MOD,DELETE,DELETE), UNIT=SYSDA,SPACE=(TRK,1)

MODinthedisposition Usesthefileifitexists.Positionsthefilepointertotheendof the file. Ifthefiledoesnotexist,MODwillcreatethefile. TocreateanyfileweneedtospecifyUNIT. AswearecreatingthefileonDASD,spaceneedstobespecified too.

Page 34

TSO-JCL-VSAM

HTC Confidential

RESTART PARMAMETER OF THE JOB STATEMENT RerunofEMPRPTprogramtoproducethereportbecomes necessaryandthefollowingcouldbesomeofthereasons: MPRPTterminatedabnormally LogicErrorsinEMPRPTprogramresultedinincorrectreport Reportislost AssumethatthefileHTC.TEMP.EMPFILEproducedbyEMPSEL programexists. Then,toreproducethereportitisnecessaryonlytorerun EMPRPT program. TheRESTARTparametercodedontheJOBstatementcan accomplishthis: //HTCU1 // //
Page 35

JOB (768,120,10),'EMPRPT-RERUN', RESTART=STEP2, CALSS=A,MSGCLASS=A,MSGLEVEL=(1,1)


TSO-JCL-VSAM HTC Confidential

SORT Toproducetheemployeereportinnamesequenceweneedto SorttheoutputofEMPSELprogrambynameand Usethesortedfileasinputtothereportprogram ThefollowingSORTstepcanbeusedtosortthedata: // EXEC PGM=SORT //SORTIN DDDSN=HTC.TEMPDATA.EMPFILE,DISP=OLD //SORTOUT DD DSN=HTC.SORTED.EMPFILE, // DISP=(NEW,CATLG), // SPACE=(TRK,(5,5)) //SYSIN DD * SORTFIELDS=(5,15,CH,A) /* //SYSOUT DD SHSOUT=A

Page 36

TSO-JCL-VSAM

HTC Confidential

DDnamesusedbySORT SORTIN --inputtothesortprogram SORTOUT --outputofthesortprogram SYSIN --sortcommands SYSOUT--errorsinsortcommandsandothersort log Sortwillbediscussedindetaillatter

Page 37

TSO-JCL-VSAM

HTC Confidential

IEBGENER TheEMPRPTprogramisproducingthereportandourJCLis spoolingit (SYSOUTparameterontheDD). Ifweneedthereportontheprinteraswellasinafileondisk ChangeJCLtomakeEMPRPTprogramtowritethereporttoa diskfile Writeanothersteptocopythereportfromdiskfiletospool output IEBGENERistheprogramthatcanbeusedtocopyfiles: //COPYFL EXEC PGM=IEBGENER //SYSUT1 DD DSN=HTC.CHENNAI.EMPRPT, // DISP=OLD //SYSUT2 DD SYSOUT=A //SYSPRINT DD SYSOUT=A //SYSIN DD DUMMY
Page 38 TSO-JCL-VSAM HTC Confidential

SYSUT1 -DDnamefortheinputfile SYSUT2 -DDnamefortheoutputfile SYSPRINT -DDnamefortheIEBGNERmessages SYSIN-DDnamefortheIEBGENER commands IEBGENERcanbeusedtoreformatthefiles,massage thedatewhilecopyingthedata.Suchcommandswillbe providedinSYSIN. Tocopyafilewithoutanyfrillsthereisnoneedtoprovide commandstoIEBGENER.ThatiswhySYSINiscoded aDUMMY.
Page 39 TSO-JCL-VSAM HTC Confidential

PROCEDURES (PROCS) JCLstatementcanbegroupedtogethertoformwhatiscalledaPROC. UsefultocreatePROCSforcommonlyusedJCL BackupMasterfiles, RestoreMasterfiles Produceemployeelistetc. In-stream Procedures:arecodedintheJOBstream,socanonlybe usedbythejobinwhichtheyarecoded. Catalogued Procedures:arecodedasseparatemembersofaPDS andcanbeusedbyanyJOB. Procedure Libraries SystemSuppliedProcedureLibrary SYS1.PROCLIB UserdefinedProcedureLibrariesex. HTC.PROCLIB Locationoftheprocedureneednotbespecifiediftheprocedureisin theSystemsuppliedPROCLIB LocationisnecessaryforproceduredefinedinuserPROCLIB(S)andis specifiedusingthefollowingDDstatement: //PROCLIBDD DSN=HTC.PROCLIB,DISP=SHR ThisstatementmustbecodedbeforetheEXECstatementintheJCL. Proceduresshouldnotcontaininstreamdatasets
Page 40 TSO-JCL-VSAM HTC Confidential

Page 41

IN-STREAM PROCEDURES In-stream PROC is a procedure coded in the JOB stream. //HTCU1 JOB //EMPLST PROC //STEP1 EXEC PGM=EMPSELC //EMPIN DD DSN=HTC.CHENNAI.EMPFILE, DISP=SHR //EMPOUT DD DSN=&&EMPDATA, DISP=(NEW, PASS), // UNIT=SYSDA, SPACE=(TRK, (1,5)), // DCB=(RECFM=LRECL=80, BLKSIZE=800) // DD DSN=HTC. PARMLIB (EMPSELP), DISP-SHR //SYSOUT DD SYSOUT=A //STEP2 EXEC PGM=EMPRPT, COND=COND=(99,EQ) //EMPFL DD DSN=&&EMPDATA, DISP=OLD RPTFL DD DISP=(NEW, CATLG), UNIT=SYSDA, // SPACE=(TRK, (1,5)), // DCB= (RECFM=FB, LRECL=80, BLKSIZE=800 //SYSOUT DD SYSOUT=A // PEND // EXEC EMPLST
TSO-JCL-VSAM HTC Confidential

//EMPLST PROC starts the definition of a PROC and gives the name EMPLST to it. // PEND ends the definition of the PROC. // EXEC EMPLST executes the JCL steps within the PROC EMPLST.

Page 42

TSO-JCL-VSAM

HTC Confidential

CATALOGUED PROCEDURES To catalogue EMPLST procedure, enter JCL statements into a procedure library (PDS) say HTC. PROCLIB with a member name EMPLST: To Execute this PROC, code the following JCL: //HTCU1 JOB //PROCLIB DD DSN-HTC.PROCLIB,DISP=SHR // EXEC EMPLST Note that // PEND is not part of the catalogued procedure. It is used in in-stream procedures only to demarcate the end of procedure definition.

Page 43

TSO-JCL-VSAM

HTC Confidential

OVERRIDING DD STATEMENTS EMPLST procedure produces employee report for selection parameters given in HTC.PARMLIB (EMPSEL1) To use parameters coded in HTC.PARMLIB (EMPSELS2) we can override the SELPARMS DD statement as shown under: //HTCU1 JOB //PROCLIB DD DSN=HTC.PROCLIB, DISP=SHR //* // EXEC EMPLIST //STEP1.SELPARM DD DSN=HTC.PARMLIB (EMPSEL2), // DISP=SHR The overriding DD statements should be coded immediately following the EXEC. The DD name in the overriding statement should include the stepname and the DD name.
Page 44 TSO-JCL-VSAM HTC Confidential

To produce employee list form HQ employee, we need to override the EMPFL DD statement also: //HTCU1 JOB //PROCLIB DD DSN-HTC.PROCLIB, DISP-SHR // EXE EMPLIST //STEP1.EMPFL DD DSN=HTC.HQ.EMPFILE, DISP=SHR //STEP1.SELPARM DD DSN=HTC.PARMLIB (EMPSEL2), // DISP=SHR

Page 45

TSO-JCL-VSAM

HTC Confidential

SYMBOLIC PARAMETERS In our example, employee files are named with second qualifier representing the Branch: HTC.CHENNAI.EMPFILE HTC.CHICAGO.EMPFILE etc. We can rewrite the EMPLST PROC by making the second qualifier as a symbolic parameter. Revised PROC is: //EMPLST PROC BRANCH=CHENNAI //STEP1 EXEC PGM=EMPSEL //EMPFL DD DSN=HTC.&BRANCH..EMPFILE, DISP=SHR . . .
Page 46 TSO-JCL-VSAM HTC Confidential

Symbolic Parameters used in the PROC are specified in the PROC statement Proc statement should not name any symbolic parameter that is not used in the PROC. Symbolic Parameters in the text of the PROC are preceded with &. Symbolic Parameters coded as positional parameters, should have a period at the end of the parameter. If Symbolic parameter is at the end of such positional parameters, then period is not necessary

Page 47

TSO-JCL-VSAM

HTC Confidential

Now, to execute EMPLST procedure for SAN JOSE Branch of HTC, we simply provide a value for BRANCH on the EXEC Statement as Follows: //HTCU1 JOB //PROCLIB DD DSN=HTC.PROCLIB,DISP=SHR //* // EXEC EMPLIST,BRANCH=SJ Value for a symbolic parameter provided in the PROC statement serves as a default value for that parameter. This value can be overridden at the time of Executing the Procedure, as above.

Page 48

TSO-JCL-VSAM

HTC Confidential

More on Symbolic Parameters. Test and Production Environments: e.g.: Employee files HTC.CHENNAI.EMPFILE, HTC.HQ.EMPFILE etc. are Production Files HTC.PROCLIB is Production Procedure Library & HTC.TEST.CHENNAI.EMPFILE, HTC.TEST.EMPFILE etc. are Test Files HTC.TEST.PROCLIB is a test Procedure Library

Page 49

TSO-JCL-VSAM

HTC Confidential

We can change EMPLIST PROC in such a way that it can be executed easily in either Production or Test Environment without modification: Let us have an additional parameter called ENV whose value should be TEST to work with test files and to work with production files. //EMPLIST PROC BRANCH=CHENNAI, ENV=TEST. //STEP 1 EXEC PGM=EMPSEL //EMPFIL DD DSN=HTC.&ENV.&BRANCH..EMPFILE, // DISP=SHR To use this PROC on production employee file of CHICAGO, we need to code: //HTCU1 JOB //PARMLIBDD DSN=HTC.PARMLIB,DISP=SHR // EXEC EMPLST, // BRANCH=CHICAGO, // ENV=
Page 50 TSO-JCL-VSAM HTC Confidential

GENERATION DATA GROUPS (GDG) Many backup jobs, data collection jobs, update jobs are done on a daily basis in production environments. Need exists to keep several versions of the files, e.g., backup of today, backup of yesterday, backup of day before yesterday etc. up to 5 days ago. i.e., at any time we would be able to go back and refer to the file that existed 5 days ago. One way to do this is to have 5 different backup files such as, HTC.CHENNAI.EMPFILE.BACKUP.BACKUP1 HTC.CHENNAI.EMPFILE.BACKUP.BACKUP2 etc. It becomes operationally difficult to keep track of the files and the job management becomes cumbersome. MVS provides an easy way of handling this through what is known as generation data groups.
Page 51 TSO-JCL-VSAM HTC Confidential

All datasets within a generation data group will have the same name. We can access a particular version by providing a version number Relative to the current version. Some of the examples where we use GDGs are: Backups Sequential file update programs Program can read the old master file and create a new master file after applying the transactions rather than updating the master file in place. Day to Day transaction files

Page 52

TSO-JCL-VSAM

HTC Confidential

GDS - Example Consider the following EMPUDT process: Program: EMPUPDT Input-output file: HTC.CHENNAI.EMPFILE Transaction file: HTC.CHENNAI.EMPTRNS is a GDG file JCL for this job would be: //HTCU1 JOB // EXEC PGM=EMPUPDT //EMPFL DD DSN=HTC.CHENNAI.EMPFILE, // DISP=OLD //TRANS DD DSN=HTC.CHENNAI.EMPTRNS(0), // DISP=OLD //SYSOUT DD SYSOUT=A
Page 53 TSO-JCL-VSAM HTC Confidential

(0) refers to the current generation of the dataset. If we needed to use previous generation of the file to do the updates, we should code //TRANS DD // DSN=HTC.CHENNAI.EMPTRNS(-1), DISP=OLD

Before updating the file HTC.CHENNAI.EMPFILE, we need to take a backup to be able to restore the file if the update fails. Assume that we have a GDG called HTC.CHENNAI.EMPFILE.BACKUP for the backup file. The following step would be coded in front of the update step to take the required backup.

Page 54

TSO-JCL-VSAM

HTC Confidential

//BACKUP EXEC PGM=IEBGENER //SYSUT1 DD DSN=HTC.CHENNAI.EMPFILE,DISP=OLD //SYSUT2 DD DSN=HTC.CHENNAI.EMPFILE.BACKUP(+1), // DISP=(NEW,CATLG),UNIT=SYSDA, // DCB=(MODEL.DCB, RECFM=FB, // LRECL=121,BLKSIZE=12100) // SPACE=(CYL,(5,2),RLSE) //SYSIN DD DUMMY (+1) creates a new generation relative to the current generation. (0) always refers to the current generation. i.e., after executing the above job, what was current generation becomes previous generation and can be referred to with a (-1). All datasets within GDG will have the same name suffixed by a unique qualifier generated by the system. Format of the qualifier is: GaaaaVnn aaaa: Absolute sequence # assigned by system (0000 9999) nn:Version # (00 to 99)
Page 55 TSO-JCL-VSAM HTC Confidential

Page 56

Creating GDGs To use GDGs, we need to create GDG Index o Model Dataset which acts as a prototype Both of these should reside on the same volume. We use IDCAMS to create GDG index as follows: //GDGCR EXEC PGM=IDCAMS //SYSIN DD * DEFINE GDG (NAME(HTC.CHENNAI.EMPFILE.BACKUP) LIMIT (5) NOEMPTY SCRATCH) //SYSPRINT DD SYSOUT=A LIMIT specifies # of versions for a GDG NOEMPTY only the oldest generation of GDG is to be uncataloged if the limit is reached. EMPTY all generations of a GDG are to be uncataloged once the limit is reached SCRATCH if entry of a GDG is removed from the index then the dataset is physically deleted NOSCRATCH if the entry is removed from the index the data set is
TSO-JCL-VSAM HTC Confidential

Model dataset can be created by coding a DD statement for model and executing IEFBR14. //MODELCR EXEC PGM=IEFBR14 //X DD DSN=MODEL.DCB, // DISP=(NEW,KEEP), SPACE=(TRK,0), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800), UNIT=SYSDA Concatenating Generations of a GDG To concatenate all the generations of HTC.CHENNAI.EMPTRAN code the DSN parameter without generation number within brackets. //ALLTRAN EXEC PGM=IEBGENER //SYSUT1 DD DSN=HTC.CHENNAI.EMPTRAN, // DISP=OLD //SYSUT2 DD SYSOUT=A //SYSIN DD DUMMY //SYSPRINT DD SYSOUT=A
Page 57 TSO-JCL-VSAM HTC Confidential

SORT/MERGE UTILITY Sort utility can sort data on fields (sort keys) in ascending or descending or a combination Sort can copy files without sorting Sort can select records for processing based on given values in fields Sort can reformat records Sort can summarize data Can create multiple outputs in the same sort processing Can merge sorted files Sort provides powerful report formatting clauses headers, trailers,Control breaks etc.
TSO-JCL-VSAM HTC Confidential

Page 58

DD Statements required by SORT: SORTIN - Input File to be sorted SORTOUT - Output of the Sort messages SYSIN - Sort Commands SYSOUT - Sort messages SORTWKnn - Sort work files SORTOFnn - DD names for multiple output files SORTINnn - DD names of the sorted files for merge operation

Page 59

TSO-JCL-VSAM

HTC Confidential

Page 60

SORT STATEMENT To copy data from input to output without sorting SORT FIELDS=COPY To sort data on given fields: SORT FIELDS=(1,10,CH,A,15,5,CH,D) This sorts data on two fields, both are character in format CH. This statement can be alternatively coded as SORT FIELDS=(1,10,A,15,5,CH,D),FORMAT=CH Sort field is specified as start-loc, length, format, sort-sequence. If the format of the sort fields is the same we can code the format as a common factor for the sort Formats of fields: CH character data PD packed decimal (COMP-3) ZD zoned decimal BI binary (COMP) FI fixed point FL floating point
TSO-JCL-VSAM

HTC Confidential

Page 61

SORT SELECTING DATA FOR PROCESSING INCLUDE Statement To select relevant data from a file, e.g., all employees of a given department from the employee file, we can code: INCLUDE COND=(19,3,CH,EQ,CD01) The format of the include condition is (start-location, length, format, comparison operator, data for comparison) The above INCLUDE COND compares department number (field from 19 to 21) in the file with D01 and selects only those records where the fields are equal. The following comparison operators can be used: EQ, GT, GE, LT, LE, NE Many conditions can be combined with AND & OR. Ex: Select employees from Department D01 and whose names start with SAM INCLUDE COND=(19,3,CH.,EQ,CD01,AND,4,3,CH,EQ,CSAM)
TSO-JCL-VSAM

HTC Confidential

OMIT STATEMENT OMIT Statement syntax is same as that of include except that INCLUDE is replaced with OMIT. The action of OMIT is opposite to that of INCLUDE. Ex: OMIT COND=(5,3,CH, NE,CD01) SORT - SUMMARIZATION Summarize data on a given field e.g., total the salary by department etc. can be done using SORT. SUM FIELDS statement is used for this purpose. To SUM on some fields, a sort key must be specified. SORT FIELDS=(19,3,CH,A) SUM FIELDS=(25,5,PD)
Page 62 TSO-JCL-VSAM HTC Confidential

Deleting Duplicates From a File Based on a Key: Sort the file by the key for which duplicates need to be deleted and issue a SUM FIELDS Statement. SUM FIELDS groups the data by the sort fields. SUM FIELDS=NONE can be specified to do the grouping without summing any fields. The following commands will delete the duplicates on employee number, if any, from the employee file: SORT FIELDS=(1,3,CH,A) SUM FIELDS=NONE

Page 63

TSO-JCL-VSAM

HTC Confidential

Selecting Fields From Input Records Before Sort Sort allows us to select only the required fields from the records using INREC FIELDS statement. This selection happens before SORT and as a result sort has fewer bytes to handle and processing is more efficient. INREC FIELDS=(p1,11[,p2,12,.....,pn,1n]) p1 specifies the beginning position and length in bytes respectively of the input record's relevant fields.

Page 64

TSO-JCL-VSAM

HTC Confidential

Eg: //STEP1 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //SORTOUT DD SYSOUT=* //SORTWK01 DD SPACE=(CYL,10),UNIT=SYSDA //SYSIN DD * INREC FIELDS=(1,3, EMPLOYEE NUMBER 19,3) DEPARTMENT NUMBER SORT FIELDS=(4,3,CH,A) SORT BY DEPT NUMB /* Note that the position mentioned in SORT FIELDS is based on the position of the fields in the INREC statement.

Page 65

TSO-JCL-VSAM

HTC Confidential

REFORMATTING DATA USING SORT OUTREC statement can be specified to format the output of sort. e.g., the following output file from the employee file can be created using sort: field columns depart number 1-3 employee number 4-6 constatnt value of 1 9-12 The sort commands for this would be: SORT FIELDS=COPY OUTREC FIELDS=(1:5,3, 4:1,3, 9:C'0001')
Page 66 TSO-JCL-VSAM HTC Confidential

SORT JCL: // EXEC PGM=SORT //SORTIN DD DSN=HTC.CHENNAI.EMPFILE, DISP=SHR //SORTOUT DD DSN=HTC.SORTED. EMPFILE, // DISP=(NEW,CATLG). // UNIT=SYSDA,SPACE=(CYL,(5,1),RLSE). // DCB=(RECFM=FB,LRECL=12,BLAKSIZE=1200) //SYSIN DD * SORT FIELDS=(19,3,CH,A) /* //SYSOUT DD SYSOUT=A //SORTWK01 DD DSN=&&SORTWK1,DIS=(NEW,DELETE), // SPACE=(CYL,(5,1),UNIT=SYSDA //SORTWK02 DD DSN=&&SORTWK2,DISP=(NEW,DELETE), // SPACE=(CYL,(5,1)),UNIT=SYSDA
Page 67 TSO-JCL-VSAM HTC Confidential

Page 68

MERGING FILES MERGE statement is used to merge the contents of two or more files, which are sorted on the same key. //STEP1 EXEC PGM=SORT //SORTIN01 DD DSN=HTC.CHENNAI.EMPFILE1, // DISP=SHR //SORTIN02 DD DSN=HTC.CHENNAI.EMPFILE2, // DISP=SHR //SORTOUT DD DSN=HTC.CHENNAI.OUTFILE, // DISP=(NEW,CATLG), UNIT=SYSDA, // SPACE=(TRK,(1,5)), DCB=(RECFM=FB, // LRECL=121,BLKSIZE=1210) //SYSIN DD * MERGE FIELDS=(1,3,CH,A) /* //SYSOUT DD SYSOUT=A In the above example, it is assumed that both the input files are already sorted on the first three characters.
TSO-JCL-VSAM HTC Confidential

CREATING MULTIPLE OUTPUT FILES USING SORT To create multiple output files using SORT, we use OUTFIL statement specifying the last two characters of the DD name for the output files. For example to copy all employee records of 'D01' to SORTOF01 and all employees of 'D02' to SORTOF02 we can use the following sort statements: SORT FIELDS=COPY OUTFIL FILES=01,INCLUDE=(19,3,CH,EQ,C'D01') OUTFIL FILES=02,INCLUDE=(19,3,CH,EQ,C'D02) //STEP1 EXEC PGM=SORT //SORTIN DD DSN=HTC.CHENNAI.EMPFILE,DISP=SHR //SORTF01 DD DSN=HTC.CHENNAI.EMP.BU1, // DISP=(NEW,CATLG),UNIT=SYSDA, // SPACE=(TRK,(1,5,), // DCB=(RECFM=FB,LRECL=121,BLKSIE=1210) //SORTF02 DD DSN=HTC.CHENNAI.EMP.BU2, DISP=SHR //SYSIN DD * SORT FIELDS=COPY OUTFIL FILES=(01,02) //SYSOUT DD SYSOUT=A
Page 69 TSO-JCL-VSAM HTC Confidential

COMPILING COBOL PROGRAMS IKFCBLOO is the VS COBOL Compiler Program. IGYCRCTL is the VS COBAL II Compiler Program. //COMPILE EXEC PGM=IKFCBLOO //SYSPRINT DD SYSOUT=A //SYSIN DD DSN=HTC.TEST.SOURCE(EMPRPT),DISP=SHR //SYSLIN DD DSN=&&OBJECT,DISP=(NEW,PASS,DELETE) //SYSLIB DD DSN=HTC.TEST.OBJLIB,DISP=SHR //SYSUT1 DD SPACE=(CYL,(1,1)),UNIT=SYSDA //SYSUT2 DD SPACE=(CYL,(1,1)),UNIT=SYSDA //SYSUT3 DD SPACE=(CYL,(1,1)),UNIT=SYSDA //*
Page 70 TSO-JCL-VSAM HTC Confidential

LINKING COBOL PROGRAMS //LKED EXEC //SYSLIN //SYSLMOD //SYSLIB //SYSUT1 //SYSUT2 PGM=IEWL DSN=&&OBJECT,DISP=(OLD,DELETE) DSN=HTC.TEST.LOADLIB,DISP=SHR DSN=HTC.TEST.OBJLIB,DISP=SHR SPACE=(CYL,(1,1)),UNIT=SYSDA SPACE=(CYL,(1,1),UNIT=SYSDA

DD DD DD DD DD

SYSLINDD name for the object code (output of the compiler & input to the linkage editor) SYSLMOD DD name for the library where the load module is to be kept

Page 71

TSO-JCL-VSAM

HTC Confidential

JOBLIB & STEPLIB DD NAMES SYS1.PARMLIB(LINKLST) specifies the load libraries that will be searched by the system to locate a program for execution. This is similar to PATH on MS-DOS. Assume that HTC.TEST.LOADLIB is not in LNKLIST. To execute the EMPRPT program which we compiled and link edited into HTC.TEST.LOADLIB we can code the following JCL: //HTCU1 JOB //JOBLIB DD DSN=HTC.TEST.LOADLIB,DISP=SHT // EXEC PGM=EMPRPT .....

Page 72

TSO-JCL-VSAM

HTC Confidential

JOBLIB specifies load library or libraries that need to be searched to locate the programs of the job. If the program is not found in JOBLIB, then the system looks for it in the libraries specified in LNKLIST. STEPLIB is specific to a step, and specifies the library to be used for the program(s) that are being invoked within the step. If program is not found in STEPLIB, then search is made in JOBLIB and then the libraries specified in LNKLIST are searched for. If the program load module could not be located in any of the libraries, then abend S806 (program not found) occurs.

Page 73

TSO-JCL-VSAM

HTC Confidential

GENERAL CODING RULES OF JCL STATEMENTS JCL statements contain // in the first two columns JCL statements has three components to it: Name: coded immediately after // with no intervening space. The naming standards for this name are: The name must be 1 to 8 alphanumeric or national characters. The national characters are @, and # The first character should be alphabetic or national character Operator: coded as JOB or EXEC or DD, with at least one blank after the name. Parameter: coded after operator with at least one blank as a delimiter. Positional and keyword parameters: Keyword parameters are coded with keyword followed by equal sign and value of the parameter, e.g.,DSN=HTC.CHENNAI.EMPFILE is a keyword parameter. Positional parameters are position dependent and JCL expects them in the position they are intended to be.
Page 74 TSO-JCL-VSAM HTC Confidential

For instance the sub-parameters of DISP

are positional.

DIS=(OLD,KEEP,DELETE) indicates OLD (first sub-parameter) to be the disposition of the file before the step initiation, KEEP (second subparameter) to be action taken after normal completion and DELETE (third sub-parameter) to be the action taken after abend of the step. To skip positional parameters, use comma as a space holder for the positional parameter being skipped. Examples: DISP=(,KEEP,DELETE) DISP=(,,DELETE) DISP=(OLD,KEEP) In the last example we are not specifying the third positional parameter. No need to code a comma there as that is the last positional subparameter of DISP.
Page 75 TSO-JCL-VSAM HTC Confidential

Statement Continuation JCL statement is understood to be continued on to the next line, if the last character of the parameter part is a comma. Comment coding rules //* in the first three columns make a JCL line to be a comment. Comments can be coded on a JCL line after the parameters. There should be at least a space separating the parameters and the comments. Comments can be coded on continuation lines of JCL statement also.

Page 76

TSO-JCL-VSAM

HTC Confidential

JOB STATEMENT The JOB statement must be the first statement in every job. If multiple jobs are coded in an input stream, the JOB statement marks the end of the preceding job. The following is the syntax of the JOB statement: //<jobname> JOB <positional parameters><keyword parameters> Jobname should follow the standard naming convention for names defined in the previous section. This is the only required parameter on the JOB statement. When a JOB is submitted, it is assigned a unique number which can be used to reference a particular job along with the name.
Page 77 TSO-JCL-VSAM HTC Confidential

It is not mandatory to give unique names to the JOBs as we can uniquely refer to them with their job numbers. It is recommended to use unique names to JOBs for convenience. Only one job with a given job name will be in execution at any point in time. If more than one job is submitted with the same job name, one will go for execution and the others have to wait.

Page 78

TSO-JCL-VSAM

HTC Confidential

JOB STATEMENT POSITIONAL PARAMETERS ACCOUNTING INFORMATION PARAMETER Accounting information parameter identifies the account number to which the resources utilized by the job such as CPU time, DASD usage, Printer usage etc., will be billed to. The syntax of this parameter is: <account #>,<additional accounting information> enclosed in parentheses or quotation marks. If account # is omitted a comma must be coded to indicate the absence of the account number.

Page 79

TSO-JCL-VSAM

HTC Confidential

PROGRAMMER NAME PARAMETER: This parameter can be used to specify the name of the person submitting the job and or any other information that might help us identify or classify the job. A maximum of 20 characters can be coded for this parameter. Ex //JPOP01D JOB (00028, 723,10), CHARY ORD GEN Job name is JPOP02D. Account number is installation dependent. The programmer name parameter is specifying the name of the person as well as some description of the job. If we need to include quote mark in the programmer name parameter or any other parameter then two quote marks should be used. Ex. //JPOP02D JOB (0028, 753, 15), O NIEL ORD REPT
Page 80 TSO-JCL-VSAM HTC Confidential

JOB STATEMENT KEYWORD PARAMETERS Keyword parameters follow positional parameters. The following are a few important keyword parameters on JOB Statement: CLASS MSGCLASS ASGLEVEL TYPRUN TIME REGION and RESTART
Page 81 TSO-JCL-VSAM HTC Confidential

CLASS Parameter: The class parameter places the job in a job queue indicated by class. Jobclass is of one character. A through Z or 0 through 9. One can only use those job classes that have been defined in the installation. This parameter is coded as CLASS=<jobclass> such as CLASS=1 etc. Jobclass is used to categorize jobs submitted to the system such as production jobs, test jobs, long running jobs, short running jobs, jobs needing type devices etc. Operating system itself assigns no meaning to this job Class. Purpose of the job class is to provide guidelines for job submission. Jobs are executed through what are called initiators. Jobs submitted in a job class are executed through one or more initiators.
Page 82 TSO-JCL-VSAM HTC Confidential

MSGCLASS parameter: This parameter specifies a class to which the JOB log output should be written. The JOB log contains system messages and JCL messages MSGCLASS is of one character, A through Z, or 0 through 9. MSGCLASS can be used to direct the outputs of jobs to different classes. Format of the MSGCLASS parameter is MSGCLASS=<output class> Ex. MSGCLASS=A The message classes are defined at the system initialization time and are installation dependent.

Page 83

TSO-JCL-VSAM

HTC Confidential

MSGLEVEL parameter The MSGLEVEL parameter specifies now the JCL statements and job execution messages given by the system are to be output. The output goes to the output class specified in the MSGCLASS parameter. MSGLEVEL has two sub-parameters. The first one controls the printing of JCL statements to the output queue as follows: 0 Print only the JOB statement 1 Print all JCL & JES statements including the procedures 2 Print only submitted JCL statements. i.e., procedures are not expanded

Page 84

TSO-JCL-VSAM

HTC Confidential

The second sub-parameter controls which messages will be printed in the job log. The following are the values and actions taken. 0 print only JCL messages on normal termination and all messages on abnormal termination. 1 print all messages whether or not the job terminates abnormally.

MSGLEVEL=(1,1) spools all the statements & all the messages of a job.

Page 85

TSO-JCL-VSAM

HTC Confidential

TYPRUN parameter: TYPRUN parameter indicates the type of the run. If this parameter is not specified JOB is put in the queue and executes when it is its turn. The following table gives the values that can be coded for TYPRUN and the corresponding actions: TYPRUN=SCAN TYPRUN=HOLD JCL will be scanned for syntax error but will not be executed Job will be held in the input queue and will be executed once the operator releases it

Page 86

TSO-JCL-VSAM

HTC Confidential

RESTART parameter: This optional keyword parameter specifies a step name from which the job execution must start. System skips all the steps up to the specified step and starts executing the job from that step on. This is coded as RESTART=<step name>. Ex: // RESTART=EMPLST.STEP2 EMPLST is the PROC and STEP2 is a step within EMPLST proc.

Page 87

TSO-JCL-VSAM

HTC Confidential

TIME This parameter specifies the amount of CPU time that the job can utilize. TIME =(MM,SS) MM minutes between 1 1439 SS seconds between 1 59 Eg: //JOB1 JOB (A 123), CHARY, TIME=(,30) It indicates that 30 seconds of CPU time is allotted to job.

Page 88

TSO-JCL-VSAM

HTC Confidential

REGION The default address space size assigned to programs executing within a job can be overridden via the REGION parameter. Region = value K / M K Kilo bytes M Mega bytes Eg: //JOB1

JOB (A 123), TEST JOB, REGION=8M

Page 89

TSO-JCL-VSAM

HTC Confidential

EXEC STATEMENT EXEC is used to execute programs or procedures both catalogued & in-stream. Procedures again consist of step that execute programs. Each step begins with an EXEC statement. Format of the EXEC statement that specifies a program to execute is: //stepname EXEC PGC=program name, keyword parameters Keyword parameters on the EXEC statement: PARM COND

Page 90

TSO-JCL-VSAM

HTC Confidential

PARM: Supplies parameters to the executing program COBOL Programs receive these parameters in Linkage Section System Prefixes the parameter data with length of the parameters Parameter length is available in a half word binary data field Parameter up to 100 characters can be pressed Parameters containing special characters need to be enclosed in apostrophes. Ex: // EXEC PGM=EMPRPTP, PARM=D05

Page 91

TSO-JCL-VSAM

HTC Confidential

COND COND parameter instructs the system whether or not to excute the step based on the return codes of the prior steps. Ex: //STEP1 EXEC PGM=PGM1 //STEP2 EXEC PGM=PGM2, COND=(4,LT) //STEP3 EXEC PGM=PGM3, // COND=((4,EQ,STEP1),(4,LT,STEP2)) If 4 is less than the condition code of STEP1 (i.e. return code of STEP1 Is > 4), do not execute STEP2. If STEP1s return code is 4 OR STEP2s return code > 4, do not Execute STEP3.
Page 92 TSO-JCL-VSAM HTC Confidential

COND=ONLY specifies that the step should be executed only if any of the prior steps terminates abnormally. COND=EVEN specifies that the step should be executed even if any of the prior steps terminates abnormally. The range of return code is 0 to 4095. The comparison operators are: GT, GE, LT, LE, EQ, NE.

Page 93

TSO-JCL-VSAM

HTC Confidential

Executing a PROC: Format of the exec statement to execute a PROC is: // EXEC PEMPLST, // ENV=TEST, ENV=TEST,QA,PROD // BR=CHENNAI, //* BR=CHENNAI,SJ,CHICAGO //* GR,MP Assume that the proc PEMPST is catalogued and available in HTC.TEST.PROCLIB. We specify the procedure library from which the PROC needs to be fetched in PROCLIB DD statement: //PROCLIB TO DSN=HTC.TES.PROCLIB, DISP=SHR.

Page 94

TSO-JCL-VSAM

HTC Confidential

DD STATEMENT DD statements link data sets (files) to programs. DD statements make programs independent of the files, the devices files reside on and to some extent the physical characteristics of the file such as blocking factor. However the record length and layout of the file should be the same as the one defined in the program to give desired results. Format of the DD statement: //name DD positional parameters, keyword parameters Name coded is DD name and is the one that is known to the programs.
Page 95 TSO-JCL-VSAM HTC Confidential

POSITIONAL PARAMETERS: * or DATA indicates in-stream data. Ex: //SYSIN DD * //SYSIN DD DATA DUMMY indicates a null file Ex: //SYSIN DD DUMMY //OUTFL DD DUMMY, // DCB=(RECFM=F, LRECL=80) Read from a null file will result in end of file condition. Any number of writes to the null file will be successful.

Page 96

TSO-JCL-VSAM

HTC Confidential

DD STATEMENT - KEYWORD PARAMETERS There are many keyword parameters that can be specified and we will limit ourselves to the following: DSN DISP SPACE DCB UNIT VOLUME SYSOUT

Page 97

TSO-JCL-VSAM

HTC Confidential

DSN (Data Set Name): Non qualified Names: Non qualified Names consists of 1 to 8 alphanumeric or national characters. The first character must not be a numeric. These names are very rarely used. Ex: DSN=TESTFILE Qualified Names: Qualified names consists of two or more non qualified names separated by periods. Ex: HTC.TEST.CHENNAI.EMPFILE Data set name can be up to 44 characters including periods. GDG names can be up to 34 characters. This is because system automatically assigns an 8 character generation number and version number as the last qualifier.
Page 98 TSO-JCL-VSAM HTC Confidential

DD STATEMENT - DISP PARAMETER DISPosition parameter has three positional parameters. The first one specifies the status of the data set before the execution of the program. Second one indicates the action to be performed after the normal completion of the job step Third positional parameter indicates the action to be performed if the job step terminates abnormally. Syntax: DISP=(status, normal disposition, abnormal disposition) Default for the status sub-parameter is NEW. Defaults for the normal disposition and abnormal disposition subparameters are: KEEP if the data set being accessed exists & DELETE if the data set being accessed is new.

Page 99

TSO-JCL-VSAM

HTC Confidential

Values that can be coded for DISP parameter are: Status OLD NEW SHR MOD Normal Disposition KEEP DELETE CATLG UNCATLG PASS Abnormal Disposition KEEP DELETE CATLG UNCATLG

Page 100

TSO-JCL-VSAM

HTC Confidential

DD STATEMENT - SPACE PARAMETER When creating a data set on a DASD, space must be specified. Format: SPACE=(unit of measure, (primary, secondary, dir blocks), RLSE) First sub-parameter can beTRK for tracks, CYL for cylinders, block size, specifying that allocation be made in terms of blocks. Quantity specified by primary allocation is allocated upon the allocation of the data set. Quantity indicated by secondary is allocated on the need basis. This allocation is done for a maximum of 15 times.

Page 101

TSO-JCL-VSAM

HTC Confidential

Directory blocks sub-parameter is required for Partitioned Data Sets. RLSE (release) sub parameter indicates that the unused space at the time of closing the file to be released. Other sub parameters indicates that the unused space at the time specified. CONTIG & MIXIG apply for the primary allocation only. CONTIG specifies that only contiguous space should be allocated for the dataset. MXIG specifies that the largest available contiguous space should be allocated. ROUND rounds off the space allocated to the nearest cylinder.
Page 102 TSO-JCL-VSAM HTC Confidential

DD STATEMENT - DCB PARAMETER Format: DCB=(RECFM=<recfm>,LRECL=nnn, BLKSIZE==nnnn, DSORG=xx) DSORG specifies the data set organization of the data set. DSORG=PS for physical sequential data sets and PS is the default. DSORG=PO must be specified while creating a PDS. RECFM is the record format sub-parameter and some of the values are F for fixed FB for fixed blocked V for variable VB for variable blocked A Records contain ISO/ANSI Characters If block contains 0 is coded in the FD for a file, then the block size specified in the DCB parameters is used. If any value other than 0 is coded for block contains clause in FD, then the value must match with the one coded in DCB.
Page 103 TSO-JCL-VSAM HTC Confidential

EX: //OUTFL DD DSN=HTC.TEST.OUTFILE, // DSP=(NEW, CATLG, DELTET), // UNIT=SYSDA, // SPACE=(CYL,(5.1),RLSE) // DCB=(RECFM=FB, LRECL=80, BLKSIZE=800)

Page 104

TSO-JCL-VSAM

HTC Confidential

DD STATEMENT - UNIT, VOLUME & SYSOUT PARAMETERS When creating a data set, it is imperative to indicate the unit on which the data set will be created. e.g., UNIT=TAPE UNIT=SYSDA etc. The above is a specification of device groups. Device types can also be specified such as UNIT=3380. Hardware addressed of the devices may also be specified such as UNIT=S05. UNIT=(TAPE,, DEFER) specifies that the tape need not be mounted till the program is ready to use it, i.e, the program issues an open command for the file. UNIT=AFF==ddname can be specified to indicate that the UNIT should equal that of the given DD statement.
Page 105 TSO-JCL-VSAM HTC Confidential

VOLUME parameter: The volume parameter may be used to indicate the volume to be mounted as follows: //XDD UNIT=(TAPE,,DEFER), VOL=SER=345783, // ... Tape volume numbered 345783 is requested to be mounted when the program opens the file denoted by the DD name X. SYSOUT Parameter: Denotes the class to which the output will be sent. The other options that we can give for SYSOUT are DEST & COPIES. //SYSOUT DD SYSOUT=A,DEST=RMT99, COPIES=2

Page 106

TSO-JCL-VSAM

HTC Confidential

IEBCOMPR IEBCOMPR is a data set utility, to compare two sequential or two partitioned data sets. DD names used by IEBCOMPR utility are SYSPRINT Defines a sequential message data set, which can be written to a system output device. SYSUT1 Defines the first input data set to be compared. SYSUT2 Defines the second input data set to be compared. SYSIN Control statements for Compare are given in SYSIN. If DUMMY is specified then the default is for comparison of two sequential data sets. Format of the Control statement is //SYSIN DD * COMPARE TYPEORG={PS / PO} /* PS is default for TYPEORG. If two PDSs are to be compared then PO should be given.
Page 107 TSO-JCL-VSAM HTC Confidential

Example for Comparison of two Sequential data sets //COMP1 JOB //STEP1 EXEC PGM=IEBCOMPR //SYSPRINT DD SYSOUT=A //SYSUT1 DD DSN=HTC.CHENNAI.EMPFILE, DISP=SHR //SYSUT2 DD DSN=HTC.CHENNAI.EMPFILE1, DISP=SHR //SYSIN DD DUMMY // If Control data set i.e., Input stream is provided, then //SYSIN DD * COMPARE TYPEORG=PS /* PS specifies that input data sets are sequentially organized

Page 108

TSO-JCL-VSAM

HTC Confidential

Example for Comparison of two Partitioned data sets //STEP2 EXEC PGM=IEBCOMPR //SYSPRINT DD SYSOUT=A //SYSUT1 DD DSN=HTC.TEST.COBOL, DISP=SHR //SYSUT2 DD DSN=HTC.TEST.COBOL1, DISP=SHR //SYSIN DD * COMPARE TYPEORG=PO /* //

Page 109

TSO-JCL-VSAM

HTC Confidential

IEBCOPY IEBCOPY is the utility used to copy one or more partitioned data sets or to merge partitioned data sets. IEBCOPY can be used to Create a backup copy of a partitioned data set. Copy one or more data sets per copy operation. Copy one partitioned data set to a sequential data set. Copy one or more data sets created by an unload operation to any direct access device. Select members from a data set to be copied, unloaded, or loaded. Replace identically named members on data sets.

Page 110

TSO-JCL-VSAM

HTC Confidential

Replace selected data set members. Rename selected members Exclude members from a data set to be copied, unloaded, or loaded. Compress partition data sets in place. Merge data sets. Re-create a data set that has exhausted its primary, secondary, or directory space allocation. Alter load modules in place. Copy and reblock load modules. In addition, IEBCOPY automatically lists the number of unused directory blocks and the number of unused tracks available for member records in the output Partitioned data set.

Page 111

TSO-JCL-VSAM

HTC Confidential

Utility control Statements: COPY : Indicates the beginning of a COPY operation SELECT : Specifies which members in the input data set are to be copied. EXCLUDE: Specifies members in the input data set to be excluded from the copy step. The absence of a SELECT or EXCLUDE statement implies a full copy which is the default.

Page 112

TSO-JCL-VSAM

HTC Confidential

Examples of IEBCOPY //STEP1 EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=A //INOUT1 DD DSN=HTC.TEST.COBOL1, DISP=SHR //INOUT2 DD DSN=HTC.TEST.COBOL, DISP=SHR //SYSUT3 DD DSN=&&TEMPDAT1, // DISP=(NEW, DELETE, DELETE), // UNIT=SYSDA, SPACE=(TRK, 1) //SYSUT4 DD DSN=&&TEMPDAT2, // DISP=(NEW, DELETE, DELETE), // UNIT=SYSDA, SPACE=(TRK, 1) //SYSIN DD * COPYOPER COPY OUTDD=INOUT1, INDD=INOUT2 /* After the copy operation is finished, the output data set will contain the same members that are on the input data set; however, there will be no embedded, unused space on HTC.TEST.COBOL1.
Page 113 TSO-JCL-VSAM HTC Confidential

SYSUT3 and SYSUT4 are temporary spill data sets may or may not be opened, depending on the amount of virtual storage available. REPLACE option //SYSIN DD * COPY OVER COPY OUTDD=INOUT1 INDD=((INOUT2,R)) /* The above Syntax shows usage of REPLACE. If in the above example HTC.TEST1.COBOL is an existing PDS then R (Replace) option replaces all the members of HTC.TEST1.COBOL with HTC. TEST.COBOL
Page 114 TSO-JCL-VSAM HTC Confidential

SELECT AND EXCLUDE statements If HTC.TEST.COBOL consists of PROG1, PROG2, PROG3, PROG4 etc., as its members the SELECT Statement copies only PROG1 and PROG2 to HTC.TEST1.COBOL. //SYSIN DD * COPYOVER COPY OUTDD=INOUT1 INDD=INOUT2 SELECT MEMBER=(PROG1, PROG2) /* // If HTC.TEST.COBOL consists of PROG1, PROG2, PROG3, PROG4 etc., as its members the SELECT Statement copies only PROG1 and PROG2 to HTC.TEST1.COBOL.
Page 115 TSO-JCL-VSAM HTC Confidential

//SYSIN COPYOVER

DD * COPY OUTDD=INOUT1 INDD=INOUT2 EXCLUDE MEMBER=(PROG1, PROG2)

/* In the above JCL the members PROG1 and PROG2 are excluded and the remaining members are copied from HTC.TEST.COBOL to HTC.TEST1.COBOL. If OUTDD is a sequential data set an unload operation is performed i.e., all the members are copied to a sequential data set for backup

Page 116

TSO-JCL-VSAM

HTC Confidential

VSAM Course Objective: VSAM is an integral part of MVS, and at the end of this module we will Know the different types of VSAM data sets. Be able to create, delete and alter VSAM data sets, with indexes and alternate indexes. using IDCAMS. Be able to write COBOL programs using VSAM data sets Know the organization of VSAM data sets.

Page 117

TSO-JCL-VSAM

HTC Confidential

What is VSAM? VSAM is a high performance access method used in MVS, DOS/VSE & VM operating systems. VSAM software resides in virtual storage along with the program that needs its services for the manipulation of data on Direct Access Storage Device (DASD). IDCAMS is the utility program used for operating on VSAM data sets.

Page 118

TSO-JCL-VSAM

HTC Confidential

Advantages Faster Access Device Independence Records can be accessed sequentially or randomly Reorganization overheads are less and transparent to the user Simple to code the JCL required Disadvantage Require more storage because of Control Intervals and Control Areas Free Space Can be slow because of bad design (Solution: Re-organization)
Page 119 TSO-JCL-VSAM HTC Confidential

VSAM CLUSTER TYPES Key Sequenced Data Set Entry Sequenced Data Set Relative Record Data Set Linear Data Set

KSDS ESDS RRDS LDS

Page 120

TSO-JCL-VSAM

HTC Confidential

VSAM BUILDING BLOCKS Control Interval A unit of data that is transferred between auxiliary storage and virtual storage. It contains records, free space and control information. Control Area The building block of a VSAM data set. Consists of a group of control intervals. Used for distributing free space and local reorganizing for a KSDS. RDF ( Record Definition Field) : A field that contains 3 bytes information about the record. This will be part of CI. CIDF ( Control Interval Definition Field) : A 4 byte field consisting of information about the offset and the length of the free space in the CI.
Page 121 TSO-JCL-VSAM HTC Confidential

KEY SEQUENCED DATA SET (KSDS) Consists of Index Component and Data Component. Can have both fixed and variable length records. Size and CA are very important. Bigger size results in getting more records at a time and reduce the number of I-Os Smaller size results in getting less records at a time and increases the number of I-Os For random access processing, Smaller size is recommended For sequential access processing, Bigger size is recommended

Page 122

TSO-JCL-VSAM

HTC Confidential

Size of Free Space is also very important. Bigger size results in accommodating future insertions andreduce the number of Splits Smaller size results in good performance for sequential processing Records stored in ascending collating sequence of the primary key field. Records can be retrieved and inserted, both randomly and sequentially. Records can be physically deleted, thus freeing space to be reused for other instructions. The primary key must be unique and cannot be modified while updating. Records can also be accessed in any sequence other than the primary key field. Such a key is called as Alternate Key and need not be unique. Most frequently used VSAM type.

Page 123

TSO-JCL-VSAM

HTC Confidential

INDEX COMPONENT An independent constituent of KSDS, catalog or alternate index that helps in establishing the sequence of records in the data component. Contains the key fields and pointers to the location of the record to which that key field belongs. Further divided into: Index Set Sequenced Set DATA COMPONENT Contains the records that hold the user data, including the key field. The part of the cluster or an alternate index that contains the data records.

Page 124

TSO-JCL-VSAM

HTC Confidential

Diagrammatic Representation INDEX COMPONENT INDEX IS1 SET IS2 IS3 SS1 SS2 SS3 SS4 SS5 SS6 DATA COMPONENT CA1 CI1 Data Free space in CI RDF(3bytes) bytes) C12 C13 .... Free Space in CA CA2 CA3
Page 125 TSO-JCL-VSAM

CIDF (4

HTC Confidential

ENTRY SEQUENCED DATA SETS (ESDS) Can be fixed or variable Block. Any new Records placed in the end of the data set. Mostly sequential, but access can be direct if RBA is provided. A record cannot be deleted physically. On deletion, record will be marked that the record was deleted but this space can not be used by some other records. Records can be updated without changing the length of the record. No Primary key Can have alternate by (useful for searching) RBA (Relative Byte Address ) : The displacement of a data record or a control interval from the beginning of the data set.

Page 126

TSO-JCL-VSAM

HTC Confidential

CL 1 RECORD1 REC2 REC3

UNUSED SPACE RDF RDF CIDF

RBA 0 CL 2 RECORD5 RECORD6 RECORD7 RECORD8 UNUSED RDF CIDF SPACE RBA 4046 CL 3 RECORD9 RECORD10 UNUSED RDF RDF CIDF RBA 8192

Page 127

TSO-JCL-VSAM

HTC Confidential

RELATIVE RECORD DATA SET (RRDS) Data Component only No Index Component Record length is fixed Records are always stored in pre-formatted slots Random load requires user program. Record are accessed by the position in the file from the first record Can be retrieved randomly or by sequentially As the relative location of records is fixed, no need for reorganization Records can be inserted, modified or deleted randomly or sequentially Free space on deletion can be reused
Page 128 TSO-JCL-VSAM HTC Confidential

Diagrammatic Representative CA1 D CI 0 SLOT1 SLOT2 SLOT3 SLOT4 A T C1 1 SLOT5 SLOT6 SLOT7 SLOT8 A C1 2 SLOT9 SLOT10 SLOT11 SLOT12 C A C1 3 SLOT13 SLOT14 SLOT15 SLOT16 CA2 D CI 0 SLOT17 SLOT18 SLOT19 SLOT20 A T C1 1 SLOT21 SLOT22 SLOT23 SLOT24 A C1 2 SLOT25 SLOT26 SLOT27 SLOT28 C A C1 3 SLOT29 SLOT30 SLOT31 SLOT32
Page 129 TSO-JCL-VSAM HTC Confidential

LINEAR DATA SETS (LDS) CI size always fixed, Maximum of 4K Only data component Required CI and CA are blocked before the application program is run. Used by DB/2 data base Diagrammatic Representation DATA CA CI DATA CI DATA CI DATA CI DATA

Page 130

TSO-JCL-VSAM

HTC Confidential

KSDS Organization SEQUENCE SET CI 4037 4065 4077 FS Data CA CI 0 4012 4023 4034 4037 FREE SPACE CI 1 4041 4050 4052 4065 FREE SPACE CI 2 4072 4073 4075 4077 FREE SPACE CI 3 FREE SPACE

Page 131

TSO-JCL-VSAM

HTC Confidential

UPDATING A KSDS INSERT 4058 SEQUENCE SET CI 4037 4065 4077 FS Data CA CI 0 4012 4023 4034 4037 FREE SPACE CI 1 4041 4050 4052 4058 4065 CI 2 4072 4073 4075 4077 FREE SPACE CI 3 FREE SPACE

Page 132

TSO-JCL-VSAM

HTC Confidential

CONTROL INTERVAL SPLIT INSERT 4046 SEQUENCE SET CI 4037 4050 4065 4077 FS Data CA CI0 4012 4023 4034 4037 FREE SPACE CI1 4041 4046 4050 FREE SPACE CI2 4072 4073 4075 4077 CI3 4052 4058 4065 FREE SPACE The movement of some records from an existing CI to another free CI in the same CA is necessary because the record to be added cannot be accommodated in the existing one. Results in two half-empty CI's instead of one full and one empty CI.
Page 133 TSO-JCL-VSAM HTC Confidential

CONTROLAREASPLIT INSERT 4074 INDEX SET 4074 4077 FS SS1 4037 4050 4074FS SS2 4065 4077 FS

Page 134

TSO-JCL-VSAM

HTC Confidential

CA1 CI0 4012 4023 4034 4037 FREE SPACE CI1 4041 4046 4050 FREE SPACE CI2 4072 4073 4074 FREE SPACE CI3 FREE SPACE CA2 CI0 4075 4077 CI1 4052 4058 4065 CI2 CI3

FREE SPACE FREE SPACE FREE SPACE FREE SPACE

Page 135

The movement of half of the records in an existing control area to a new control area because a record add or update cannot be accommodated in the existing control area. There results in two approximately half-full control areas instead of one full and one empty CA.
TSO-JCL-VSAM HTC Confidential

ACCESS METHOD SERVICES-IDCAMS UTILITY Access Method Services (AMS) is a multifunctional service program that helps in performing various functions on VSAM files, nonVSAM files, VSAM catalogs and ICF catalogs. Such information include allocations, deletions, loading, printing, alternate indexing, reorganizations, alterations, backups of catalogs and data sets. Purpose of IDCAMS Allocating, maintaining and deleting catalogs. Allocating, maintaining and deleting VSAM data sets. Reorganizing and printing data sets. Cataloging Non-VSAM data sets and Generating Data Group (GDG) Defining page space for the MVS operating system.

Page 136

TSO-JCL-VSAM

HTC Confidential

AMS COMMANDS DEFINE CLUSTER Used to allocate VSAM data sets (KSDS, ESDS AND RRDS). If cluster is KSDS then an index component and data component are allocated. REPRO Used to load records into a VSAM data set. May be used to load records from an ISAM to a VSAM cluster. Can also be used to copy data from a PS to VSAM or a PDS member to VSAM and vice versa. DEFINE ALTERNATE INDEX Used to allocate an alternate index cluster. Only allocates and does not load the records into the alternate index. The base cluster must exist before an alternate index is defined.
Page 137 TSO-JCL-VSAM HTC Confidential

PRINT Used to get a character dump and / or hex dump of a VSAM data set. Can also be used in printing ISAM files, physical sequential files, or PDS members. Selective portions of the data set can also be printed. DELETE Used to delete VSAM and non-VSAM objects such as clusters, alternate indexes and paths. ALTER Used to change the characteristics of a VSAM data set or catalog without deleting or redefining the same. Changes could also include, changing of password, renaming of data sets, changing of free space in a KSDS etc.

Page 138

TSO-JCL-VSAM

HTC Confidential

DEFINE GDG Used to define Generation Data Groups. (GDG) GDG's are mainly used to store cyclic data. LISTCAT Used to list the characteristics of a VSAM data set or a Catalog. Lists the attributes defined and other characteristics such as secondary allocations, the number of records, the number of index levels and the number of CI and CA splits. DEFINE PATH Used to establish a path between an alternate index and the base cluster. The base cluster and the alternate index must exist before defining a path.

Page 139

TSO-JCL-VSAM

HTC Confidential

Page 140

JCL FOR INVOKING ACCESS METHOD SERVICES //JOBNAME JOB (ACCTINFO), PROG NAME //STEPNAME EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=A //SYSIN DD * Functional commands Positional parameters Keyword parameters Sub parameters Comments, etc. /* // Functional commands can be contained in more than one line with a continuation character (hyphen) specified in the previous line. The absence of hyphen as a last character in a line indicates the end of a functional command. All functional commands and their parameters must start in or after the 2nd column and cannot extend beyond the 72nd column.
TSO-JCL-VSAM HTC Confidential

JCL FOR DEFINING A CLUSTER: The basic information for defining a VSAM data set are The volume(s) on which the data set will be allocated. The type of data set (KSDS, ESDS or a RRDS) The space needed for the data set. For a KSDS, the length of the primary key and its offset from the beginning of the record The record size and whether it is fixed or variable in length The Control Interval size The CI and CA Free space for a KSDS The cluster name (This cluster name will be the data set name (DSN)).

Page 141

TSO-JCL-VSAM

HTC Confidential

SAMPLE JCL FOR DEFINING A VSAM CLUSTER: //TRGI01A JOB (ACCTNO), WALSH //DEFKSDS EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=A //SYSIN DD * DEFINE CLUSTER (NAME(userid.TRG1.KSDS) TRACKS(2,1) VOLUMES(USER01) CONTROLINTERVALSIZE(4096) FREESPACE(5,5) KEYS(9,0) RECORDSIZE(50,50)) DATA (NAME(userid.TRG1.DATA)) INDEX (NAME(userid.TRG1.KSDS.INDEX)CONTROLINTERVALSIZE (1024)) /* The KEYS parameters indicates that the primary key is 9 bytes long and starts in position 0 of the record. The record size has two values. The first value gives the average record length, and second gives the maximum record length. In the example both are equal because of fixed length records.
Page 142 TSO-JCL-VSAM HTC Confidential

Page 143

EXAMPLES JCL FOR COPYING RECORDS INTO A KSDS //TRGI01A JOB (ACCTNO), WALSH //LOADKSDS EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=A //SOURCE DD DSN=userid.INPUT.DATA, DISP=OLD //TARGET DD DSN=userid.KSDS.CLUSTER,DISP=OLD //SYSIN DD * REPRO INFILE (SOURCE) OUTFILE(TARGET) /* // Note: If the record are out of sequence then REPRO would return an error message. In such situations, an external sort step could be used to sort the input file before the execution of REPRO.
TSO-JCL-VSAM HTC Confidential

Example JCL that uses SORT and REPRO commands to Load a KSDS //AMSJOB JOB (ACCTNO), AKSHAY /****************SORT INPUT PS FILE********************* //SORT EXEC PGM=SORT //SORTLIB DD DSN=SYS1.SORTLIB,DISP=SHR //SORTIN DD DSN=userid.INPUT.DATA,DISP=OLD //SORTOUT DD DSN=&&TEMP, // DISP=(NEW,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=50,BLKSIZE=5000), // SPACE=(TRK,(5,1)),UNIT-SYSDA //SYSIN DD * SORT FIELDS=(1,9,CH,A) /*

Page 144

TSO-JCL-VSAM

HTC Confidential

//************** REPRO FROM SORTEDFILE *** //LOADKSDS EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=A //SOURCE DD DSN=&&TEMP, // DISP=(OLD, DELETE,DELETE), //TARGET DD DSN=userid.KSDS.CLUSTER, // DISP=OLD //SYSIN DD * REPRO INFILE (SOURCE) OUTFILE(TARGET) /* //
Page 145 TSO-JCL-VSAM HTC Confidential

VSAM CATALOG: Special purpose files residing on a DASD servicing as a central repository for information about all the data sets under its control. Contains name and physical location of data sets, password information required to access protected data set. Contains statistics about the data set such as number or records added, number of records read, deleted or number of CI, CA Splits and information about data set itself. ALTERNATE INDEX: Allows access to records in KSDS through a key which is based on any field in the record. Is a KSDS cluster having data and index component. Data Component of Alternate Index contains pointers to the base cluster of the KSDS cluster. Pointers in KSDS are the primary key and in case of ESDS it is the RBA.
Page 146 TSO-JCL-VSAM HTC Confidential

STEPS TO CREATE AIX Define the alternate index using the IDCAMS DEFINE AIX COMMAND Specify an alternate index path using the IDCAMS DEFINE PATH Command to form the connection between the alternate index and the base cluster. (Path will not contain any records but path name becomes a catalog entry). Build the alternate index and populate it with IDCAMS BLDINDEX command.

Page 147

TSO-JCL-VSAM

HTC Confidential

SAMPLE JCL FOR DEFINING An Alternate Index CLUSTER //TRGI101A JOB (ACCTNO), WALSH //DEFAIX EXEC PGM-IDCAMS //SYSPRINT DD SYSOUT=A //SYSIN DD * DEFINE AIX (NAME(userid.TRG1.KDSD.AIX) VOLUMES(USER01) CISZ(4096) TRACKS(2,1)RELATE (userid.TRG1.KSDS) UPGRADE CYLINDERS(2,1) FREESPACE(5,5) KEYS(9,0) RECORDSIZE(50,100)) NONUNIQUEKEY DATA (NAME(userid.TRG1.KSDS.AIX.DATA)) INDEX (NAME(userid.TRG1.KSDS.AIX.INDEX) ) /* //
Page 148 TSO-JCL-VSAM HTC Confidential

UPGRADEspecifiesthattheAIXistobeupdatedautomaticallyby thesystemwheneverthebaseclusterrecordsarechanged.Thisis thedefaultvalue.wecanspecifyNOUPDATEtospecifythatthe AIXshouldnotbeintheUPGRADE-SETanditistheprogrammer responsibilitytoupgradethisAIX.WewillspecifyNOUPDATE optiontoincreasetheperformanceinonlineapplications. InRECORDSIZEparameterwecanspecifytheminimumand maximumvaluesforAIX. RecLengthofUniquekeyAIX=5+Lengthofalternatekey+ Lengthofprimarykey RecLengthofnonUniquekeyAIX=5+Lengthofalternatekey+ n*Lengthofprimarykey,wherenisthenumberofallowed duplicatesforagivenalternatekeyvalue.
Page 149 TSO-JCL-VSAM HTC Confidential

SHAREOPTIONS providesthevaluesforcross-region(1,2,3,4)and cross-systemsharing(3,4).Thisoptionwillbeusedtosharethe VSAMfilebetweentheregionsandsystems.Defaultoptions are(1,3) BUILDINDEX canbeusedtoloadtheAIXafterAIXwasallocated. WhenBLDINDEXcommandwasexecuted,thefollowingfunctions willbeperformed RecordsofKSDSorESDSarereadsequentiallyandkeypointer pairsareextracted Allkey-pointerpairsaresortedinascendingorder Recordsofthesortedfilearereadsequentially.ForUnique keyAIX,oneAIXrecordwillbecreatedfromeachsortedinput andfornonuniquekeyAIX,oneAIXrecordwillbecreatedfor eachsetofmultipleinputrecordscontainingthesameAIXkeyin thekey-pointerpair.

Page 150

TSO-JCL-VSAM

HTC Confidential

SampleJCL //TRGI01A JOB (ACCTNO),WALSH //LOADAIX EXEC PGM=IDCAMS //BASE DDDSN=userid.TRG1.KSDS,DISP=OLD //AIX1 DD DSN=userid.TRG1.KSDS.AIX,DISP=OLD //IDCT1 DDDSN=SPORT.WORK.FILE.ONE, // DISP=OLD,AMP="AMPORG" //IDCUT2 DDDSN=SORT.WORK.FILE.TWO, // DISP=OLD,AMP="AMPORG" //SYSPRINT DD SYSOUT=A //SYSIN DD* BLDINDEX INFILE(BASE)OUTFILE(AIX1) //

Page 151

TSO-JCL-VSAM

HTC Confidential

IDCUT1ANDIDCUT2describe2filesusedforsort. AMP(Accessmethodparameter)complements informationinanaccesscontrolblock.Itisprimarilyused toallocateI/Obuffersfortheindexanddatacomponents foroptimumperformance.TheAMPORGparameter indicatestheparticularDDstatementreferstoasa VSAMdataset. DEFINE PATHcommandestablishesabridgebetween thebaseclusterandtheAIX.Thisisnotadatasetand willnotoccupyanyspaceanddoesnothaveany records..ItisjustalinkthatestablishesbetweenanAIX andbasecluster.Accessingbyitsnamegivesusthe recordsofthebasecluster(nottheAIX)inthealternate keysequencewhileaccessinganAIXwillgiveonlythe key-pointerrecords.
Page 152 TSO-JCL-VSAM HTC Confidential

SampleJCL //TRGIO1A JOB(ACCTNO),WALSH //DEFPATH EXECPGM=IDCAMS //SYSPARINT DDSYSOUT=A //SYSIN DD* DEFINEPATH (NAME(userid.TRG1.KSDS.PATH1)PATHENTRY(userid.TRG1.KSDS.AIX) UPDATE) /* //
Page 153 TSO-JCL-VSAM HTC Confidential

WhenapathwiththeUPDATEparameter(default)isopenedfor processing,thebaseclusteranditsupgradesetareopened automatically. WhenapathwiththeNOUPDATEparameter(default)isopened for processing,thebaseclusterisopenedbutitsupgradesetisnot opened. PRINTcommandisusedtoprinttherecordsofthebaseclusteror AIX. Ex: PRINT INDATASET(HTC.KSDS.EMPLOYEE) CHAR PRINT INDATASET(HTC.KSDS.EMPLOYEE.AIX1)CHAR PRINT INDATASET(HTC.KSDS.EMPLOYEE.PATH1) CHAR
Page 154 TSO-JCL-VSAM HTC Confidential

APPLICATION CODING CONSIDERATIONS BeforeusingtheVSAMfileintheCOBOLprogram,the VSAMbaseclustermustbedefinedandloadedandif thereareanyalternateindexestheyalso,mustbe defineddefinedandloaded. THEFOLLOWINGARETHENEWSELECT STATEMENTS ESDS SELECTFILE-A ASSIGNTOAS-FILEADD ORGANIZATIONISSEQUENTIAL FILESTATUSFILE-STAT

Page 155

TSO-JCL-VSAM

HTC Confidential

RRDS SELECTFILC-C ASSIGNTOFILECDD ORGANIZATIONISRELATIVE ACCESSMODEISRANDOM RELATIVEKEYISREC-NO FILESTATUSFILE-STAT KSDS SELECTFILE-B ASSIGNTOFILEBDD ORGANIZATIONISINDEXED ACCESSMODEISDYNAMIC REOCRDKEYISACCT-NO ALTERNATERECORDKEYIS SSNOWITHDUPLICATES FILESTATUSFILE-STAT
Page 156 TSO-JCL-VSAM HTC Confidential

Page 157

TSO-JCL-VSAM

HTC Confidential

Page 158

TSO-JCL-VSAM

HTC Confidential

Page 159

TSO-JCL-VSAM

HTC Confidential

Page 160

TSO-JCL-VSAM

HTC Confidential

Page 161

TSO-JCL-VSAM

HTC Confidential

Você também pode gostar