JCL – Utility Programs

JCL – Utility Programs ”; Previous Next IBM Dataset Utilities Utility programs are pre-written programs, widely used in mainframes by system programmers and application developers to achieve day-to-day requirements, organising and maintaining data. A few of them are listed below with their functionality: Utility Name Functionality IEHMOVE Moves or copies sequential datasets. IEHPROGM Deleting and renaming datasets; catalog or uncatalog datasets other than VSAM. IEHCOMPR Compares data in sequential datasets. IEBCOPY Copy, Merge, compress, back-up or restore PDS. IEFBR14 No operation utility. Used to return control to user and terminate. It is usually used to create empty dataset or delete an existing dataset. For example, if a dataset is passed as input to a IEFBR14 program with DISP=(OLD,DELETE,DELETE), the dataset is deleted at job completion. IEBEDIT Used to copy selected parts of a JCL. For Example, if a JCL has 5 steps and we require to execute step 1 and 3 only, then a IEBEDIT JCL can be coded with a dataset which contains the actual JCL to be executed. In the SYSIN of IEBEDIT, we can specify STEP1 and STEP3 as parameters. When this JCL is executed, it executes the STEP1 and STEP3 of the actual JCL. IDCAMS Create, delete, rename, catalog, uncatalog datasets (other than PDS). Usually used to manage VSAM datasets. These utility programs need to be used with appropriate DD statements in a JCL in order to achieve the specified functionality. DFSORT Overview DFSORT is a powerful IBM utility used to copy, sort or merge datasets. SORTIN and SORTINnn DD statements are used to specify input datasets. SORTOUT and OUTFIL statements are used to specify output data. SYSIN DD statement is used to specify the sort and merge conditions. DFSORT is generally used to achieve the below functionalities: SORT the input file(s) in the order of the specified field(s) position in the file. INCLUDE or OMIT records from the input file(s) based on the specified condition. SORT MERGE input file(s) in the order of the specified field(s) position in the file. SORT JOIN two or more input files based on a specified JOIN KEY (field(s) in each input file). When there is additional processing to be done on the input files, a USER EXIT program can be called from the SORT program. For example, if there is a header/trailer to be added to the output file, then a USER written COBOL program can be called from the SORT program to perform this functionality. Using a control card, data can be passed to the COBOL program. On the other way round, a SORT can be called internally from a COBOL program to arrange the input file in a particular order before being processed. Usually, this is not recommended in view of performance for large files. ICETOOL Overview ICETOOL is a multi-purpose DFSORT utility used to perform a variety of operations on datasets. Input and output datasets can be defined using user defined DD names. The file operations are specified in the TOOLIN DD statement. Additional conditions can be specified in user defined ”CTL” DD statements. Few of the utilities of ICETOOL are given below: ICETOOL can achieve all the functionalities of DFSORT in one or more conditions. SPLICE is a powerful operation of ICETOOL which is similar to SORT JOIN, but with additional features. It can compare two or more files on specified field(s) and create one or more output files like file with matching records, file with non-matching records, etc. Data in one file in a particular position can be OVERLAYed into another position in the same or different file. A File can be split into n files based on a specified condition. For example, a file containing names of employees can be split into 26 files, each containing the names starting with A, B, C and so on. Different combination of file manipulation is possible using ICETOOL with a little exploration of the tool. SYNCSORT Overview SYNCSORT is used to copy, merge or sort datasets with a high performance. It gives best utilization of system resources and efficient operation in 31-bit and 64-bit address spaces. It can be used in the same lines of DFSORT and can achieve the same features. It can be invoked by a JCL or from within a program coded in COBOL, PL/1 or Assembler language. It also supports User Exit programs to be called from the SYNCSORT program. Frequently used sort tricks using these utilities are explained in the next chapter. Complex requirements, which requires a huge programming in COBOL/ASSEMBLER can be achieved using the above utilities in simple steps. Print Page Previous Next Advertisements ”;

JCL – Quick Guide

JCL – Quick Guide ”; Previous Next JCL – Overview When to use JCL JCL is used in a mainframe environment to act as a communication between a program (Example: COBOL, Assembler or PL/I) and the operating system. In a mainframe environment, programs can be executed in batch and online mode. Example of a batch system can be processing the bank transactions through a VSAM (Virtual Storage Access Method) file and applying it to the corresponding accounts. Example of an online system can be a back office screen used by staffs in a bank to open an account. In batch mode, programs are submitted to the operating system as a job through a JCL. Batch and Online processing differ in the aspect of input, output and program execution request. In batch processing, these aspects are fed into a JCL which is in turn received by the Operating System. Job Processing A job is a unit of work which can be made up of many job steps. Each job step is specified in a Job Control Language (JCL) through a set of Job Control Statements. The Operating System uses Job Entry System (JES) to receive jobs into the Operating System, to schedule them for processing and to control the output. Job processing goes through a series of steps as given below: Job Submission – Submitting the JCL to JES. Job Conversion – The JCL along with the PROC is converted into an interpreted text to be understood by JES and stored into a dataset, which we call as SPOOL. Job Queuing – JES decides the priority of the job based on CLASS and PRTY parameters in the JOB statement (explained in JCL – JOB Statement chapter). The JCL errors are checked and the job is scheduled into the job queue if there are no errors. Job Execution – When the job reaches its highest priority, it is taken up for execution from the job queue. The JCL is read from the SPOOL, the program is executed and the output is redirected to the corresponding output destination as specified in the JCL. Purging – When the job is complete, the allocated resources and the JES SPOOL space is released. In order to store the job log, we need to copy the job log to another dataset before it is released from the SPOOL. JCL – Environment Setup Installing JCL on Windows/Linux There are many Free Mainframe Emulators available for Windows which can be used to write and learn sample JCLs. One such emulator is Hercules, which can be easily installed in Windows by following few simple steps given below: Download and install the Hercules emulator, which is available from the Hercules” home site – : www.hercules-390.eu Once you installed package on Windows machine, it will create a folder like C:Mainframes. Run Command Prompt (CMD) and reach the directory C:Mainframes on CMD. The complete guide on various commands to write and execute a JCL can be found on URL www.jaymoseley.com/hercules/installmvs/instmvs2.htm Hercules is an open source software implementation of the mainframe System/370 and ESA/390 architectures, in addition to the latest 64-bit z/Architecture. Hercules runs under Linux, Windows, Solaris, FreeBSD, and Mac OS X. Running JCL on Mainframes A user can connect to a mainframe server in a number of ways such a thin client, dummy terminal, Virtual Client System (VCS) or Virtual Desktop System (VDS). Every valid user is given a login id to enter into the Z/OS interface (TSO/E or ISPF). In the Z/OS interface, the JCL can be coded and stored as a member in a Partitioned Dataset (PDS). When the JCL is submitted, it is executed and the output received as explained in the job processing section of previous chapter. Structure of a JCL The basic structure of a JCL with the common statements is given below: //SAMPJCL JOB 1,CLASS=6,MSGCLASS=0,NOTIFY=&SYSUID (1) //* (2) //STEP010 EXEC PGM=SORT (3) //SORTIN DD DSN=JCL.SAMPLE.INPUT,DISP=SHR (4) //SORTOUT DD DSN=JCL.SAMPLE.OUTPUT, (5) // DISP=(NEW,CATLG,CATLG),DATACLAS=DSIZE50 //SYSOUT DD SYSOUT=* (6) //SYSUDUMP DD SYSOUT=C (6) //SYSPRINT DD SYSOUT=* (6) //SYSIN DD * (6) SORT FIELDS=COPY INCLUDE COND=(28,3,CH,EQ,C”XXX”) /* (7) Program Description The numbered JCL statements have been explained below: (1) JOB statement – Specifies the information required for SPOOLing of the job such as job id, priority of execution, user-id to be notified upon completion of the job. (2) //* statement – This is a comment statement. (3) EXEC statement – Specifies the PROC/Program to be executed. In the above example, a SORT program is being executed (i.e., sorting the input data in a particular order) (4) Input DD statement – Specifies the type of input to be passed to the program mentioned in (3). In the above example, a Physical Sequential (PS) file is passed as input in shared mode (DISP = SHR). (5) Output DD statement – Specifies the type of output to be produced by the program upon execution. In the above example, a PS file is created. If a statement extends beyond the 70th position in a line, then it is continued in the next line, which should start with “//” followed by one or more spaces. (6) There can be other types of DD statements to specify additional information to the program (In the above example: The SORT condition is specified in the SYSIN DD statement) and to specify the destination for error/execution log (Example: SYSUDUMP/SYSPRINT). DD statements can be contained in a dataset (mainframe file) or as in stream data (information hard-coded within the JCL) as given in above example. (7) /* marks the end of in stream data. All the JCL statements except in stream data starts with //. There should be at least one space before and after JOB, EXEC and DD keywords and there should not be any spaces in rest of the statement. JOB Parameter Types Each of the JCL statements is accompanied by a set of parameters to help the Operating Systems in completing the program execution. The parameters can be of two types: Positional Parameters

JCL – Discussion

Discuss JCL ”; Previous Next Job Control Language (JCL) is the command language of Multiple Virtual Storage (MVS), which is the commonly used Operating System in the IBM Mainframe computers. JCL identifies the program to be executed, the inputs that are required and location of the input/output and informs the Operating System through Job control Statements. In mainframe environment, programs can be executed in batch and online modes. JCL is used for submitting a program for execution in batch mode. Print Page Previous Next Advertisements ”;

JCL – Basic Sort Tricks

JCL – Basic Sort Tricks ”; Previous Next The day-to-day application requirements in a corporate world that can be achieved using Utility Programs are illustrated below: 1. A file has 100 records. The first 10 records need to be written to output file. //JSTEP020 EXEC PGM=ICETOOL //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN1 DD DSN=MYDATA.URMI.STOPAFT,DISP=SHR //OUT1 DD SYSOUT=* //TOOLIN DD * COPY FROM(IN1) TO(OUT1) USING(CTL1) /* //CTL1CNTL DD * OPTION STOPAFT=10 /* The option STOPAFT will stop reading the input file after 10th record and terminates the program. Hence, 10 records are written to output. 2. Input file has one or more records for same employee number. Write unique records to output. //STEP010 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=MYDATA.URMI.DUPIN,DISP=SHR //SORTOUT DD SYSOUT=* //SYSIN DD * SORT FIELDS=(1,15,ZD,A) SUM FIELDS=NONE /* SUM FIELDS=NONE removes duplicates on fields specified in SORT FIELDS. In the above example, employee number is in the field position 1,15. The output file will contain the unique employee numbers sorted in ascending order. 3. Overwrite input record content. //JSTEP010 EXEC PGM=SORT //SORTIN DD DSN= MYDATA.URMI.SAMPLE.MAIN,DISP=SHR //SORTOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * OPTION COPY INREC OVERLAY=(47:1,6) /* In the input file, the content in position 1,6 is overwritten to the position 47,6 and then copied to the output file. INREC OVERLAY operation is used in order to rewrite data in input file before copying to output. 4. Adding a sequence number to the output file. //JSTEP010 EXEC PGM=SORT //SORTIN DD * data1 data2 data3 /* //SORTOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * OPTION COPY BUILD=(1:1,5,10:SEQNUM,4,ZD,START=1000,INCR=2) /* The output will be: data1 1000 data2 1002 data3 1004 4-digit sequence number is added in output at position 10, starting at 1000 and incremented by 2 for every record. 5. Adding Header/Trailer to output file. //JSTEP010 EXEC PGM=SORT //SORTIN DD * data1 data2 data3 /* //SORTOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * SORT FIELDS=COPY OUTFIL REMOVECC, HEADER1=(1:C”HDR”,10:X”020110131C”), TRAILER1=(1:C”TRL”,TOT=(10,9,PD,TO=PD,LENGTH=9)) /* The output will be: HDR 20110131 data1 data2 data3 TRL 000000003 TOT calculates the number of records in the input file. HDR and TRL are added as identifiers to header/trailer, which is user defined and can be customised as per the users” needs. 6. Conditional Processing //JSTEP010 EXEC PGM=SORT //SORTIN DD * data1select data2 data3select /* //SORTOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * INREC IFTHEN=(WHEN=(6,1,CH,NE,C” ”),BUILD=(1:1,15), IFTHEN=(WHEN=(6,1,CH,EQ,C” ”),BUILD=(1:1,5,7:C”EMPTY ”) OPTION COPY /* The output will be: data1select data2 EMPTY data3select Based on the 6th position of the file, the BUILD of output file varies. If 6th position is SPACES, then text “EMPTY” is appended to input record. Else, the input record is written to output, as-is. 7. Backing up a file //JSTEP001 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSIN DD * //SYSOUT DD SYSOUT=* //SORTOUT DD DUMMY //SYSUT1 DD DSN=MYDATA.URMI.ORIG,DISP=SHR //SYSUT2 DD DSN=MYDATA.URMI.BACKUP,DISP=(NEW,CATLG,DELETE), // DCB=*.SYSUT1,SPACE=(CYL,(50,1),RLSE) IEBGENER copies the file in SYSUT1 to file in SYSUT2. Please note that file in SYSUT2 takes the same DCB as that of the SYSUT1 in the above example. 8. File Comparison //STEP010 EXEC PGM=SORT //MAIN DD * 1000 1001 1003 1005 //LOOKUP DD * 1000 1002 1003 //MATCH DD DSN=MYDATA.URMI.SAMPLE.MATCH,DISP=OLD //NOMATCH1 DD DSN=MYDATA.URMI.SAMPLE.NOMATCH1,DISP=OLD //NOMATCH2 DD DSN=MYDATA.URMI.SAMPLE.NOMATCH2,DISP=OLD //SYSOUT DD SYSOUT=* //SYSIN DD * JOINKEYS F1=MAIN,FIELDS=(1,4,A) JOINKEYS F2=LOOKUP,FIELDS=(1,4,A) JOIN UNPAIRED,F1,F2 REFORMAT FIELDS=(?,F1:1,4,F2:1,4) OPTION COPY OUTFIL FNAMES=MATCH,INCLUDE=(1,1,CH,EQ,C”B”),BUILD=(1:2,4) OUTFIL FNAMES=NOMATCH1,INCLUDE=(1,1,CH,EQ,C”1”),BUILD=(1:2,4) OUTFIL FNAMES=NOMATCH2,INCLUDE=(1,1,CH,EQ,C”2”),BUILD=(1:2,4) /* JOINKEYS specifies the field on which the two files are compared. REFORMAT FIELDS=? places ”B” (matched records), ”1” (present in file1, but not in file2), or ”2” (present in file2 but not in file1) in the 1st position of the output BUILD. JOIN UNPAIRED does a full outer join on the two files. The output will be: MATCH File 1000 1003 NOMATCH1 File 1001 1005 NOMATCH2 File 1002 The same functionality can be achieved using ICETOOL also. Print Page Previous Next Advertisements ”;

JCL – EXEC Statement

JCL – EXEC Statement ”; Previous Next Each JCL can be made of many job steps. Each job step can execute a program directly or can call a procedure, which in turn executes one or more programs (job steps). The statement, which holds the job step program/procedure information is the EXEC statement. The purpose of the EXEC statement is to provide required information for the program/procedure executed in the job step. Parameters coded in this statement can pass data to the program in execution, can override certain parameters of JOB statement and can pass parameters to the procedure if the EXEC statement calls a procedure instead of directly executing a program. Syntax Following is the basic syntax of a JCL EXEC statement: //Step-name EXEC Positional-param, Keyword-param Description Let us see the description of the terms used in above EXEC statement syntax. STEP-NAME This identifies the job step within the JCL. It can be of length 1 to 8 with alphanumeric characters. EXEC This is the keyword to identify it as an EXEC statement. POSITIONAL-PARAM These are positional parameters, which can be of two types: Positional Parameter Description PGM This refers to the program name to be executed in the job step. PROC This refers to the procedure name to be executed in the job step. We will discuss it a separate chapter. KEYWORD-PARAM Following are the various keyword parameters for EXEC statement. You can use one or more parameters based on requirements and they are separated by comma: Keyword Parameter Description PARM Used to provide parametrized data to the program that is being executed in the job step. This is a program dependant field and do not have definite rules, except that the PARM value has to be included within quotation in the event of having special characters. For example given below, the value “CUST1000” is passed as an alphanumeric value to the program. If the program is in COBOL, the value passed through a PARM parameter in a JCL is received in the LINKAGE SECTION of the program. ADDRSPC This is used to specify whether the job step require virtual or real storage for execution. Virtual storage is pageable whereas real storage is not and is placed in the main memory for execution. Job steps, which require faster execution can be placed in real storage. Following is the syntax: ADDRSPC=VIRT | REAL When an ADDRSPC is not coded, VIRT is the default one. ACCT This specifies the accounting information of the job step. Following is the syntax: ACCT=(userid) This is similar to the positional parameter accounting information in the JOB statement. If it is coded both in JOB and EXEC statement, then the accounting information in JOB statement applies to all job steps where an ACCT parameter is not coded. The ACCT parameter in an EXEC statement will override the one present in the JOB statement for that job step only. Common Keyword Parameters of EXEC and JOB Statement Keyword Parameter Description ADDRSPC ADDRSPC coded in JOB statement overrides the ADDRSPC coded in EXEC statement of any job step. TIME If TIME is coded in an EXEC statement, then it applies to that job step only. If it is specified in both JOB and EXEC statement, then both will be in effect and can cause time-out error due to either of it. It is not recommended to use TIME parameter in both the JOB and EXEC statement together. REGION If REGION is coded in an EXEC statement, then it applies to that job step only. REGION coded in JOB statement overrides the REGION coded in EXEC statement of any job step. COND Used to control the job step execution based on the return-code of the previous step. If a COND parameter is coded in an EXEC statement of a job step, then the COND parameter of the JOB statement (if present) is ignored. The various tests that can be performed using a COND parameter is explained in conditional Processing. Example Following is a simple example of JCL script along with JOB and EXEC statements: //TTYYSAMP JOB ”TUTO”,CLASS=6,MSGCLASS=X,REGION=8K, // NOTIFY=&SYSUID //* //STEP010 EXEC PGM=MYCOBOL,PARAM=CUST1000, // ACCT=(XXXX),REGION=8K,ADDRSPC=REAL,TIME=1440 Print Page Previous Next Advertisements ”;

JCL – Environment

JCL – Environment Setup ”; Previous Next Installing JCL on Windows/Linux There are many Free Mainframe Emulators available for Windows which can be used to write and learn sample JCLs. One such emulator is Hercules, which can be easily installed in Windows by following few simple steps given below: Download and install the Hercules emulator, which is available from the Hercules” home site – : www.hercules-390.eu The complete guide on various commands to write and execute a JCL can be found on URL www.jaymoseley.com/hercules/installmvs/instmvs2.htm Hercules is an open source software implementation of the mainframe System/370 and ESA/390 architectures, in addition to the latest 64-bit z/Architecture. Hercules runs under Linux, Windows, Solaris, FreeBSD, and Mac OS X. Running JCL on Mainframes A user can connect to a mainframe server in a number of ways such a thin client, dummy terminal, Virtual Client System (VCS) or Virtual Desktop System (VDS). Every valid user is given a login id to enter into the Z/OS interface (TSO/E or ISPF). In the Z/OS interface, the JCL can be coded and stored as a member in a Partitioned Dataset (PDS). When the JCL is submitted, it is executed and the output received as explained in the job processing section of previous chapter. Structure of a JCL The basic structure of a JCL with the common statements is given below: //SAMPJCL JOB 1,CLASS=6,MSGCLASS=0,NOTIFY=&SYSUID (1) //* (2) //STEP010 EXEC PGM=SORT (3) //SORTIN DD DSN=JCL.SAMPLE.INPUT,DISP=SHR (4) //SORTOUT DD DSN=JCL.SAMPLE.OUTPUT, (5) // DISP=(NEW,CATLG,CATLG),DATACLAS=DSIZE50 //SYSOUT DD SYSOUT=* (6) //SYSUDUMP DD SYSOUT=C (6) //SYSPRINT DD SYSOUT=* (6) //SYSIN DD * (6) SORT FIELDS=COPY INCLUDE COND=(28,3,CH,EQ,C”XXX”) /* (7) Program Description The numbered JCL statements have been explained below: (1) JOB statement – Specifies the information required for SPOOLing of the job such as job id, priority of execution, user-id to be notified upon completion of the job. (2) //* statement – This is a comment statement. (3) EXEC statement – Specifies the PROC/Program to be executed. In the above example, a SORT program is being executed (i.e., sorting the input data in a particular order) (4) Input DD statement – Specifies the type of input to be passed to the program mentioned in (3). In the above example, a Physical Sequential (PS) file is passed as input in shared mode (DISP = SHR). (5) Output DD statement – Specifies the type of output to be produced by the program upon execution. In the above example, a PS file is created. If a statement extends beyond the 70th position in a line, then it is continued in the next line, which should start with “//” followed by one or more spaces. (6) There can be other types of DD statements to specify additional information to the program (In the above example: The SORT condition is specified in the SYSIN DD statement) and to specify the destination for error/execution log (Example: SYSUDUMP/SYSPRINT). DD statements can be contained in a dataset (mainframe file) or as in stream data (information hard-coded within the JCL) as given in above example. (7) /* marks the end of in stream data. All the JCL statements except in stream data starts with //. There should be at least one space before and after JOB, EXEC and DD keywords and there should not be any spaces in rest of the statement. JOB Parameter Types Each of the JCL statements is accompanied by a set of parameters to help the Operating Systems in completing the program execution. The parameters can be of two types: Positional Parameters Appears at pre-defined position and order in the statement. Example: Accounting information Parameter can appear only after the JOB keyword and before the programmer name parameter and the Keyword Parameters. If a positional parameter is omitted, it has to be replaced with a comma. Positional Parameters are present in JOB and EXEC statements. In the above example, PGM is a positional parameter coded after the EXEC keyword. Keyword Parameters They are coded after the positional parameters, but can appear in any order. Keyword parameters can be omitted if not required. The generic syntax is KEYWORD= value. Example: MSGCLASS=X, i.e., the job log is redirected to the output SPOOL after the job completion. In the above example, CLASS, MSGCLASS and NOTIFY are keyword parameters of JOB statement. There can be keyword parameters in EXEC statement as well. These parameters have been detailed out in the subsequent chapters along with appropriate examples. Print Page Previous Next Advertisements ”;

JCL – Input/Output Methods

Input-Output Methods ”; Previous Next Any batch program executed through a JCL requires data input, which is processed and an output is created. There are different methods of feeding input to the program and writing output received from a JCL. In batch mode, there is no user interaction required but input and output devices and required organisation are defined in JCL and submitted. Data Input in a JCL There are various ways to feed the data to a program using JCL and these methods have been explained below: INSTREAM DATA Instream data to a program can be specified using a SYSIN DD statement. //CONCATEX JOB CLASS=6,NOTIFY=&SYSUID //* Example 1: //STEP10 EXEC PGM=MYPROG //IN1 DD DSN=SAMPLE.INPUT1,DISP=SHR //OUT1 DD DSN=SAMPLE.OUTPUT1,DISP=(,CATLG,DELETE), // LRECL=50,RECFM=FB //SYSIN DD * //CUST1 1000 //CUST2 1001 /* //* //* Example 2: //STEP20 EXEC PGM=MYPROG //OUT1 DD DSN=SAMPLE.OUTPUT2,DISP=(,CATLG,DELETE), // LRECL=50,RECFM=FB //SYSIN DD DSN=SAMPLE.SYSIN.DATA,DISP=SHR //* In Example 1, input to MYPROG is passed through SYSIN. The data is provided within the JCL. Two records of data are passed to the program. Please note that /* marks the end of instream SYSIN data. “CUST1 1000” is record1 and “CUST2 1001” is record2. End of data condition is met when the symbol /* is encountered while reading the data. In Example 2, the SYSIN data is held within a dataset, where SAMPLE.SYSIN.DATA is a PS file, which can hold one or more records of data. Data Input through files As mentioned in most of the examples in previous chapters, data input to a program can be provided through PS, VSAM or GDG files, with relevant DSN name and DISP parameters along with DD statements. In Example 1, SAMPLE.INPUT1 is the input file through which data is passed to MYPROG. It is referred as IN1 within the program. Data Output in a JCL The output in a JCL can be cataloged into a dataset or passed to the SYSOUT. As mentioned in DD statements chapter, SYSOUT=* redirects the output to the same class as that mentioned in the MSGCLASS parameter of the JOB statement. Saving Job Logs Specifying MSGCLASS=Y saves the job log in the JMR (Joblog Management and Retrieval). The entire JOB log can be redirected to the SPOOL and can be saved to a dataset by giving the XDC command against the job name in the SPOOL. When the XDC command is given in the SPOOL, a dataset creation screen is opened up. The job log can then be saved by giving appropriate PS or PDS definition. Job logs can also be saved into a dataset by mentioning an already created dataset for SYSOUT and SYSPRINT. But the entire job log cannot be captured through this way (i.e., JESMSG will not be cataloged) as done in JMR or XDC. //SAMPINST JOB 1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID //* //STEP1 EXEC PGM=MYPROG //IN1 DD DSN=MYDATA.URMI.INPUT,DISP=SHR //OUT1 DD SYSOUT=* //SYSOUT DD DSN=MYDATA.URMI.SYSOUT,DISP=SHR //SYSPRINT DD DSN=MYDATA.URMI.SYSPRINT,DISP=SHR //SYSIN DD MYDATA.BASE.LIB1(DATA1),DISP=SHR //* //STEP2 EXEC PGM=SORT In the above example, SYSOUT is cataloged in MYDATA.URMI.SYSOUT and SYSPRINT in MYDATA.URMI.SYSPRINT. Print Page Previous Next Advertisements ”;

JCL – DD Statement

JCL – DD Statement ”; Previous Next Datasets are mainframe files with records organised in a specific format. Datasets are stored on the Direct Access Storage Device (DASD) or Tapes of the mainframe and are basic data storage areas. If these data are required to be used/created in a batch program, then the file (i.e., dataset) physical name along with the file format and organisation are coded in a JCL. The definition of each dataset used in the JCL is given using the DD statement. The input and output resources required by a job step needs to be described within a DD statement with information such as the dataset organisation, storage requirements and record length. Syntax Following is the basic syntax of a JCL DD statement: //DD-name DD Parameters Description Let us see the description of the terms used in above DD statement syntax. DD-NAME A DD-NAME identifies the dataset or input/output resource. If this is an input/output file used by a COBOL/Assembler program, then the file is referenced by this name within the program. DD This is the keyword to identify it as an DD statement. PARAMETERS Following are the various parameters for DD statement. You can use one or more parameters based on requirements and they are separated by comma: Parameter Description DSN The DSN parameter refers to the physical dataset name of a newly created or existing dataset. The DSN value can be made up of sub-names each of 1 to 8 characters length, separated by periods and of total length of 44 characters (alphanumeric). Following is the syntax: DSN=Physical Dataset Name Temporary datasets need storage only for the job duration and are deleted at job completion. Such datasets are represented as DSN=&name or simply without a DSN specified. If a temporary dataset created by a job step is to be used in the next job step, then it is referenced as DSN=*.stepname.ddname. This is called Backward Referencing. DISP The DISP parameter is used to describe the status of the dataset, disposition at the end of the job step on normal and abnormal completion. DISP is not required in a DD statement only when the dataset gets created and deleted in the same job step (like the temporary datasets). Following is the syntax: DISP=(status, normal-disposition, abnormal-disposition) Following are valid values for status: NEW : The dataset is newly created by the job step. OUTPUT1 in the example above. OLD : The dataset is already created and will be overwritten in the job step. The job step gains exclusive access on the dataset and no other job can access this dataset until the completion of the job step. SHR : The dataset is already created and will be read in the job step. The dataset can be read by multiple jobs at the same time. Example: INPUT1 and INPUT2. MOD : The dataset is already created. This disposition will be used when there is a need to append new records to the existing dataset (existing records will not be overwritten). A normal-disposition parameter can take one of the following values CATLG, UNCATLG, DELETE, PASS and KEEP A abnormal-disposition parameter can take one of the following values CATLG, UNCATLG, DELETE and KEEP Here is the description of CATLG, UNCATLG, DELETE, PASS and KEEP parameters: CATLG : The dataset is retained with a entry in the system catalog. UNCATLG : The dataset is retained but system catalog entry is removed. KEEP : The dataset is retained without changing any of the catalog entries. KEEP is the only valid disposition for VSAM files. This is to be used only for permanent datasets. DELETE : Dataset is deleted from user and system catalog. PASS : This is valid only for normal disposition. This is used when the dataset is to be passed and processed by the next job step in a JCL When any of the sub-parameters of DISP are not specified, the default values are as follows: status : NEW is the default value. normal-disposition : If status is NEW, default normal-disposition is DELETE, else it is KEEP. abnormal-disposition : Same as normal disposition. DCB The Data Control Block (DCB) parameter details the physical characteristics of a dataset. This parameter is required for datasets that are newly created in the job step. LRECL is the length of each record held within the dataset. RECFM is the record format of the dataset. RECFM can hold values FB, V or VB. FB is a fixed block organisation where one or more logical records are grouped within a single block. V is variable organisation where one variable length logical record is placed within one physical block. VB is Variable Block organisation where one or more variable length logical records are placed within one physical block. BLKSIZE is the size of the physical block. The larger the block, greater is the number of records for a FB or VB file. DSORG is the type of dataset organisation. DSORG can hold values PS (Physical Sequential), PO (Partitioned Organisation) and DA (Direct Organisation). When there is a need to replicate the DCB values of one dataset to another within the same jobstep or JCL, then it is specified as DCB=*.stepname.ddname where stepname is the name of the job step and ddname is the dataset from which the DCB is copied. Check below example where RECFM=FB,LRECL=80 forms the DCB of dataset OUTPUT1. SPACE The SPACE parameter specifies the space required for the dataset in the DASD (Direct Access Storage Disk). Following is the syntax: SPACE=(spcunits, (pri, sec, dir), RLSE) Here is the description of all the used parameters: spcunits : This can be one of the CYL(Cylinder), TRK(Tracks) or BLKSIZE(Block Size). pri : This is the primary space required for the dataset. sec : This is the additional space required, when the primary space is not being sufficient. ir : This is the directory blocks required, if the dataset is a PDS (Partitioned Dataset) with members within it. RLSE : This is used to

JCL – Run COBOL Programs

Running COBOL Programs using JCL ”; Previous Next Compiling COBOL Programs In order to execute a COBOL program in batch mode using JCL, the program needs to be compiled and a load module is created with all the sub-programs. The JCL uses the load module and not the actual program at the time of execution. The load libraries are concatenated and given to the JCL at the time of execution using JCLLIB or STEPLIB. There are many mainframe compiler utilities available to compile a COBOL program. Some corporate companies use Change Management tools like Endevor, which compiles and stores every version of the program. This is useful in tracking the changes made to the program. //COMPILE JOB ,CLASS=6,MSGCLASS=X,NOTIFY=&SYSUID //* //STEP1 EXEC IGYCRCTL,PARM=RMODE,DYNAM,SSRANGE //SYSIN DD DSN=MYDATA.URMI.SOURCES(MYCOBB),DISP=SHR //SYSLIB DD DSN=MYDATA.URMI.COPYBOOK(MYCOPY),DISP=SHR //SYSLMOD DD DSN=MYDATA.URMI.LOAD(MYCOBB),DISP=SHR //SYSPRINT DD SYSOUT=* //* IGYCRCTL is an IBM COBOL compiler utility. The compiler options are passed using PARM parameter. In the above example, RMODE instructs the compiler to use relative addressing mode in the program. The COBOL program is passed using SYSIN parameter and the copybook is the library used by the program in SYSLIB. This JCL produces the load module of the program as output which is used as the input to the execution JCL. Running COBOL Programs Below a JCL example where the program MYPROG is executed using the input file MYDATA.URMI.INPUT and produces two output files written to the spool. //COBBSTEP JOB CLASS=6,NOTIFY=&SYSUID // //STEP10 EXEC PGM=MYPROG,PARM=ACCT5000 //STEPLIB DD DSN=MYDATA.URMI.LOADLIB,DISP=SHR //INPUT1 DD DSN=MYDATA.URMI.INPUT,DISP=SHR //OUT1 DD SYSOUT=* //OUT2 DD SYSOUT=* //SYSIN DD * //CUST1 1000 //CUST2 1001 /* The load module of MYPROG is located in MYDATA.URMI.LOADLIB. This is important to note that the above JCL can be used for a non-DB2 COBOL module only. Passing Data to COBOL Programs Data input to COBOL batch program can be through files, PARAM parameter and SYSIN DD statement. In the above example: Data records are passed to MYPROG through file MYDATA.URMI.INPUT. This file will be referred in the program using the DD name INPUT1. The file can be opened, read and closed in the program. The PARM parameter data ACCT5000 is received in the LINKAGE section of the program MYPROG in a variable defined within that section. The data in the SYSIN statement is received through ACCEPT statement in the PROCEDURE division of the program. Every ACCEPT statement reads one whole record (i.e., CUST1 1000) into a working storage variable defined in the program. Running a COBOL-DB2 program For running COBOL DB2 program, specialised IBM utility is used in the JCL and program; DB2 region and required parameters are passed as input to the utility. The below steps are followed in running a COBOL-DB2 program: When a COBOL-DB2 program is compiled, a DBRM (Database Request Module) is created along with the load module. The DBRM contains the SQL statements of the COBOL programs with its syntax checked to be correct. The DBRM is bound to the DB2 region (environment) in which the COBOL will run. This can be done using the IKJEFT01 utility in a JCL. After the bind step, the COBOL-DB2 program is run using IKJEFT01 (again) with the load library and DBRM library as the input to the JCL. //STEP001 EXEC PGM=IKJEFT01 //* //STEPLIB DD DSN=MYDATA.URMI.DBRMLIB,DISP=SHR //* //input files //output files //SYSPRINT DD SYSOUT=* //SYSABOUT DD SYSOUT=* //SYSDBOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //DISPLAY DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(SSID) RUN PROGRAM(MYCOBB) PLAN(PLANNAME) PARM(parameters to cobol program) – LIB(”MYDATA.URMI.LOADLIB”) END /* In the above example, MYCOBB is the COBOL-DB2 program run using IKJEFT01. Please note that the program name, DB2 Sub-System Id (SSID), DB2 Plan name are passed within the SYSTSIN DD statement. The DBRM library is specified in the STEPLIB. Print Page Previous Next Advertisements ”;

JCL Home

JCL Tutorial PDF Version Quick Guide Resources Job Search Discussion Job Control Language (JCL) is the command language of Multiple Virtual Storage (MVS), which is the commonly used Operating System in the IBM Mainframe computers. JCL identifies the program to be executed, the inputs that are required and location of the input/output and informs the Operating System through Job control Statements. In mainframe environment, programs can be executed in batch and online modes. JCL is used for submitting a program for execution in batch mode. Audience This tutorial will be useful for software programmers in the need of understanding the basics of Job Control Language. Also, this tutorial will be helpful to mainframe professionals to increase their level of expertise in JCL. Prerequisites The tutorial is intended for readers, who have a basic understanding of job management and data management in a mainframe environment. Print Page Previous Next Advertisements ”;