JCL+ VSAM Programming Guide

  • Upload
    sarath

  • View
    265

  • Download
    0

Embed Size (px)

Citation preview

  • 7/25/2019 JCL+ VSAM Programming Guide

    1/109

    Mainframesmania

    JCL Programming

    Guide

  • 7/25/2019 JCL+ VSAM Programming Guide

    2/109

    Index

    1.Introduction to Mainframe computers

    1.1

    Introduction1.2 Mainframes Features

    1.3 Mainframe Operating System

    2.ISPF((Interactive Service productivity Facility)

    2.1 Introduction to ISPF

    2.2 Creation of PS file

    2.3 Creation of PDS file

    2.4 Renaming option

    2.5 SUPERC utility

    3. JCL (JOB CONTROL LANGUAGE)

    3.1 Introduction to JCL

    3.2

    JOB card3.3 EXEC card

    3.4 DD card

    3.5 GDG (GENERIC DATA GROUP)

    3.6 Condition Parameter

    3.7 DFSORT utility

    3.8 IBM utilities like IEFBR14, IEBCOPY, IEBEDIT, and

    IEBGENER3.9 JCL procedures

  • 7/25/2019 JCL+ VSAM Programming Guide

    3/109

    4.VSAM (Virtual Storage Access Method)

    4.1-Introduction to VSAM

    4.2-Key Sequential Data set (KSDS)

    4.3- Entry Sequential Data Set:

    4.4- Relative record data set (RRDS)

    4.5-REPRO Command

    Author - Avinash C kamble.

  • 7/25/2019 JCL+ VSAM Programming Guide

    4/109

    Chapter-1

    Introduction

    to Mainframe

    computers

  • 7/25/2019 JCL+ VSAM Programming Guide

    5/109

    1.1- Introduction

    Fig-IBM mainframe. . . . . . . .

    Mainframe is the technology introduced by IBM in1960 and still it is in

    market handling mission critical applications of various domain without failure.

    The languages which are using are started from that time only and some of added

    later part of time like CICS and there is no change in syntax of that while other

    technology are changing time to time.

    Fig. . . . .ATM machine

    By considering todaysscenario more than 80 percentage of data transaction

    executing on mainframe. Though you are using Google, ATM machine,

    Reservation system etc the backend is mainframe computer.

  • 7/25/2019 JCL+ VSAM Programming Guide

    6/109

    Learning of mainframe technology is not like other technology once you set up

    on your system and start using it. You cantlearn it from home.

    The main reason is that when you write a program on your system you have to

    run the program through IBM mainframe computer/server so you are using IBMserver to perform your work.

    So according to CPU time utilized for that operation IBM applies the charges to

    that user who submitted the job. Means it is not free to use thats why you cant

    learn it from home.

    As per the use of IBM mainframe technology most of multinational companies

    business runs on mainframe.

    What is Mainframe?

    Fig. . . . IBM mainframe. . . .

    1 ) A Mainframe is also an large powerful-high speed computer which servesthousand of user connected to it. In todaysworld commercial use of computer is

    called as server. So mainframe is also a largest type of a server in todaysuse.

    So from our Terminal means from out computer we are connecting to mainframe

    server for our business use.

  • 7/25/2019 JCL+ VSAM Programming Guide

    7/109

    So the mainframe server stores the critical data of much application for ex.

    banking, telecom, hospitality, travels, insurance etc. uses mainframes.

    2) A mainframe is what a businesses use to host the commercial database-

    transaction servers-and application that requires high level security and 24*7available for their customer to use.

    So for highly reliable and security purpose companies are using mainframe.

    Mainframe serves the entire domain.

    EX. Imagine a bank server is a small server where the data resides. These servers

    never work when a large number of transactions took place where mainframe is

    exclusively good in transaction processing. Through Mainframe we can process

    million of record within a fraction of second.

    ATM machine is also run on the mainframe so it is 24*7 available. It is closed for

    only filling the money.

    What about the space required for IBM mainframe server/computer?

    At the start 1960 when IBM mainframe was developed it requires more space for

    its hardware device and for processor. Starting around 1990 the size of processor

    and I-O peripheral is reduced. The size of mainframe server/computer is like a

    Refrigerator.

    From 1960 there is only IBM mainframe why there is no competition

    IBM never supplied architecture of Mainframe the idea is only with IBM. From

    1960 companies start using IBM mainframe for their mission critical application

    and now the situation is like that they cantreplace the IBM mainframe. So they

    are keeping using it as the cost of preparation is very high and there is no

    guarantee of success.

  • 7/25/2019 JCL+ VSAM Programming Guide

    8/109

    What is charges from IBM ?

    As you submit the job means a unit of work to do on mainframe server then in the

    output log of job there is CPU time utilized for that particular work is counted on

    that Mainframe server which you are using. So it is like Electricity Bill how muchyou use you have to pay.

    IBM charges a fee for the hardware, and then they have software fees (one time

    charges and monthly recurring charges). Those costs, however, may or may not

    have anything to do with system usage. IBM will happily sell you a machine that

    sits idle, doing nothing -- but the price will (generally) be the same as for a

    machine that is 98% busy of the time. IBM does have some usage-based pricing,

    but that's not typically directly based on CPU seconds if you installed in your own

    sites.

    How user uses Mainframe computers/servers?

    Fig. . .User terminal. . . .

    Yes User can use access the mainframe computer/server from their desktop is

    called as terminal so location doesnt matter you can access the mainframe from

    across the world.

    Mainframe user interface is 80*24 characters Green on black screen.

    Many of todaysweb sites store their production database on mainframe host.

  • 7/25/2019 JCL+ VSAM Programming Guide

    9/109

    Important Features of using Mainframes.

    Reliability - AS mainframe is also a machine which made up of many hardware

    components so any hardware failure causes the impact on business. So there is

    health checker which detects hardware failure problem early before any impact

    on business.

    Availability-The system can recover from failed hardware without impacting

    the running system. so the application is 24*7 available.

    Serviceability

    When the hardware or software is failed it can be easily detected forreplacement of hardware or software.

    So in that failure time also the application is available for service and during the

    less traffic on application the replacement is done.

    Security

    The critical data like bank account number-password-employee record is

    protected from unauthorized user. Mainframe computers have extensivecapabilities to share the data among authorized user and protect the same.

    So this important feature is of mainframe gives IT firm to use mainframe.

    Scalability

    It means that ability of hardwaresoftware to continue the function well in any

    change.

    Ex. If we add the processor or increase the memory then also application will

    perform well.

  • 7/25/2019 JCL+ VSAM Programming Guide

    10/109

    Extensibility

    The system will continue come up with adding the new functionality into it to

    make it more reliable to use.

    Ex. Initially mainframe is used for batch processing so IBM introduced CICS for

    online programming.

  • 7/25/2019 JCL+ VSAM Programming Guide

    11/109

    1.3-What is Mainframe operating system (Z/OS)?

    I have doubt while I am reading the most of books-sides about operating system I

    came across two answers MVS (Multiple Virtual Storage) and Z-OS

    MVS and Z-OS are same only. IBM introduced MVS operating system in 1974 and

    modification of the operating system will reach up to Z-OS. So now it is Z-OS uses

    Mainframe computers.

    Defination of Operating System

    Operating System is nothing but a collection of programs which performs the

    system internal software-hardwarememory processor working.

    So mainframe also having an operating system which manages its operations this

    operating system is Z-OS.

    Why IBM has introduced Z-OS ?

    Early in mainframe the multiple users submits the job at a time then operating

    system takes one job at a time and gives the output to the requested user and

    then it takes the second job for execution and this process in continuing.

    So By introducing Z-OS multiple jobs are executed at a time so no any queue

    problem.

  • 7/25/2019 JCL+ VSAM Programming Guide

    12/109

    Characteristics of Mainframe Operating System. . . .

    1) Virtual Storage

    Storage used by Mainframe operating system is Direct Access Storage Device(DASD) volume. In mainframe computer there is two types of storage one is

    Actual physical storage memory and another is Virtual storage to which user has

    an accesss/OS keeps only the active portions of each program in central storage.

    Virtual storage is a memory management technique by which programs are made

    to work as if they have more memory available to them than is actually attached

    to the computer. After running program on mainframe the output is reflect on

    physical memory or can be placed on disk.

    2) Multiprogramming

    It means simultaneous execution of more than one program in single CPU.So CPU

    utilization is better.

    3) Spooling

    As many user are submitting a job at a time so for the output of program given to

    printer which is shared among the user through spooling.

    4) Multiprocessing

    Two or more Central Processing Unit (CPU) shares access to main memory. So it

    removes particular CPU dependency as one CPU fails another CPU will take care

    of its work.

    5) Time Sharing

    In this each user hahrough a terminal devices access to the mainframe system .

    Here user interacts directly with the mainframe computer.

  • 7/25/2019 JCL+ VSAM Programming Guide

    13/109

    Chapter-2ISPF

    (Interactive Service

    productivity Facility)

  • 7/25/2019 JCL+ VSAM Programming Guide

    14/109

    1.1- ISPF(Interactive Service productivity Facility) And TSO

    TSO is Time sharing Option. As computers are faster than user when a userrequest for memory data through a program then computer returns the output

    and before checking the output that computer serves other user request and this

    continues.

    So by Time sharing option thousand or more than that user are connected to

    mainframe system at a time. This connection of multiple user is depends on

    operating system specification.

    ISPF is a user interface with MVS system. As your information is stored in MVS

    DASD volume so for communication purpose ISPF created.

    For ex. With the help of ISPF you can create, delete, alter, view, edit, and browse

    etc.a dataset without writing a program.

    So when you login to mainframe on Ready window type ISPF and press enter.

  • 7/25/2019 JCL+ VSAM Programming Guide

    15/109

    So you will get an ISPF windows like below

    This is ISPF menu screen through which you can interact with MVS system.

    Here I will explain the parameter that we use for all required operation.

    1)

    Option is command line where you can enter your choice and then press

    enter so you will redirect to that screen.

    2)

    Option 0 is for settings where you can change the ISPF setting as per yourconvenience. Suppose I want to take command line at bottom then I will

    give / against it and enter save on command line and press enter Then the

    command line will appear at bottom.

  • 7/25/2019 JCL+ VSAM Programming Guide

    16/109

    Option 1 is view option where you can give a file name which you want to

    view and that file you cant change as you are in view mode.

    This option will not used in day to day activity.

    Option 2 is EDIT option where you can edit the VSAM, PS, PDS file.

    Option 3 is utility option this is important one. When you enter 3 on command

    line you can see the below screen.

  • 7/25/2019 JCL+ VSAM Programming Guide

    17/109

    Option 1 is library option with the help of this you can perform different function

    like brwse, edit, and view on your Dataset give a dataset name.

    On command line select appropriate option and on name line give your PS and

    PDS dataset name.

    Option 2 is most important option used to create, delete, rename, catlog yourdataset on mainframe.

    Dataset like PS, PDS, VSAM etc.

    To jump directly on Allocation of dataset type 3.2 from ISPF main menu and

    press enter.

  • 7/25/2019 JCL+ VSAM Programming Guide

    18/109

    Creation of physically sequential dataset using ISPF.

    First I will show you how to create PS (physically sequential) dataset.

    Physical sequential dataset where you can stored your data but for huge number

    of record it is time consuming to retrieve the record so VSAM(Virtual Storage

    Access Method ) came into picture. Now you just concentrate on how to create

    PS dataset.

    The name of dataset is 44 char with 8 character in a group then dot . you can use

    national characters like @,#,$,% etc but it should not be at the start.

    XXXXXXXX.XXXXXXXX.XXXXXXXX.XXXXXXXX.XXXXXXXX.XXXX

    Option a to allocate a dataset then give the name of dataset like below.

    Just to know it is ps file I have written at last.ps so from name only I can

    understand that it is PS file.

    Then you will forward towards next screen where you have to give storage

    specification like space in Track, Cylinder, KB, MB, Bytes etc.

  • 7/25/2019 JCL+ VSAM Programming Guide

    19/109

    All first fields like management class, volume serial etc.is system admin defined.

    Space is calculated as per the requirement.

    Relation between Byte,kilobyte,megabyte

    8 Bits = 1 Byte

    1024 Bytes = 1 Kilobyte

    1024 Kilobytes = 1 Megabyte

    Relation between Track and Cylinder.

    1 TRK=56,664 bytes

    1 CYL=15 TRK=849,960 Bytes per Cylinder

    Primary quantity is amount of required space for our dataset and if this space is

    full then data stored on the secondary space defined by secondary quantity.

    Directory Block is defined for PDS dataset only. For PS dataset it is blank or zero.

  • 7/25/2019 JCL+ VSAM Programming Guide

    20/109

    Record format Types-

    1) Undefined assigned by U.

    2) FB means fixed block for e.g. A block with record length=50 and block size

    of 5000 so we create a 1 block of total 5000 bytes in length in our assignedspace.

    3)

    VB means variable Block here record length is fixed but block length is not

    fixed.

    4)

    F for Fixed

    5)

    V for Variable

    Data set name type is blank for PS.

    After pressing enter you can get a message like DatasetAllocated

    You can see the file in dataset list as below.

    From ISPF main menu enter 3 for utility then press 4 i.e. DSlist then press enter.

    Then type Dataset name that you created it will gives you result like this

  • 7/25/2019 JCL+ VSAM Programming Guide

    21/109

    By typingsagainst dataset name you will get all the information about dataset

    like below.

  • 7/25/2019 JCL+ VSAM Programming Guide

    22/109

    Creation of Partition Data set from ISPF .

    The process is similar to PS file. From ISPF menu Type 3 then type 2 then A for

    allocation like below then press enter.

    So next screen will be same as PS

    Here just you have to fill the directory block because it is extra space to store the

    member name as PDS is just like a folder.

    Data set name type is pds. Then press enter so you get output below.

  • 7/25/2019 JCL+ VSAM Programming Guide

    23/109

    Now you can see the output dataset like below.

    But PDS file you cant open in view, browse, edit mode directly as it is folderwhich stores the member so you have to create the member first.

    Creation of member in PDS dataset.

    Member name is in bracket which is maximum 8 characters. You can use

    E for edit

    V for view

    B for browse

    But in View and Browse mode you cant save the member so use Edit mode.

    So type save in command window and save the member here you can write your

    JCL code.

  • 7/25/2019 JCL+ VSAM Programming Guide

    24/109

    You are getting message like member is saved.

    Rename a Dataset.

    R in command line will used to rename a dataset.

    Then give another name for e.g. I have give name as AVINASH.TRIAL.pds

  • 7/25/2019 JCL+ VSAM Programming Guide

    25/109

    How to Rename a member?

    1) Open the pds file

    2) In front of member name type R

    3)

    Then on next screen give the name.

    You also get the message like this

    You can Rename the whole PDS name also just write R against the PDS then give

    the new name.

    Creation of VSAM file using ISPF will see in VSAM section as a starting point of

    view PS and PDS files are important for programming.

  • 7/25/2019 JCL+ VSAM Programming Guide

    26/109

    What is SUPERC utility?

    Introduction:

    Used to compare the dataset. It may be PS, PDS, and VSAM.

    Enter 12 on command line

    Then give the first dataset name like below.

    Press enter then give second dataset name like below.

  • 7/25/2019 JCL+ VSAM Programming Guide

    27/109

    Then press enter you will get the output.

    Here one is PS file and another is PDS and difference between them is member

    name.

    If there are records in two PS dataset and you have to find the unique records

    from them then use SUPERC utility. These daily activities are performed through

    ISPF main menu.

  • 7/25/2019 JCL+ VSAM Programming Guide

    28/109

    Chapter-2JCL

    (JOB CONTROL

    LANGUAGE)

  • 7/25/2019 JCL+ VSAM Programming Guide

    29/109

    2.1- Introduction:

    Introduction to Mainframe programming.

    Before that I would like to highlight on two different programming technique that

    we used in Mainframe.

    1) Batch programming means there is no any human interaction . Here you run

    your code which will not accept any human values .

    2) Online programming here human interaction is must. The values passed by

    human will decide the flow of execution of program.

    What is JCL ?

    JCL = Job control language.

    JOB = It is the execution of one or more related programs in sequence. Each

    program to be executed by a job is called a job step.

    JCL is the command language of MVS and consists of a set of control statements

    that identifies the program to be executed and the data to be read or written.

    Jobs written in JCL are managed by an operating system (OS) component called

    the Job Entry Subsystem or JES. For every job that is submitted to OS forexecution, we need to tell the OS, the programs it has to execute, the inputs that

    are required, the location of input and the location for output. These information

    are provided using statements known as Job Control Statements.

    1) JCL statements are coded in 80 byte records

    Only 72 of the 80 chars are available to code the JCL. The columns 73-80 is

    reserved for sequence number or comment means the compiler will ignore it.

    2) Each JCL statement is logically divided into five fields. All five fields may not

    appear on every statement.

    3) JCL statements has the following fields

    a. Identifier

  • 7/25/2019 JCL+ VSAM Programming Guide

    30/109

    b. Name

    c. Operation

    d. Parameters

    e. Comments

    1) Identifier - Two slashes ( // ) starting in col 1. Exceptions are

    For a delimiter statement, /* starting in col 1

    For a comment statement , //* starting at col 1

    2) NameIt can be from one to eight characters long, consisting of alphanumeric

    (A-Z and 0-9) and National (@,#,$) characters. Name should start with an

    alphabet or national ($, #, @) character. It must begin at col 3.

    3) OperationA valid operation code, such as JOB, EXEC or DD. Must be preceded

    and followed by a space.

    ParametersOne or more parameters depending on the operation. Individual

    parameters are separated from one another by commas.

    4) JCL parameters :

    a) Positional parameters

    They are coded first in the parameter field. If you omit a positional parameter and

    code a following positional parameter, then code a comma to indicate the

    omitted parameter.

    Do not code the replacing comma if:

    The omitted positional parameter is the last positional parameter.

    All following positional parameters are also omitted.

    Only keyword parameters follow.

  • 7/25/2019 JCL+ VSAM Programming Guide

    31/109

    All positional parameters are omitted

    In the JOB card there are 2 positional parameters

    1) JOB accounting information.

    2) Programmer name.

    Eg. See below job card I have written with positional parameters only.

    //Ak47, Job, a123, Avinash

    1) The JOB which is operation field must start between column 8 to 11.

    2) A123 is accounting information.

    3) Avinash is programmer name.

    If I skipped any positional parameter then give comma.

    b) Keyword parameters-

    A keyword consists of characters that appear in uppercase followed by an equals

    sign (e.g. NOTIFY=&SYSUID) followed by either characters that must be coded or

    variable information. Code any of the keyword parameters for a statement in any

    order in the parameter field after the positional parameters. Because of this

    positional independence, never code a comma to indicate the absence of a

    keyword parameter.

    Class, notify, msgclass, msglevel, prty, typrun are the keyword parameter used in

    JOB card.

    5) Comments:

    Comments may follow parameters, preceded by one space and not extending

    beyond col 71.

  • 7/25/2019 JCL+ VSAM Programming Guide

    32/109

    How the JOB is processed in mainframe ?

    There is JOB entry subsystem which will handle the execution of JOB. As there are

    user across the world uses mainframes for their day to day activities. But then

    also JES manages all these execution process smoothly.

    1) Determine the job requirement and characteristics.

    2) Write JCL

    3) Submit the JCL.

    After submitting the JCL the user part is over now its turn of JES system which

    proceeds below.

    4) JES receive submitted job and initiate initiator.

    5) JCL steps are executing

    6) JES collects output.

    7) JES prints output.

  • 7/25/2019 JCL+ VSAM Programming Guide

    33/109

    8) User views output.

    I never heard about this in my engineering life .Even I never heard a word

    Mainframe also and now I am working on Mainframe Green on black window.

    Job Control Language is one kind of a command language which instruct a

    mainframe storage to please do the required things to me.

    How JCL tells the storage system and what is storage?

    IBM mainframe storage nothing but a DASD(direct Access Storage Device)volume

    where the actual data stores.So to allocate a volume to store required data is not

    manual process it requires some interface with mainframe storage to

    communicate.

    So IBM introduced JCL language to fill this gap.

    User requirement Mainframe storage(DASD)

    JCL

    JOB is nothing but in mainframe any work is submitted as a job. for ex. In C

    language suppose you write a program of addition which will add two numbers.

    This program will perform a unit of work. Similarly in JCL also each Job is

    performing a unit of work.

    Ex. Jobxyz copies a data from one file to another file.

    C=control

    Now I defined a job for particular work. So I have to keep the Track on the correct

    operation of my job like pick up the correct file and copy it into correct file.

    So through instruction I am controlling my job to perform a correct operation.

    Language which will understand by system then only it gives you the output.

  • 7/25/2019 JCL+ VSAM Programming Guide

    34/109

    So adding up all JCL is a language where work is submitted in the form of a job

    and executes without any error so gives an correct output.

    So JCL is heart of Mainframe.

    Can there be many jobs in one JCL?

    No it can be in one JCL there is only one job at a time.

    So how can I perform a larger work like copy a file-create a file at a time can I

    have to define two separate jobs for it and submit it so it is time consuming

    process.

    To avoid such problem one job can have steps which does a work. So your

    program is nothing but a job step. Means my first step will copy the file for the joband my second step has second program create a new file for the same job.

    So itsquite pretty to do a lot of different work in one job just submit a job and it

    will executes multiple steps at a time.

    But how many steps one job executes

    There is 255 steps one job can executes.

    Means JOB is divided into steps which execute the actual work.

    Now I have understood the function of JCL in mainframe.

    How can I write JCL program and where to write his program and how to execute

    a program?

    Wait I will explain it one by one

    Where to write a JCL program which performs a certain task

    In a mainframe before writing a program you must know the two terms pS and

    PDS

  • 7/25/2019 JCL+ VSAM Programming Guide

    35/109

    PS=physical sequential is nothing but a normal file

    PDS=Partitation Data Set it is just like a folder where all the files with different

    names are resides so all the files inside the folder is called as member.

    So you can call it as PS dataset and PDS dataset

    So In that member you are going to write your program.

    Can I write and execute my JCL program in PS file?

    No you cannot its a rule for a mainframe to always write a program in PDS

    member only.

    Fig---error while submitting a ps file with program.

    Now I understood where to write a program now can you tell me how to

    execute a program?

    Sure once you written your JCL program you have to save it by typing SAVEcommand on your command line. then type SUBMIT or SUB command on

    command line it will submit your job.

    Can I directly submit the job?

    No you cant you have to first save your job then submit the job. One thing you

    can do is you can directly type save; sub on command line it will do your two

    works at a time or after saving the job just type J in front of member of member

    name.

  • 7/25/2019 JCL+ VSAM Programming Guide

    36/109

    3.2- JOB Card

    Introduction:

    There are 3 types of JCL statements used

    1) JOB - Used for identification of JOB.

    2) EXEC - Used for identification of Execution.

    3) DD - Used for identification of Data source.

    Other statements are NULL statement and Comment statement.

    A JOB statement contains detail about JOB name programmer name etc.

    EXEC statements contains name of program to be executed.

    DD statement contains source and output dataset name.

    At end JCL terminated by Null statement.

    JOB statement:

    This is first statement of JOB card.

    It identifies beginning of JOB.

    It contains positional parameter as well as Keyword parameter.

    Positional parameter:

    1) JOB accounting information

    2) Programmer name.

  • 7/25/2019 JCL+ VSAM Programming Guide

    37/109

    Keyword parameter:

    1) CLASS

    2) MSGCLASS

    3) MSGLEVEL

    4) PRIORITY

    5) NOTIFY

    6) COND

    7) TIME

    8) RESTART

    9) REGION

    10)TYPRUN

    1)JOB Accounting Information.

    This is used for billing or charge back purpose information.

    In production environment there are many teams are working for different

    purposes so each of them have a different accounting ID for billing purpose.

    Syntax:

    (Account-number, additional accounting information)

    Total number of character is 142.

    You can write Accounting information like TEAM

    if we omit this parameter then give comma.

    2) Programmers Name

    This parameter gives information about programmer who has written and

    submitted the JOB.

    Max length is 20 char.

  • 7/25/2019 JCL+ VSAM Programming Guide

    38/109

    Example:

    //IEFBR14 JOB ACCT, AVINASH

    //IEBCOPY JOB ACCT, AVINASH

    3) CLASS

    Used to assign JOB class which decides nature of JOB.

    Syntax:

    CLASS=JOB class

    JOB class may be from A-Z and from 0-9

    Frankly speaking you dont need to give this parameter this is installation

    dependent.

    4) PRTY

    There are different classes as mentioned above and the schedular picks up the

    different classes JOB based on PRTY basis.

    Syntax:

    PRTY=number from 0-15.

    This is also installation dependent you need not to specify this.

    5) MSGCLASS

    This parameter used to specify the output device to which output message like

    system message and JCL message to be routed

  • 7/25/2019 JCL+ VSAM Programming Guide

    39/109

    Syntax:

    MSGCLASS=output-class-name

    It is A-Z or 0-9

    This is also installation dependent.

    6) MSGLEVEL

    As you have submitted the job then messages like JCL message, System message

    ,Log message are to be recorded on output device specified by MSGCLASS

    parameter.

    Syntax:

    MSGLEVEL=(statements, messages) failed

    where statements may be a number from 0 to 2 and message value is either 0 or

    1.

    This parameter is also system defined.

    1) Statements value and its meaning 0 means only Job related messages to be

    recorded.

    1 means all JCL statements including procedure to be recorded.

    2 means only input JCL statement to be recorded.

    2) Message value and its meaning

    0 means JOB allocation or termination messages to be output if job terminates

    abnormally.

  • 7/25/2019 JCL+ VSAM Programming Guide

    40/109

    1 means JOB allocation or deallocation messages to be output even if job

    terminates normally or abnormally.

    7) NOTIFY parameter

    This parameter notify user about job completion whether it is successful or failed

    due to some reason.

    Syntax:

    NOTIFY=userid or &sysuid.

    //jobname job,notify=&sysuid

    8)TYPRUN

    This parameter specifies enviroment for JOB execution.

    Syntax:

    TYPRUN=SCAN or HOLD or JCLHOLD or COPY

    If TYPRUN=SCAN then it will SCAN the JCL statements for syntax error and reports

    it. This will not execute job even if no errors.

    If TYPRUN=HOLD then JOB will held for execution until user released it.It will

    check for errors when JOB is submitted.

    If TYPRUN=copy then job is printed as sysout datast but not processed.

  • 7/25/2019 JCL+ VSAM Programming Guide

    41/109

    9) RESTART

    This parameter is important one when a submitted job abends on step3 then to

    start the execution of same JOB from step3 use RESTART parameter.

    Syntax:

    RESTART=* or stepname or stepname.procstepname

    where * indicates default first step.

    Stepname specifies specific step name.

    Stepname.procstepname specifies start of specified step from a procedure.

    Example:

    //JOB1,RESTART=STEP3.STEP4

  • 7/25/2019 JCL+ VSAM Programming Guide

    42/109

    EXEC statement

    Introduction:

    As JOB contains steps which have to be executing so EXEC statement tells

    compiler that this is my step which has to be executed.

    It specifies program or procedure to be executed.

    Syntax:

    Stepname EXEC pgm or proc,parameters

    A maximum 255 EXEC statements can be coded within a JOB.

    Parameters on EXEC statements:

    A) Positional parameters:

    1)PGM2)PROC

    B) Keyword parameter:

    1)ACCT

    2)COND

    3)REGION

    4)ADDRSPC

    5)PARM

    6)TIME

  • 7/25/2019 JCL+ VSAM Programming Guide

    43/109

    1)

    PGM parameter

    This parameter specifies a program name or utility name which has to be

    executed from that step.

    Syntax:

    //STEPNAME EXEC pgm=program-name

    PGM is first parameter on EXEC statement.

    EXAMPLE:

    STEP1 EXEC pgm=ADDPGM

    2) PROC parameter

    Used to call an instream procedure or catlog procedure.

    Syntax:

    stepname exec proc=procedure-nameor

    stepname exec procname.

    Example:

    step1 exec proc=newproc

    or

    step1 exec newproc.

  • 7/25/2019 JCL+ VSAM Programming Guide

    44/109

    3) ACCT

    This parameter specifies Accounting information.

    This is used for billing or charge back purpose information.

    In production environment there are many teams are working for different

    purposes so each of them have a different accounting ID for billing purpose.

    Syntax:

    (Account-number additional accounting information)

    Total number of character is 142.

    4) PARM

    this will pass the information to your program.

    Syntax:

    PARM=information.

    Information is maximum 100 characters in length.

    //step1 exec pgm=pgm1,PARM= welcome to mainframe

    Below parameters are common to JOB as well as EXEC statements

    5) TIME

    This parameter if specified then it will override the default installation TIME

    value.

    Syntax:

    TIME=(min,sec) or

  • 7/25/2019 JCL+ VSAM Programming Guide

    45/109

    (NOLIMIT) or

    (MAXIMUM) or

    (0)

    min=from 0 to 357912 i.e. max 248 days.

    Sec=from 0 to 59.

    NOLIMIT = specifies JOB or JOB step can use unlimited processing time.

    Maximum = Specifies JOB or JOB step uses maximum processing time i.e.

    248 days.

    0 means JOB step can use remaining time from previous time and if it

    requires more time to process then job will ABEND.

    Examples:

    //JOB1 JOB ,,TIME=(10,3)

    //JOB1 JOB ,,TIME=10

    //JOB1 JOB ,TIME=MAXIMUM

    //STEP1 EXEC PGM=IEBCOPY,TIME=(,30)

    //STEP1 EXEC PGM=pgm1,TIME=NOLIMIT

  • 7/25/2019 JCL+ VSAM Programming Guide

    46/109

    6) ADDRSPC

    Specifies the JOB or JOB step use either virtual or Real storage.

    Syntax:

    ADDRSPC=(VIRT or REAL)

    7) REGION

    This parameter override default memory allocated to JOB or JOB step.

    Syntax:

    REGION= value in KB or

    value in MB.

    KB value is max. 7 digit and

    MB value is max.4 digit

    If REGION=0K or 0M ,then all the available storage will be assigned to that

    job.

    Example:

    //JOB1 JOB ,,REGION=126K

    //STEP1 EXEC PGM=IEFBR14,REGION=95M

  • 7/25/2019 JCL+ VSAM Programming Guide

    47/109

    Data Definition (DD) statement:

    Introduction:

    When you have to use a PS file or a PDS file member in program you have to

    declare it first to the system via DD statements.

    Simple rule before use define it.

    Syntax:

    DDNAME DD DSN=File name.

    Here DDNAME is data definition name means you can give any name here. This

    must be max.8 characters.

    The DDNAMEmust be unique as you can call the file at any point through

    DDNAME parameter.

    DSNis Data set name here you have to give your PDS, VSAM, PS file name which

    you want to access.

    I will show you some program that clears you the idea behind DD statements.

    Look at the above code here my DDNAME is SYSUT3 and another DDNAME is

    SYSUT4. My DSN is AVINASH.FIRST.PS and AVINASH.NEW.PS respectively. In my

    control card I am defining OUTDD=SYSUT4 i.e. after processing this job store the

    output in DDNAME sysut4 i.e. AVINASH.NEW.PS while take SYSUT3 as input.

    So I called the files by using DDNAME not DSN name.

  • 7/25/2019 JCL+ VSAM Programming Guide

    48/109

    What is DD * statements?

    This tells that below data is my input data which I defined in program itself

    instead of writing in a File. In short DD * is for Inputting a information without

    using dataset.

    What is DUMMY parameter?

    The Dummy parameter is coded to check the execution of a program without

    using the actual file in a program.

    Syntax:

    DDNAME DD DUMMY or

    DDNAME DD DSN=NULLFILE.

    What is SYSOUT DD SYSOUT=* parameter?

    SYSOUT means system output i.e. output generated during execution of a job it

    directs it to the Output device class.

    Syntax:

    SYSOUT DD SYSOUT=CLASS

    The CLASS parameter is taken from MSGCLASS parameter or else system defined

    class.

    What happen if I give SYSOUT DD SYSOUT=*?

    If in my job card I given a MSGCLASS=A then I defined SYSOUT DD SYSOUT=*parameter

    So the Output system message will forward to class A.

  • 7/25/2019 JCL+ VSAM Programming Guide

    49/109

    2.2-Generic Data Group (GDG).

    Introduction:

    Problemin many situations we have to store the data on daily basis. Suppose I

    have to record a customer data on daily basis. So each day I have to create a new

    file and store the data into it.

    Solution-- So instead of this if I am using GDG I can create the new dataset on

    daily basis just submitting the one job on daily basis.

    It will create a new version of the dataset.

    It is the group of dataset which are related to each other.

    Every GDG dataset have unique generation number and version number.

    Steps for creating GDG.

    First we have to create GDG base. Then we are going to create its version USING

    IEFBR14 UTILITY just we have to change file name.

    In the version created Dataset we can store our data.

    Creation of GDG base.

    Below program will create GDG base here we can define how many version of this

    dataset will be created.

  • 7/25/2019 JCL+ VSAM Programming Guide

    50/109

    This job will create my GDG base with name ak999.gdg.bill

    I will explain each parameter in my control card.

    Limit( )This field indicates how many versions of my Base GDG will be created.

    Eg. Ak999.gdg.bill. G0001V00

    Ak999.gdg.bill. G0002V00

    Ak999.gdg.bill. G0003V00 etc.

    The generation number GxxxxVyy where xxxx is in between 0001 to 9999 and the

    version no yy is 00.

    When we have created a version you can use it as Current version i.e.

    ak999.gdg.bill (0)

    Next version which you are going to create is ak999.gdg.bill (+1).

    What is maximum limit for version?

    You can create up to 255 versions from one GDG base.

    It means you can have 255 dataset with same functionality.

    Name (dataset name)- You can give your dataset name which you wanted to be

    created.

    Empty\ Noempty- Empty parameter specifies that when the versions of GDG

    reached to its limit then all existing generation of GDG are to be uncatloged.

    NOEMPTY specifies that only oldest generation of GDG is to be uncatloged.

    Scratch/Noscratch- Scratch specifies that if entry of dataset will get removed

    from GDG index then the dataset will get physically removed from Volume so

    gives free space.

  • 7/25/2019 JCL+ VSAM Programming Guide

    51/109

    NOSCRATCH specifies that if dataset get removed from index it will just

    uncatloged not physically deleted.

    Is there is another way to create GDG?

    Yes you can create a GDG by simple way.

    Type TSO gdgp in command line and press Enter.

    You will get screen below.

    Now you want to build a GDG base so give GDG base name and enter option 1

    in command line. So your GDG base will get created.

    Similarly you can delete, Alter GDG base.

    How to create GDG versions?

    Once you have created GDG base you cant sore data into GDG base. If you are

    going to edit GDG base it will gives you error like GDGbase

    As you know IEFBR14 utility used to create a new dataset same way GDG is also a

    new dataset so you have to give only dataset name i.e. your Base name it will

  • 7/25/2019 JCL+ VSAM Programming Guide

    52/109

    create version with your base name (+1). Generation numbers get added into it

    like GxxxxVyy.

    See below program for creating a version.

    Upon submitting the above job will create version automatically.

    Can I change record length, block size field for every version?

    Yes you can change these parameter as per the requirement. The job will run with

    maxcc=0.

    Altering GDG

    How can I change the parameters which i have used to create my GDG ?

    Alter command will help in this situation. You can change the parameters after

    you defined your GDG base.

    You cant change LIMIT(n) parameter.

    You can alter scratch/Noscratch and Empty/Noempty parameter.

    Program to alter GDG.

  • 7/25/2019 JCL+ VSAM Programming Guide

    53/109

    How to delete a GDG version?

    As we can create a GDG version using IEFBR14 utility same utility is used to delete

    a GDG version.

    Here we can delete only GDG version Not GDG base.

    How to delete GDG base and its versions?

    To delete GDG base with its version use IDCAMS utility with purge and force sub

    parameters.

    Purge parameter- when we create GDG base it has its time period to exit is called

    as retention period after that period the GDG will get automatically deleted. So if

    you want to delete GDG before this time period you can use Purge option.

    The expiration date is defined by system admin.

  • 7/25/2019 JCL+ VSAM Programming Guide

    54/109

    GDG with force option will delete GDG base as well as all its versions.

  • 7/25/2019 JCL+ VSAM Programming Guide

    55/109

    2.3- Condition parameter.

    Introduction:

    As one job may have several job steps to execute. Suppose in my job there are 3

    steps to execute and after execution of each step it will return a Return code

    (RC)/ Condition Code.

    Now i am checking this Return Code in my program to execute or bypass

    particular step in my JOB.

    This checking of Return code done by the use of COND parameter.

    Real time example where COND parameter using.

    Suppose my job contains two steps. In my first step i am copying a file into

    another file for backup purpose and in my second step i am deleting the original

    file which i used in step1 if step1 completed successfully else not.

    So to handle such condition without error the best choice will be use COND

    parameter.

    Where to code Condition Parameter?

    The COND parameter can be coded in Job statement or to particular job step

    depending on requirement.

    If condition parameter coded for job statement then it checks each job step

    Return code (RC) according to COND parameter.

    If condition parameter coded for job step then it checks particular job steps

    return code only.

  • 7/25/2019 JCL+ VSAM Programming Guide

    56/109

    Common condition codes:

    Return Code Explanation

    0 Successful execution

    4 Successful execution with some warning messages

    8 Error in job step

    16 Serious error

    COND parameter on JOB statement

    Syntax:

    COND=(comparison code(RC value),condition)

    The value of Return code is in between 00 to 4095 so comparison code must be

    any number among this.

    This comparison code is compared with Return code of job steps and takes the

    decision whether to execute a step or not.

    In condition parameter operator like Greater Than (GT), Less than (LT) etc. are

    coded.

    Table for condition parameter:

    Condition Explanation

    GT Checks comparison code is greater

    than RC

  • 7/25/2019 JCL+ VSAM Programming Guide

    57/109

    GE Checks comparison code is greater

    than or equal to RC

    LT Checks comparison code is less than

    RC

    LE Checks comparison code is less than

    or equal to RC

    EQ Checks comparison code equals to

    RC

    NE Checks comparison code not equals

    to RC

  • 7/25/2019 JCL+ VSAM Programming Guide

    58/109

    Example for condition parameter coded on Job statement.

    Here if RC of step1 is 00 so whether 8 is less than 00 ? No. then step2 will be

    executing. Now if RC of step2 is 16 so 8 is less than 16 then step3 will not execute

    and if there is step4,step5 then that will also not executing.

    Can i check multiple conditions in my job statement?

    Yes you can just code COND=((4,LE),(8,GT),(16,LT))

    If all the above condition get satisfied then only the job step will be terminating

    i.e.

    4 is less than RC and

    8 is greater than RC and

    16 is less than RC.

    COND parameter coded on EXEC/step name statement

    This applies the COND parameter on particular step not for all job steps. The jobstep will be executing or bypassed depending upon depending upon RC.

    Syntax:

    COND=(comparison code,condition,step name)

  • 7/25/2019 JCL+ VSAM Programming Guide

    59/109

    Here step name specifies name of preceding step whosRC will be checked.

    Example of COND parameter:

    If RC of step1 is 00 then condition is not satisfying so step2 will be executing .

    If we not mention any step name then it will check all prior steps RC.

    What is COND=EVEN/ONLY parameter?

    COND=EVEN means a particular step has to be executed even if all previous steps

    terminate abnormally or completes successfully means forceful execution.

    COND=ONLY means a particular step will be executing only if previous steps

    terminates abnormally.

    Can we code EVEN and ONLY in one JOB?

    You cant as EVEN and only are mutually exclusive so code any one of them in

    your program.

  • 7/25/2019 JCL+ VSAM Programming Guide

    60/109

    2.3- DFSORT Tutorial.

    Introduction:

    IBM supplied a utility to sort, Merge, Copy a PS dataset into another PS dataset.

    DFSORT gives you versatile data handling capabilities.

    The input to this operation is a dataset which contains record which you want to

    sort, Merge, Copy into output dataset.

    So Input dataset will remain as it is and according to given condition your output

    dataset will change like rec. In ascending or descending order etc.

    Sorting Dataset.

    SORT means Arrange a dataset.

    Its easy to sort a dataset having few records manually but when records are more

    then you need to use DFSORT utility.

    Utility name is DFSORT but while defining a program the name of program must

    be SORT.

    SYNTAX:

    Step1 exec PGM=SORT

    I will show you all the Sort option with program so you will understand.

    SORT by Ascending Order

    Here my input dataset contains below 5 records now i have to sort It withAscending order and put the ascending output records in AK999.PS.NEW which is

    my output dataset.

  • 7/25/2019 JCL+ VSAM Programming Guide

    61/109

    Next step is write a SORT program.

    SORTIN is the name of my input dataset.

    SORTOUT is my output dataset which i am going to create so i have given its all

    parameter.

    If you have already a dataset created then use DISP=OLD.

    SYNTAX of SORT card:

    SORT FIELDS=(1,5,CH,A)

    (1,5)-This is my key field to tell operating system that the starting position of my

    input dataset column is from 1 and it will continues next 5 bytes so Sort the

    record by reffering these key field.

  • 7/25/2019 JCL+ VSAM Programming Guide

    62/109

    CH- This is format of my dataset record. It will tell the operating system that my

    data contain character as well as number fields. This is commonly used parameter

    also we can use

    ZD- will tell operating system that my data is numeric one though it contain + orve sign.

    A or D- A for Ascending Order and D is for Descending order.

    After submitting job will gives me MAXCC=00 and my output dataset contents

    are:

    SORT by Descending Order

    This will arrange records in descending order.

    Just one change in above program in the SORT control card just replace A by D.

    SYNTAX:

    SORT FIELDS= (1, 5, CH, D)

  • 7/25/2019 JCL+ VSAM Programming Guide

    63/109

    Can I SORT my input file itself ascending or Descending?

    Yes you can just open the input file in edit mode

    In command window just type SORT A or SORT D and press enter you will see the

    changes in input file itself.

    My input file records are:

    My Command:

    OUTPUT:

    If you want to use multiple columns then see below command will also accept :

  • 7/25/2019 JCL+ VSAM Programming Guide

    64/109

    How to SORT the records by considering multiple Key Fields?

    Suppose my input dataset has following data:

    First field is Name of Employee

    Second field is Shift allowance

    Third field is Department

    My requirement is I have to sort the records according to Name field and Shift

    allowance field

    So my SORT card will tell the operating system please check both two fields and

    satisfy both condition and arrange data for me in my output dataset.

    Name field is within column 1-7 (6 bytes) and

    Shift allowance field is within column 9-14 (5 bytes).

    Order is Ascending or Descending.

    Sort Program:

  • 7/25/2019 JCL+ VSAM Programming Guide

    65/109

    SORT card is:

    Or same command you can hit on command line when you open file in EDIT mode

    like below:

    If my input dataset has duplicate records How can i eliminate?

    See following data in my input file:

    Here Avinash is duplicate record and i have to eliminate duplicate records while

    rearranging so i just add one line in my control card i.e.

    SUM FIELDS=NONE

  • 7/25/2019 JCL+ VSAM Programming Guide

    66/109

  • 7/25/2019 JCL+ VSAM Programming Guide

    67/109

    How to SUM up the column values?

    Input dataset:

    Now i have to add middle column to sum means to add so i use below program to

    sum up middle columns value:

    It will gives you maxcc=0.

  • 7/25/2019 JCL+ VSAM Programming Guide

    68/109

    Copying dataset using SORT option.

    If i want to copy a dataset as it is through DFSORT utility as i can copy it through

    IEBCOPY utility also.

    Input file:

    Program:

    Output:

  • 7/25/2019 JCL+ VSAM Programming Guide

    69/109

    IBM supplied Utilities:

    Introduction:

    Utility is a tool that executes a task like creating a dataset, copying a dataset

    etc.IBM supplied many prewritten utilities I will highlight some important utilities.

    Below are some functions of utility

    Copy a sequential dataset or a member of PDS dataset.

    Copy a PDS dataset.

    Include a member of PDS dataset while copying.

    Exclude a member of PDS dataset while copying.

    Create a PS and PDS dataset.

  • 7/25/2019 JCL+ VSAM Programming Guide

    70/109

    2.4- IEFBR14 utility

    Introduction:

    This utility used to create, delete, uncatlog, catalog a PS dataset or PDS dataset.

    I can handle all these stuff using ISPF main menu so why I use this utility?

    As you can create, delete, etc through ISPF main menu but consider a scenario

    where you have to copy a dataset data into a new dataset so here in your

    program only you are creating a file and copying a content from one file to

    another file.

    Program of IEFBR14 utility as below.

    This program will create the PDS with above specification.

    Here I am not using the control card i.e. sysin dd so I have written sysin dd

    dummy.

    This PDS file has a record length of 80 bytes.

    Block size is 27920 bytes.

    Space field is an important field it decides whether a file is a PS file or a PDS file

    Syntax for SPACE field:

  • 7/25/2019 JCL+ VSAM Programming Guide

    71/109

    SPACE=(TRK/CYL(primary,secondary,directory),

    If you have given Directory quantity then it will create a PDS file else will be a PS

    file.

    Record format is fixed block and

    Dataset organization is PO or you do not have to declare this just keep sysin dd

    dummy.

    This job will run at maxcc=0.

    Now I will show you the specification that I have given in my program will

    matching or not.

    Creation of PS file using IEFBR14:

  • 7/25/2019 JCL+ VSAM Programming Guide

    72/109

    Output message.

    Properties of file.

    For deleting the Dataset use the same utility but in dd statement write

    DDname dd dsn= file which to be deleted its name

    Disp= (old, delete, delete)

    It will delete your mentioned file.

    Similarly to catalog the file use disp= (old, catlg).

    To uncatlog the file use disp= (old, uncatlg).

  • 7/25/2019 JCL+ VSAM Programming Guide

    73/109

    IEBGENER utility

    Introduction:

    This utility used to copy

    1) One PS dataset into another PS dataset or

    2) Copies data from PDS member to another PDS member.

    3) Copies data from PDS member to another PS

    But criteria is record length must be matching else will throw an error.

    See the below program I have to copy the data from my input PS to output PS for

    backup purpose.

    Data in my input file is as below.

    My output file is empty.

    JCL program:

  • 7/25/2019 JCL+ VSAM Programming Guide

    74/109

    This program will run with maxcc=0.

    So content of output dataset as below.

    What happen if there are duplicate records?

    To clear this I will again submit the same job as contents are same in both job.

    Again you will get maxcc=00

    And content of output PS dataset will be override.

    If there are duplicate records then also it will get copied like below.

  • 7/25/2019 JCL+ VSAM Programming Guide

    75/109

    Copy the data from one PDS member to another PDS member:

    Program:

    Copy the data from one PDS member to another PS:

    Program:

    Can we use any other utility to perform same function?

    Yes you can use IEBCOPY or SORT utility to do same function.

  • 7/25/2019 JCL+ VSAM Programming Guide

    76/109

    IEBCOPY utility.

    Introduction:

    Situation- Whenever there is requirement to copy a PDS to another PDS or

    copying a member to another pds or exclude some members from one PDS and

    copying remaining all members for backup purpose then we will use IEBCOPY

    utility.

    To copy all the members of one PDS to another PDS.

    To copy selected member of one PDS to another PDS.

    To exclude selected member of one PDS to another PDS.

    Here we have to define to Dataset one is as input and another is as output.

    Below I have taken Avinash.copy.pds as my input dataset and my output

    dataset is Avinash.new4.pds.

    In the control card i.e in sysin dd * I have given the instruction that my input

    dataset name is defined by sysut3 and my output dataset is defined by sysut4.

    This will copy my entire input dataset member into my output dataset.

  • 7/25/2019 JCL+ VSAM Programming Guide

    77/109

    One very important thing is before copying you should check the record length

    both input and output dataset Record length must be same.

    If the record length is not same then you will get maxcc=0 but members will not

    copy.

    3) Always write outdd as first and indd as second else will give you

    maxcc=08.

    Now to copy a selective member from one pds to another pds.

    For this requirement just add one line in your control card i.e. select

    member=(mem1, mem2,etc)

    It will select only that particular member in your output dataset.

    To exclude a particular member from input dataset to copy then just use Exclude

    member=(mem1,mem2,etc).

    It will not copy only these members and rest of member will copy.

  • 7/25/2019 JCL+ VSAM Programming Guide

    78/109

    Can we use both exclude and select statement in one program?

    No you cant will throws an error maxcc=12.

    How to merge two PDS

  • 7/25/2019 JCL+ VSAM Programming Guide

    79/109

    IEBEDIT utility

    Introduction:

    This utility is used when you require copying a particular step from one PDS

    member to another.

    Used when we have to run only selective step like from step no 4 to step no.7 etc.

    See below I have written one JCL which will copy the step01 from my input JCL

    defined in SYSUT1 to my output JCL defined by SYSUT2.

    The control card contains

    Edit type= Include means we have to include a step in JOB .

    Stepname=(step01,step02,etc)

    Here in my output JCL this program will create a member sort1 and also contentsis step01 from input PDS.

  • 7/25/2019 JCL+ VSAM Programming Guide

    80/109

    Content of step01.

    The output of program is

  • 7/25/2019 JCL+ VSAM Programming Guide

    81/109

    This is member created in my PDS and its content like below.

    This will copy all data from Job card to the end of that step program.

  • 7/25/2019 JCL+ VSAM Programming Guide

    82/109

    2.5-JCL Procedure

    Introduction:

    In JCL code reusability function is JCL procedure. A copy of JCL code like dataset

    creation, copy a dataset etc. Operation will perform on daily routine so every time

    instead of copying a same code and submitting the code we can use JCL

    procedure.

    Here you just call the code in your main program so no need to submit separate.

    E.g. Suppose there is 2 different job which reads same dataset so instead of

    writing a separate code for each job what i do is i will write a JCL code to read a

    dataset in the form of Procedure\PROC and call that PROC in that 2 different job.

    In short PROC is Same JCL used by multiple users in there program.

    What are the Types of JCL PROC?

    There are two types of JCL Proc.

    Instream Procedure

    Catlog procedure.

    What is Instream procedure?

    In Instream procedure we write a procedure code in JCL code itself.

    No separate calling for another PDS member.

    Maximum 15 Instream Procs you can write in a JCL.

    You can refer the same Instream Proc in any step in same JCL.

  • 7/25/2019 JCL+ VSAM Programming Guide

    83/109

    What is Catlog procedure?

    Here you are calling a JCL code stored in another PDS member or in system

    library.

    If you are using system library i.e. sys1.proclib which contains member like below

    snap shot

  • 7/25/2019 JCL+ VSAM Programming Guide

    84/109

    If you have coded your JCL in your personal JCL then you must give the path for

    compiler to find out JCL code which you have called i.e your PROC code.

    So to give a path you can use STEPLIB or JOBLIB parameter.

    What is STEPLIB and JOBLIB?

    As a JOB contains several steps like step1, step2, step3 etc.

    So in JOBLIB we describe the JCL which is common for all JOB steps for the

    particular JOB.

    Suppose all the steps in JOB uses different procs but we are storing all procs in

    same PDS then we can give the path of that PDS and will tell the compiler that this

    is my JOB which contains following steps and for every step use same PDS to find

    out the PROC required to execute a step.

    SYNTAX:

    JCLLIB DD DSN=ak999.new.proc, DISP=SHR

    This statement must write after JOB card and before any EXEC statement.

    If we have a different PROC for each step also locate at different destination PDS

    then we must use STEPLIB in our program.

    SYNTAX:

    //STEPLIB DD DSN=AK999.PROCLIB,DISP=SHR

    STEPLIB must be coded after EXEC statement like below

    //step1 exec pgm=myproc

    //steplib dd dsn=ak999.proclib,disp=shr

  • 7/25/2019 JCL+ VSAM Programming Guide

    85/109

    Can we code both STEPLIB and JOBLIB?

    Yes you can. Here the system will search STEPLIB library first then system library.

    The system will ignore the JOBLIB library for the particular step where you

    defined STEPLIB DD statement.

    Program:

    Now i have coded below CATLOGPC . This is my PROC name which i have coded in

    my personal PDS.

    Do not use JOBCARD while defining a JCL PROC code.

    Do not submit the PROC job.

    Now i am calling above program in another JCL program.

    Submit this job will create a new version of GDG through catlog procedure.

  • 7/25/2019 JCL+ VSAM Programming Guide

    86/109

    Chapter-4VSAM (Virtual

    Storage Access

    Method)

  • 7/25/2019 JCL+ VSAM Programming Guide

    87/109

    4.1-Introduction to VSAM.

    VSAM stands for Virtual Storage Access Method.

    Introduction:

    Any kind of file like PS, VSAM etc.is stored in certain volume space which is part of

    DASD (Direct access storage device) .So in certain volume there can be a different

    dataset of other user also so particular user only uses the some data on the

    volume so rest of other user data is of no use to him/her. So the Virtual storage

    came into picture.

    There are two types of storage supported by Z/OS (IBM Mainframes OS)

    1)

    Physical storage.2) Virtual storage.

    As you know IBM mainframe is used by multiple users at a time from their work

    location so every time accessing data, updating data etc. Take place. So every

    time instead of using the physical storage where actual data resides the data

    called in virtual storage as per the job requirement.

    So it will speed up the process of data manipulation. So for updating also data

    manipulated is updated in physical storage.

    Why IBM has introduced VSAM?

    VSAM is also a file system like a normal PS file but it overcomes the drawbacks of

    PS file.AS no any system is perfect VSAM file also have some drawbacks.

    So to speed up the data manipulation operation IBM introduced VSAM in 1973.

    VSAM advantages over PS file

    1) AS the KSDS data set has an INDEX component the searching operation will be

    faster than normal PS files.

  • 7/25/2019 JCL+ VSAM Programming Guide

    88/109

    2) Records can be physically deleted.

    3) All VSAM files are stored in VSAM catlog so we can refer any VSAM dataset no

    need to detail in JCL.

    Disadvantages

    Space requirement is higher as there is free space required after every record.

    VSAM programming divided into two parts

    1)

    VSAM with JCL used to create,delete,alter,load the VSAM files from PS,GDG

    files

    2)

    VSAM with COBOL used to read, write, and Rewrite the VSAM file.

    Types of VSAM files

    1) KSDS (Key Sequential Data set)

    2) ESDS (Entry sequential Data set)

    3) RRDS(Relative Record Data Set)

  • 7/25/2019 JCL+ VSAM Programming Guide

    89/109

    4.2-Key Sequential Data set (KSDS)

    Introduction:

    1)

    A Key Sequenced Data Set (KSDS) is a type of data set used by the IBM

    VSAM computer data storage system. Each record in a KSDS data file is

    embedded with a unique key. A KSDS consists of two parts, the data

    component and a separateindex file known as the index component which

    allows the system to physically locate the record in the data file by its key

    value. Together, the data and index components are called a cluster.

    2)

    Records can be accessed randomly or in sequence and can be variable-

    length

    We cant directly use the KSDS file first we have to create the KSDS file.

    First we will see the program that creates the KSDS file.

    Program:

    //KSDSNEW1 JOB 'AK85427','AVINASH',NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    DEFINE CLUSTER(NAME(AK999K.AVINASH.KSDS1)-

    TRACKS(3,1)-

    http://en.wikipedia.org/wiki/Data_sethttp://en.wikipedia.org/wiki/IBMhttp://en.wikipedia.org/wiki/VSAMhttp://en.wikipedia.org/wiki/Computer_data_storagehttp://en.wikipedia.org/wiki/Index_filehttp://en.wikipedia.org/wiki/Index_filehttp://en.wikipedia.org/wiki/Computer_data_storagehttp://en.wikipedia.org/wiki/VSAMhttp://en.wikipedia.org/wiki/IBMhttp://en.wikipedia.org/wiki/Data_set
  • 7/25/2019 JCL+ VSAM Programming Guide

    90/109

    KEYS(3,0)-

    CONTROLINTERVALSIZE(4096)-

    FREESPACE(10,10)-

    RECORDSIZE(35,70))

    /*

    ****************************************************************

    See below Mainframe program i have written in my PDS member to create the

    KSDS new file which i am going to use for my data storing.

    Now i will tell you the function of each in brief.

    1)//KSDSNEW1 JOB 'AK85427','AVINASH',NOTIFY=&SYSUID

    This is my Job card.

    Job name=KSDSNEW1

    AK85427=Accounting information.

    AVINASH=programmer Name

    NOTIFY=&sysuid will notify all messages related to this job to me.

  • 7/25/2019 JCL+ VSAM Programming Guide

    91/109

    2)STEP1 EXEC PGM=IDCAMS

    Stepname=step1------you can give any stepname but it should be 8 char. Not

    started with any digit.

    EXEC=it is control card name

    PGM=IDCAMS (Integrated Data Control Access Method)

    As we are working for Data operation.

    It is utility required for the creation of any VSAM file.

    3) SYSPRINT DD SYSOUT=*

    It allocates a printing device for this operation and gives the result in spool

    4) SYSOUT DD SYSOUT=*

    It says that output message of the system is shown in the spool as sysout=*

    If we have written sysout dd dsn=file name then this will stores the information in

    respective file

    5)SYSIN DD *

    This is the control card which controls the operation of creation of KSDS file.

    1) DEFINE CLUSTER(NAME(AK999K.AVINASH.KSDS1)-

    CLUSTER----It is logical name for defining a VSAM file.It can be a dataset contains

    both Index and data component.

    But these criteria only satisfied by KSDS file only.

    NAME (dataset name)

    2) Defining the space

    TRK/CYL (primary quantity, secondary quantity)

    I have given TRK (3,1)

  • 7/25/2019 JCL+ VSAM Programming Guide

    92/109

    It means that on my volume please give me a primary space of 3 Track and if it is

    filled by my data please add 1 more TRK space as secondary space.

    As many of dont know the difference in TRK and CYL space they are just giving it

    blindly so i would like to explain the terms TRK and CYL.

    TRK-----1 TRK=56,664 bytes

    CYL----1 CYL=15 TRK=849,960 Bytes per Cylinder

    Defining the primary key

    This is nothing but a unique column value from your file.

    For ex. If your file having employee record which contain different columns like

    employee id, employee Name, City here employee name, city can be same but

    employee id is always different so we are doffing Employee id as primary key.

    Suppose in my file the employee id is started at column 1 whose length is 3 digits.

    Now i want to define keys parameter to tell the system that it is my unique field

    and i want to search the records by this key.

    So in INDEX of KSDS file it will store the employee id with its corresponding

    address in memory.

    So be careful while defining the Key column.

    Offset means its position from column 1.

    Here my employee id field starts at column 1 so its offset is 3.

    So i defined keys (3, 0)

    If my field length is 5 and starts at column 10 then keys will be

    Keys(5,10).

  • 7/25/2019 JCL+ VSAM Programming Guide

    93/109

    3)

    Defining Control interval

    A Control Interval can contain many records. If the records are not all of

    constant length, the number of records in each CI will also vary. Also, as we

    will see when we discuss record insertion, all CIs are created with a

    moderate amount of free space (to leave room for newly inserted records).

    All of the records in a CI (along with their keys) are packed at the beginning

    of the CI. At the end of each CI is a descriptor (including a record length) for

    each record in the CI. The area between the records and their descriptors is

    free space ... to accommodate new records.

    It is just like a fixed length block.

    Size of control interval is ranging from 4096 bytes to 32k bytes.

    In control interval actual records get inserted.

  • 7/25/2019 JCL+ VSAM Programming Guide

    94/109

    Frankly speaking a programmer never minds how the data stores internally.

    Suppose i have defined my space =1 trk=56,664 bytes and my control interval size

    is 4096 bytes. Then 56,664/4096 = approximately 14 Control interval will be

    created.

    All the control intervals are grouped in control area.

    Control Area 1

    Control interval

    A

    Control intervalB

    Control intervalC

    Control intervalD

    Control intervalE

    Control Area 2

    Control interval

    F

    Control interval

    G

    Control interval

    H

    Control interval

    I

    Control interval

    J

  • 7/25/2019 JCL+ VSAM Programming Guide

    95/109

    4)

    Freespace

    FREESPACE(CI CA) Specifies the percentage of free space to reserve for the

    control intervals (ci) and control areas (ca) of the data component.

    5)Record size

    RECORDSIZE/RECSZ (AVG ,MAX) Specifies the average and maximum record

    size.

    Depends upon the requirement.

    Its nothing but the minimum and maximum record size.

    Program for KSDS:

    This program will run with maxcc=0 and the ksds file is created with the nameAK999K.avinash.ksds1.

  • 7/25/2019 JCL+ VSAM Programming Guide

    96/109

    The file is created with its data name and index name.

    Now you have doubt where to store actual data its in .DATA file or in .KSDS1 orin .INDEX

    Let me clear it.

    The actual data is stored in cluster file i.e. MYID.avinash.ksds1. You cant open.data and .Index file that is for system use.

    Many sites define the program with data name and index name also included in theprogram but no need to defines this it will automatically created.

    So control interval field also multiple of 4096 bytes.

    ****Now I will show you how to store a data manually

    You cant edit a VSAM file like a ps file if you try to open the file by typing Eagainst it. Shows you a below error.

    So I am using File aid tool to open a VSAM file and stores date in it.

    In KSDS always data stored in ascending order.

    Suppose if I am going to insert any word which is not ascending then it will showsyou error while saving the content.

  • 7/25/2019 JCL+ VSAM Programming Guide

    97/109

    Now I am inserting amit after zebra then you can see the error message.

    So be careful while inserting a data.

    Now if I am going to save a duplicate record it will shows a message like

    So this data cant be saved. DUP means duplicate.

    If I dont know my record length?

    If you dont know your record length then no need to write it. It will take it asvariable length records.

    If without key field I am submitting the job then it will gives you maxcc=12

    But gives you problem while searching the data with primary column.

    Deleting KSDS

    Now if I would like to delete my KSDS file as we are creating the file we have

    authority to delete also.

    You may have doubt can I have to delete cluster file, data file, and index fileseparately. Just a minute I will clear your all doubts.

  • 7/25/2019 JCL+ VSAM Programming Guide

    98/109

    Now I want to delete my KSDS file name sk648k.avinash.ksds3 so below jcl Iam going to use in my JCL program.

    //TXXXXXJ JOB , ,NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSIN DD *

    DELETE TXXXXX.VSAM.KSDSFILE

    /*

    So below program I have written in my JCL.

    It runs successful and gives maxcc=0.

    So all files with data, Index component got deleted.

  • 7/25/2019 JCL+ VSAM Programming Guide

    99/109

    4.3- Entr y Sequential Data Set:

    Introduction:

    It is just like a PS file.

    It has only data component no Index component.

    So keys field from the KSDS SYSIN card get removed.

    ESDS file access can be sequential or random but not dependent on primary key.

    There is no any free space in ESDS file.

    Program:

    //E114298J JOB ,,NOTIFY=&SYSUID,CLASS=B

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSIN DD *

    DEFINE CLUSTER(NAME(E114298.ESDS.VSAM) -

    NONINDEXED -

    RECSZ(80,80) -

    TRACKS(1,1) -

    CISZ or control interval size(4096)

    /*

    The fields in the control card is not positional you can make it up and down.

    So now I will write my ESDS file creation program.

  • 7/25/2019 JCL+ VSAM Programming Guide

    100/109

    Program:

    Output of above JCL is

    So created ESDS file is

    The delete program is same as KSDS delete program.

    Here after deleting the cluster ESDS file and data file both will get deleted.

  • 7/25/2019 JCL+ VSAM Programming Guide

    101/109

    Data Loading in ESDS dataset:

    There is no any ascending insertion rule in ESDS file system. You can insert a dataas you want like normal ps file.

  • 7/25/2019 JCL+ VSAM Programming Guide

    102/109

    4.4- Relative record data set (RRDS)

    Introduction:

    RRDS file also similar to ESDS file. It has data component only.

    RRDS contains only fixed records.

    Just instead of NONINDEXED parameter we code NUMBERED parameter.

    Program:

    //E114298J JOB ,,NOTIFY=&SYSUID,CLASS=B

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSIN DD *

    DEFINE CLUSTER(NAME(E114298.ESDS.VSAM) -

    NUMBERED -

    RECSZ(80,80) -

    TRACKS(1,1) -

    CISZ(4096) -

    FREESPACE(3,3))

    /*

  • 7/25/2019 JCL+ VSAM Programming Guide

    103/109

    Now I will write a program in my JCL.

    Program:

    Output:

    Dataset created:

    So above two files are created.

    Data insertion and deletion process is same like ESDS VSAM file.

    RECORD SIZE parameter:

    Here I have defined record size as (5,5)

    So I can enter only 5 letter or number it will not accept 6 one

    Data is accessed by RRN number.

    See the below snapshot.

  • 7/25/2019 JCL+ VSAM Programming Guide

    104/109

    Delete operation also same as KSDS, ESDS file.

    Now I have cleared the file creation, deletion and initial manually loading of data.

    If I want to load a VSAM dataset by other dataset like PS then I have to useREPRO command.

  • 7/25/2019 JCL+ VSAM Programming Guide

    105/109

    4.5-REPRO Command

    Introduction:

    Now I have to copy my PS file data into my VSAM file.

    So REPRO command is used to copy a PS file data to VSAM file.

    Program:

    //REPRO123 JOB 'CRIS','AVINASH',NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //DD1 DD DSN=AK999K.AVINASH.PS1,

    // DISP=OLD

    //DD2 DD DSN=AK999K.AVINASH.KSDS1,

    // DISP=OLD

    //SYSIN DD *

    REPRO INFILE(DD1) OUTFILE(DD2)

    /*

    //

    So I will write this program in my JCL

    Intially my PS file data is

  • 7/25/2019 JCL+ VSAM Programming Guide

    106/109

    KSDS file data is

    Now I will show you the output of a program

    This will gives me a maxcc of 12 with below error.

    As the records are not ascending order so it will not insert the record in betweentwo data names.

    Now I will delete all the records of KSDS file so it will be empty.

    Now I will submit same job.

  • 7/25/2019 JCL+ VSAM Programming Guide

    107/109

    Repro command used for ESDS file:

    Contents of ESDS file after successful completion of job.

    Here records are added at last.

    So In ESDS the records got added at last it will not consider any order.

  • 7/25/2019 JCL+ VSAM Programming Guide

    108/109

    Repro command for RRDS file.

    Same ESDS Program I have written for RRDS dataset just changed the datasetname by RRDS dataset.

    But as the record length were not matching it gives the MAXCC=12 with belowerror.

    As the records are of not fixed length it gives you error now I will make all recordsof same length and then submits the job.

    PS file content is

    I will make the Record length same for both dataset then submit the below

    job.

  • 7/25/2019 JCL+ VSAM Programming Guide

    109/109

    Program:

    Output:

    Data: