JCL+ VSAM Programming Guide
JCL+ VSAM Programming Guide
JCL+ VSAM Programming Guide
JCL Programming
Guide
Index
1. Introduction to Mainframe computers
1.1 Introduction
1.2 Mainframes Features
1.3 Mainframe Operating System
Introduction to ISPF
Creation of PS file
Creation of PDS file
Renaming option
SUPERC utility
Introduction to JCL
JOB card
EXEC card
DD card
GDG (GENERIC DATA GROUP)
Condition Parameter
DFSORT utility
IBM utilities like IEFBR14, IEBCOPY, IEBEDIT, and
IEBGENER
3.9 JCL procedures
Chapter-1
Introduction
to Mainframe
computers
1.1- Introduction
Fig-IBM mainframe. . . . . . . .
Learning of mainframe technology is not like other technology once you set up
on your system and start using it. You cant learn 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 IBM
server 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?
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 databasetransaction servers-and application that requires high level security and 24*7
available 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.
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 todays web sites store their production database on mainframe host.
Serviceability
When the hardware or software is failed it can be easily detected for
replacement 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 extensive
capabilities 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 hardware software to continue the function well in any
change.
Ex. If we add the processor or increase the memory then also application will
perform well.
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.
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.
Chapter-2
ISPF
(Interactive Service
productivity Facility)
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 your
convenience. 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.
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.
Option 3 is utility option this is important one. When you enter 3 on command
line you can see the below screen.
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 your
dataset 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.
Then you will forward towards next screen where you have to give storage
specification like space in Track, Cylinder, KB, MB, Bytes etc.
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.
Then type Dataset name that you created it will gives you result like this
By typings against dataset name you will get all the information about dataset
like below.
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.
But PDS file you cant open in view, browse, edit mode directly as it is folder
which stores the member so you have to create the member first.
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
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.
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.
Chapter-2
JCL
(JOB CONTROL
LANGUAGE)
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 for
execution, 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
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) Name It 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) Operation A valid operation code, such as JOB, EXEC or DD. Must be preceded
and followed by a space.
Parameters One 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.
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.
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 job
and my second step has second program create a new file for the same job.
So its quite 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 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 SAVE
command 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.
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.
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
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.
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.
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
EXEC statement
Introduction:
1)ACCT
2)COND
3)REGION
4)ADDRSPC
5)PARM
6)TIME
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-name
or
stepname exec procname.
Example:
step1 exec proc=newproc
or
step1 exec newproc.
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
(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
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
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.
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.
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.
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.
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 GDG base
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
create version with your base name (+1). Generation numbers get added into it
like GxxxxVyy.
See below program for creating a version.
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.
GDG with force option will delete GDG base as well as all its versions.
Return Code
Explanation
Successful execution
16
Serious error
Explanation
GT
GE
LT
LE
EQ
NE
and
Here step name specifies name of preceding step whos RC will be checked.
Example of COND parameter:
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.
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 with
Ascending order and put the ascending output records in AK999.PS.NEW which is
my output dataset.
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 + or
ve 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:
My Command:
OUTPUT:
If you want to use multiple columns then see below command will also accept :
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:
Or same command you can hit on command line when you open file in EDIT mode
like below:
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
Program :
OUTPUT:
If i want to copy all eliminated records in one dataset then i use XSUM field as
well as add SORTXSUM Dataset name in program like below.
Now i have to add middle column to sum means to add so i use below program to
sum up middle columns value:
Program:
Output:
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.
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)
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.
Copy the data from one PDS member to another PDS member:
Program:
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.
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.
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 contents
is step01 from input PDS.
Content of step01.
This will copy all data from Job card to the end of that step program.
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.
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.
Submit this job will create a new version of GDG through catlog procedure.
Chapter-4
VSAM (Virtual
Storage Access
Method)
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.
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)
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:
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.
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 interval
B
Control interval
C
Control interval
D
Control interval
E
Control Area 2
Control
F
Control
G
Control
H
Control
I
Control
J
interval
interval
interval
interval
interval
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 name
AK999K.avinash.ksds1.
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 or
in .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 the
program 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 E
against 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 shows
you error while saving the content.
Now I am inserting amit after zebra then you can see the error message.
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 file
separately. Just a minute I will clear your all doubts.
JOB , ,NOTIFY=&SYSUID
EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE TXXXXX.VSAM.KSDSFILE
/*
So below program I have written in my JCL.
RECSZ(80,80)
TRACKS(1,1)
Program:
RECSZ(80,80)
TRACKS(1,1)
CISZ(4096)
FREESPACE(3,3))
/*
Output:
Dataset created:
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
As the records are not ascending order so it will not insert the record in between
two data names.
Now I will delete all the records of KSDS file so it will be empty.
As the records are of not fixed length it gives you error now I will make all records
of 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.
Program:
Output:
Data: