This document is (c) Copyright by Dave Edwards, 2005
1. Introduction
2. References
3. Abbreviations
4. Data Storage and Organization
5. Features Not Supported
6. Usage Notes
7. Main Storage Requirements
8. File Sharing
9. Error Codes
10. Abend Codes
11. Tracing and Debugging Facilities
12. Miscellaneous Notes
13. Sample Program
This file:
http://musicm.mcgill.ca/sim390/http/vsam_help.htm
Last updated Nov 23, 2005
MUSIC/SP VSAM (Virtual Storage Access Method) is an implementation of
the data organization method described in the IBM publication OS/VS
Virtual Storage Access Method (VSAM) Programmer's Guide, GC26-3838.
That publication describes the features and usage of VSAM from the
point of view of an assembler programmer. Most of the assembler
interface documented there is supported on MUSIC/SP for programs run-
ning in OS simulation mode. Some major features not supported by
MUSIC/SP are: control interval access, spanned records, data set
passwords.
The VSAM assembler interface is also used by higher level languages
which allow access to VSAM files. In this way, MUSIC/SP programs
written in languages such as PL/I, VS Cobol, and VS Fortran, in addi-
tion to VS Assembler, can use VSAM.
MUSIC/SP supports the three types of VSAM files: KSDS (key-sequenced
data set), ESDS (entry-sequenced data set), and RRDS (relative record
data set). The data records, which make up the data component, of a
VSAM file are stored in a single Save Library file or UDS (user data
set) file. In the case of a KSDS, the index component is stored in a
second Save Library file. Alternate indexes (which are themselves
KSDSs) can be built over a KSDS or ESDS. The Access Method Services
(AMS) utility program is used to create and initialize VSAM files on
MUSIC/SP.
The most significant feature of VSAM is its ability to access data
records by means of a key, which is a fixed-length field at a fixed
displacement in each data record. Each key, along with a pointer to
the data record which contains the key, is also stored in a multi-
level index (the primary index or an alternate index), which can be
quickly searched for a given key. Instead of specifying a record num-
ber or an address on disk, the user program specifies the key when
retrieving or updating a record. For example, a student number key
could be used to identify a student record in a file of marks, or a
part number could identify a part record within an inventory file.
Records can be added, changed and deleted; VSAM automatically updates
the index as required. It is also possible to access the data records
sequentially, in order of increasing or decreasing keys.
OS/VS Virtual Storage Access Method (VSAM) Programmer's Guide,
GC26-3838.
Introduction to IBM Direct-Access Storage Devices and Organization
Methods (student text), GC20-1649. Refer to the chapter on VSAM.
OS/VS2 Access Method Services, GC26-3841. On MUSIC/SP, a subset of
Access Method Services is provided by the utility program AMS.
Getting Into VSAM: An Introduction and Technical Reference,
by Michael P. Bouros. 1985. John Wiley & Sons. ISBN 0471812374.
Library of Congress ref: QA76.9 V5B68
ACB Access control block. An OS control block which is specified
in order to open a VSAM file (logically connect a program to a
VSAM file). The ACB is analogous to the DCB (data control
block) for non-VSAM files.
AMS Access Method Services utility program.
CA Control area. A logical group of control intervals.
CI Control interval. A fixed-length area on disk, where VSAM
stores data records. The CI corresponds to a logical block
for non-VSAM files.
ESDS Entry-sequenced data set. One of the 3 types of VSAM files.
KSDS Key-sequenced data set. One of the 3 types of VSAM files.
RBA Relative byte address. The displacement (expressed as a full-
word binary integer) of a data record or control interval from
the beginning of the data set. The VSAM RBA of the first con-
trol interval is 0.
RPL Request parameter list. An OS control block which defines an
input/output operation to be performed on a VSAM file.
RRDS Relative record data set. One of the 3 types of VSAM files.
RRN Relative record number. The record number (1, 2, 3,...) of a
data record (slot) in an RRDS.
A KSDS consists of a data component and an index component. An ESDS
or RRDS consists of a data component only (ignoring alternate indexes
for the moment). The data component and index component each occupy
one Save Library file on MUSIC/SP. It is possible for the data compo-
nent, but not the index component, to be a UDS (user data set) file
instead of a Save Library file.
For example, a KSDS cluster could comprise the 2 files SAMPLE1.DAT
(the data component) and SAMPLE1.IDX (the index component). Any file
names can be used, but a naming convention such as this is recom-
mended. The first 512-byte block of SAMPLE1.DAT contains the file
name of the index, along with other control information. The user
refers to the KSDS cluster by giving the file name of the data compo-
nent, SAMPLE1.DAT, usually on a /FILE statement.
MUSIC/SP does not have a separate VSAM catalog. Attributes and con-
trol information for a VSAM file are stored in the first 512-byte
block of the data component and index component files. User data
starts in the second 512-byte block. For example, if the control
interval size is 4096, which is eight 512-byte blocks, then the first
data CI occupies blocks 2 through 9 of the file and is at VSAM RBA 0.
The 2nd CI is blocks 10 through 17, at VSAM RBA 4096, etc. Control
information is in block 1.
The VSAM RBA is different from the MUSIC/SP file system (MFIO) RBA.
They are related by the formula: MFIO RBA = VSAM RBA + 1024.
An alternate index is a special type of KSDS which is associated with
a KSDS or ESDS base cluster. It allows access to data records via a
key field different from the primary key. Block 1 of the alternate
index data component contains the file name of the data component of
the base cluster. There can be several alternate indexes built over a
KSDS or ESDS. The combination of an alternate index and a base clus-
ter is called a path. Each path is given its own name and is repre-
sented by a 1-block file of that name. The path file contains the
file name of the alternate index data component. So, when a base KSDS
is accessed via a path, there are 5 MUSIC/SP files involved: the path
file, the data and index components of the alternate index, and the
data and index components of the base KSDS. The name of the path file
is specified on the /FILE statement.
A Save Library file which is part of a VSAM file normally has bit
X'20' on in the first byte of the 4-byte access control field.
VSAM control intervals on MUSIC/SP have the same format as on OS,
except that spanned records are not allowed.
VSAM indexes on MUSIC/SP have the same structure as on OS, and index
records have the same basic format, except for the following differ-
ences. The first index record (record 0) starts at the 2nd 512-byte
block of the file. Block 1 contains control information. There is
only one section per index record. In the sequence set (lowest
level), vertical pointers are always 3-byte CI numbers, relative to
the beginning of the data component, which starts with CI 0. Sequence
set records do not contain pointers to free CIs, since new CIs are
always added after existing CIs in the data component. Sequence set
records are chained backward as well as forward. A chain of free
index records is maintained.
Compared with OS VSAM, the following restrictions apply to MUSIC/SP
VSAM.
* Records may not span control intervals. This means that the long-
est record that can be stored is CILEN-7 bytes, where CILEN is the
data component CI length. CILEN can be up to 32768 if necessary,
but is fixed for a given file. This also restricts the number of
pointers that can be stored in an alternate index record, for an
alternate index with the NONUNIQUEKEY option. LRECL for an alter-
nate index should be defined as CILEN-7 to allow for records as
large as possible.
* Control interval access (MACRF=CNV and OPTCD=CNV) is not supported.
* Passwords for VSAM files are not supported.
* Reusable data sets (VSAM work files) are not supported. This is
the REUSE option of the AMS DEFINE command.
* These performance options are not supported: IMBED, KEYRANGES,
REPLICATE.
* The maximum number of alternate indexes in the upgrade set is 10.
Note that, as on OS, performance is slow when updating a base clus-
ter with several alternate indexes in its upgrade set, so the num-
ber of alternate indexes should be kept to a minimum.
* A data component is limited in size to the maximum Save Library
file, which is usually 56000K, unless the data component is a UDS.
However, an alternate index cannot be built over a UDS base.
* There are limitations on how VSAM files can be shared by multiple
users and/or programs. In general, concurrent updating by multiple
users or programs requires special handling. See the section on
file sharing below.
* The OPEN/CLOSE message area is not supported. If a message area
(MAREA and MLEN parameters) is defined for an ACB, it is ignored by
MUSIC/SP.
* MUSIC/SP VSAM is available in OS simulation mode only. It cannot
be used from Fortran G1 programs or other programs running in MUSIC
(non-OS) mode.
* Only the following types of exit routines are supported: EODAD
(end of data set), LERAD (logical error), SYNAD (physical error).
An exit routine must not be specified as the member name of a mod-
ule to be loaded dynamically by VSAM (the L option of EXLST).
* The following macros for advanced applications are not supported:
BLDVRP, DLVRP, GETIX, MRKBFR, PUTIX, SCHBFR, SHOWCAT, VERIFY,
WRTBFR.
* The following fields are not supported in SHOWCB and TESTCB macros
for an ACB: AVSPAC, BFRFND, BUFNO, BUFRDS, ENDRBA, FS, HALCRBA,
NCIS, NDELR, NEXCP, NEXT, NINSR, NIXL, NLOGR, NRETR, NSSS, NUIW,
NUPDR, STMT, UIW.
A VSAM file to be used by a program must first be created and initial-
ized by the DEFINE command of the AMS utility. At that time, you
specify file characteristics such as name, type of file, amount of
disk space required, data and index CI length, length (1 to 255) and
position of the key field, and maximum logical record length. Refer
to the description of the AMS utility for details.
For most applications, recommended index and data CI lengths are 512
and 4096, respectively. If the key length is 234 or more, the index
CI length must be at least 1024.
In order to use the file in a program, a /FILE statement of the fol-
lowing form is required:
/FILE ddname NAME(filename) disp
ddname is the 1- to 8-character data definition name used in the
program. This name is specified in the ACB when the file is
opened.
filename is the name of the data component Save Library file. In the
case of accessing a base cluster via an alternate index, it
is the name of the path file.
disp disp is the disposition. For read-only access, it should be
SHR. For read/write access, it should be OLD NORLSE. The
NORLSE option tells MUSIC/SP not to release unused space
when the job ends. NORLSE can be omitted if you do not
expect to make major additions to the file after this job.
To allow concurrent access by multiple users or programs,
some of which may be updating the file, the disposition
should be WSHR NORLSE for read/write, otherwise SHR.
VSAM services during a user program are provided by the re-entrant
modules VSAM (about 32K) and CBMANIP (about 14K). They are loaded
from the system Load Library or Link Pack Area the first time the job
requires them. They occupy main storage in the user region, unless
your system administrator has placed them into the Link Pack Area.
Module VSAM is always required for VSAM. CBMANIP is only required if
any of the control block manipulation macros (GENCB, MODCB, SHOWCB,
and TESTCB) are used. VSAM programs written in high-level languages
such as PL/I require CBMANIP.
In addition to storage for modules, VSAM requires a work area of about
10K in the user region.
VSAM requires data buffers and index buffers (in the case of a KSDS)
for each base cluster and alternate index cluster. They are allocated
in the user region when the VSAM file is opened.
The length of each data buffer is the data CI length. There is 1 data
buffer for each concurrent string (for most applications the number of
concurrent strings is 1). An additional 1 or 2 work data buffers are
required if a KSDS or alternate index base is being updated. These
additional buffers are allocated automatically and should not be
included in the number of buffers specified in the ACB or in the AMS
DEFINE command.
The length of each index buffer is the index CI length, normally 512.
There are no index buffers for an ESDS or RRDS. For a KSDS, there are
at least 4 index buffers. Specifying more index buffers will usually
increase performance, especially if the index is large and access is
not sequential.
Each alternate index cluster is a KSDS, and therefore has its own set
of data and index buffers.
Each open cluster requires approximately 2K additional storage for
miscellaneous control blocks and work areas.
A job that updates a VSAM file while other jobs are using the file
must specify WSHR, rather than OLD, on the /FILE statement. Using OLD
prevents all other jobs from accessing the file while the current job
is running.
When WSHR is specified, it is not possible to add space to a file.
Only the currently allocated space can be used.
When one job is updating a VSAM file while other jobs are accessing it
for read-only, read integrity for the other jobs is the responsibility
of those jobs. See the discussion of cross-region share option 2 in
the VSAM Programmer's Guide. Also, it is up to the updating job to
use ENQ or a similar facility to prevent other jobs from updating the
file at the same time.
If multiple jobs are allowed to update a file concurrently, read and
write integrity is the user's responsibility. See the discussion of
cross-region share options 3 and 4 in the VSAM Programmer's Guide. In
general, multiple concurrent updating is not recommended unless ENQ is
used to serialize all requests and the ENDREQ macro (or CLOSE TYPE=T)
is used to release buffers and positioning. MUSIC/SP VSAM does not
prevent concurrent updaters from ignoring these requirements and dam-
aging data.
The CLOSE TYPE=T request is useful when sharing files. It forces mod-
ified data buffers and block 1 buffers to disk, releases positioning,
invalidates the main storage copies of index buffers, and rereads
block 1 information from disk, but the data set remains open for fur-
ther processing. It is logically similar to a CLOSE followed by an
OPEN, but is more efficient. The ENDREQ macro does not invalidate
index buffers or update block 1 information.
MUSIC/SP does not support the shared resources feature of OS VSAM.
This refers to the sharing of control blocks and buffers among several
VSAM data sets open at the same time.
VSAM open, close, and input/output requests return an error code num-
ber if the request does not complete successfully. In some cases, the
error codes for MUSIC/SP differ slightly from those for OS VSAM. The
error codes for MUSIC/SP are listed below.
For open and close, the error code is returned in the byte at dis-
placement 49 in the ACB. For I/O requests, the error code is in the
4th byte of the feedback word in the RPL. The feedback word is at
displacement 12 in the RPL; the error code byte is at displacement 15.
The register 15 (R15) return code for an I/O request is in the 2nd
byte of the feedback word. An error code of 0 indicates successful
completion.
OPEN Error Codes When R15 Is Not 0
Note: Always test for an error condition after an OPEN, since attempt-
ing to use an ACB which was not opened successfully usually causes a
branch to location 0 (a program interrupt).
4 (Warning only.) The data set is already open.
128 The ddname is undefined, or an indicated Save Library file can-
not be found.
144 An I/O error occurred while reading or writing the control
information in block 1 of a VSAM file.
148 Unable to open a Save Library file, for a reason other than the
conditions in OPEN error codes 128, 152, 168, and 172.
152 Requested access to Save Library file is not allowed (MFIO error
code 43).
160 Inconsistent or invalid control information in block 1.
168 Save Library file is in use (MFIO error code 33).
172 Too many open files (MFIO error code 20).
188 The block 1 identifier is incorrect, or the file is not a VSAM
file, or a path file does not point to an alternate index, or an
item in the upgrade set is not an alternate index.
CLOSE Error Codes When R15 Is Not 0
4 The data set is already closed.
144 An I/O error occurred while writing block 1 control information
to disk, or (for CLOSE TYPE=T) while reading block 1.
148 Unable to close a MUSIC/SP file.
184 An I/O error occurred while VSAM was completing outstanding I/O
requests.
I/O Request Error Codes When R15=8 (Logical Error)
(For error codes not shown here, refer to the VSAM Programmer's Guide.)
4 End of data set encountered. Either no EODAD routine is pro-
vided, or it returned to VSAM and the processing program issued
another GET.
8 You attempted to store a record with a duplicate key, or there
is a duplicate record for an alternate index with the unique key
option.
16 Record not found.
32 You specified an RBA that is not the address of a data record.
44 For a GET with OPTCD=MVE, the receiving area is not large enough
for the data record. The data is truncated and the GET com-
pleted normally except for this. For a GET with OPTCD=LOC, the
receiving area is less than 4 bytes long.
64 The request cannot be started because the number of active
requests would exceed the maximum number of strings.
68 Attempt to PUT or ERASE on a read-only file. The file may be
read-only because SHR or WSHR was used on the /FILE statement,
or because the ACB specified input processing only.
72 Keyed request on an ESDS is not allowed.
76 Insert by RBA is not allowed on a KSDS.
80 ERASE on an ESDS is not allowed.
84 OPTCD=LOC is not allowed for a PUT request or in an RPL in a
chain of RPLs.
88 Required positioning does not exist, or you attempted an illegal
switch between forward and backward processing. For example,
you issued a sequential GET without having caused VSAM to be
positioned for it.
92 PUT for update or ERASE is not preceded by a GET for update.
96 An attempt to change the prime key or key of reference when
updating a record.
100 An attempt to change the length of a record when making an
addressed (by RBA) update.
104 Invalid or conflicting RPL options.
108 Invalid record length for a PUT. It is negative, or 0, or
larger than the maximum, or is too small to contain the entire
key field, or is not equal to the slot size for an RRDS.
112 Key length is 0 or too large.
144 Invalid pointer (no associated base record) in an alternate
index.
148 Unable to add a pointer to an alternate index record during
upgrade processing, because the resulting length of the alter-
nate index record would exceed the maximum record length or
CILEN-7. The original PUT request is not done.
192 Invalid relative record number (RRN) for a request on an RRDS.
196 Addressed request is not allowed on an RRDS.
200 Addressed access is not allowed through a path.
204 PUT insert request is not allowed during backward processing.
I/O Request Error Codes When R15=12 (Physical Error)
4 Read error in a data component.
8 Read error in an index component.
16 Write error in a data component.
20 Write error in an index component.
I/O Error Message Area Contents
When a physical error occurs (return code R15=12 for an I/O request)
and the RPL specifies a message area which is 128 bytes or longer,
MUSIC/SP VSAM fills in the message area as described below. The first
12 bytes are the same as in OS VSAM. The remaining bytes are in prin-
table format, and are different on MUSIC/SP and OS. Only the first
128 bytes are filled in. No bytes are filled in if the message area
length is less than 128.
Bytes 0-1: Binary value 128 (message length).
Bytes 2-3: Unused (0).
Bytes 4-5: Binary value 124.
Bytes 6-7: Unused (0).
Bytes 8-11: I/O buffer address.
Bytes 12-127: Printable text in the format:
VSAM dddddddd t-ccccc I/O ERROR nnn: xx BLK=mmmmmm
LEN=lllll BUF=aaaaaa yyyyy...
Bytes 17-24: (dddddddd) The file's ddname.
Byte 26: (t) B for base cluster, A for alternate index cluster,
or U for alternate index cluster being accessed during
upgrade processing.
Bytes 28-32: (ccccc) DATA for an data component or INDEX for an
index component.
Bytes 44-46: (nnn) MUSIC/SP file system (MFIO) error code.
Bytes 49-50: (xx) RD for a read operation or WR for a write opera-
tion.
Bytes 56-61: (mmmmmm) The starting 512-byte block number where the
error occurred.
Bytes 67-71: (lllll) The length used in the MFIO I/O request.
Bytes 77-82: (aaaaaa) The buffer address used in the MFIO I/O
request.
Bytes 84-127: (yyyyy...) The first 44 characters of the error
description text corresponding to the MFIO error code.
This describes the reason for the error.
When VSAM detects an unexpected error which it cannot recover from, it
issues an abend (abnormal end) message on logical unit 6 (i.e. the
terminal or whatever is defined as /FILE 6). The message contains an
abend code number, which indicates the reason for the abend.
The format of the abend message is:
*VSAM ABEND nnn AT aaaaaa INFO = xxxxxxxx xxxxxxxx xxxxxxxx
nnn is the abend code. aaaaaa is the address from which the abend
routine was invoked. xxxxx.... gives 3 words of additional informa-
tion, in hexadecimal. The meaning of the INFO words depends on the
abend code.
Following the abend message, VSAM enters a conversational dump routine
(for a terminal job) or dumps the user region (for a job running on
batch). Then the job is terminated.
For a complete listing of the abend codes, list or edit file
VSAM.ABENDS.
Some notable abend codes are:
5 Not enough index buffers.
6 Unexpected error while retrieving a data record from a control
interval. This error usually indicates invalid control informa-
tion in a data CI.
7 Attempt to access a spanned record. Spanned records are not
supported.
10 Attempt to use control interval access. CI access is not sup-
ported.
14 Illegal change of request options in an RPL chain.
17 An invalid index record has been encountered. The first word of
INFO has the index record number in hexadecimal.
19 Invalid record in the data component of an alternate index clus-
ter.
22 Chained RPLs are not allowed with a PUT/update or ERASE request.
26 For a PUT request, the address of the logical record in the RPL
(the RPL AREA field) is 0. I.e. no area address has been pro-
vided.
Two options on the /JOB statement (or on the member name statement for
/LOAD XMON) can be used to trace and debug the internal workings of
the VSAM processing modules. In some cases these options are useful
in determining why a user program is failing.
The IOTRACE option causes a trace message to be written to logical
unit 6 for each entry to, or exit from, a VSAM processing routine.
Since many routine calls are made for each user request, this option
may generate a very large amount of output.
If the CDUMP option is used with IOTRACE, a conversational dump rou-
tine is entered after each VSAM trace message. Commands, read conver-
sationally from logical unit 9, are used to inspect and modify main
storage and registers, to skip a specified number of subsequent trace
items, and to turn VSAM tracing on or off. Enter a blank line to
resume execution. To suppress all further VSAM tracing, enter the
command TRACE END and then a blank line (non-VSAM tracing will con-
tinue).
* For a GET request, if the address in the RPL of the receiving area
for the logical record (the RPL AREA field) is zero, then no data
is moved but the GET is completed normally and no error indication
is given. This applies to both move and locate mode.
* It is possible to open a VSAM file dynamically. Normally a ddname
is specified in the ACB when a file is opened. In that case the
file must be defined by a /FILE statement. A special form of
ddname is used to open a VSAM file which is not defined on a /FILE
statement. This feature is available only on MUSIC/SP. The 8-byte
ddname field is, in hexadecimal, 0Fxx0000 00aaaaaa, where 0F indi-
cates this special type of OPEN, xx contains option bits, and
aaaaaa is the address of a 22-character area which contains the
full Save Library file name of the data component or path file.
Bits in the option byte are: X'80' on means the cluster is to be
opened read-only (equivalent to SHR on /FILE); X'40' bit is used
internally by VSAM OPEN; X'20' on means that the cluster is to be
opened for shared read/write (WSHR on /FILE). Option byte X'00'
opens the cluster for non-shared read/write (OLD on /FILE).
* The OS RDJFCB macro (read Job File Control Block, SVC 64) can be
used before OPEN to test whether a ddname represents a VSAM or non-
VSAM file. This is useful to know, since opening a VSAM file
requires an ACB while opening a non-VSAM file requires a DCB. On
MUSIC/SP, the byte at displacement 99 (JFCDSRG2) in the JFCB for a
VSAM file has bit X'08' on. After the RDFJCB, do a normal OPEN,
not OPEN TYPE=J. Refer to RDJFCB in OS/VS2 System Programming
Library: Data Management, GC26-3830.
PL/I Support
The environment option REUSE is not supported by MUSIC/SP.
The environment option BUFND(n) should not be used, since extra data
component buffers will not improve performance. The BUFSP(n) option
is not supported. Use BUFNI(n) to specify the number of index buffers
if you wish to use more than the standard number.
The VSAM Compatibility Interface, which allows a VSAM file to be
accessed by a PL/I program originally written to access an ISAM file,
is not supported.
The sample assembler program presented here uses the macros described
in the VSAM Programmer's Guide to copy records from a sequential file,
MYDATA, to a VSAM KSDS file, VSAMFILE1.DAT. The records are added as
new records.
The following job creates and initializes the data and index compo-
nents of the KSDS using the AMS utility. The key field occupies the
first 8 bytes of each record. The initial space allocation for the
data component is 20K. The data control interval size is 4096. The
name of the index component file is VSAMFILE1.IDX. The index control
interval size is 512 by default.
/INCLUDE AMS
DEFINE CLUSTER(NAME(VSAMFILE1.DAT) INDEXED SPACE(20) -
CISZ(4096) KEYS(8 0))
The sample program is listed below. It is contained in file
VSAM.SAMPLE.
/FILE DDNAME1 NAME(MYDATA) SHR
/FILE DDNAME2 NAME(VSAMFILE1.DAT) OLD NORLSE
/LOAD ASM
*
* THIS SAMPLE PROGRAM READS DATA RECORDS FROM A SEQUENTIAL
* FILE ON DDNAME "DDNAME1" AND WRITES THEM TO A VSAM KSDS
* ON DDNAME "DDNAME2". IT IS ASSUMED THAT THE VSAM FILE
* HAS ALREADY BEEN CREATED AND INITIALIZED.
* THE INPUT RECORDS ARE ASSUMED TO BE OF LENGTH 80.
*
* AN OPEN ERROR CAUSES AN INVALID OP-CODE WITH R7=X'EE1' AND
* R0=OPEN ERROR CODE.
*
* AN ERROR WRITING TO THE VSAM FILE CAUSES AN INVALID OP-CODE
* WITH R7=X'EE2', R0=ERROR CODE FROM PUT, R15=RETURN CODE FROM PUT.
*
SAMPLE CSECT
REGS , THIS MACRO DEFINES REGISTERS
STM R14,R12,12(R13) SAVE REGISTERS
LR R12,R15 SET UP A BASE REGISTER
USING SAMPLE,R12
LA R14,SAVEAREA SET UP A SAVE AREA
ST R13,4(0,R14)
ST R14,8(0,R13)
LR R13,R14
* OPEN THE TWO FILES
OPEN (MYDCB,INPUT) OPEN SEQUENTIAL FILE
OPEN (MYACB) OPEN VSAM FILE, USING AN ACB
* GET ERROR CODE FIELD FROM ACB
SHOWCB ACB=MYACB,AREA=OPENERRC,LENGTH=4,FIELDS=(ERROR)
L R0,OPENERRC
LTR R0,R0 TEST FOR VSAM OPEN ERROR
BZ OPENOK BRANCH IF NO ERROR
* VSAM OPEN ERROR
LA R7,X'EE1' INDICATE INTENTIONAL P.I.
DC H'0' STOP JOB BY INVALID OP-CODE
OPENOK DS 0H
* READ LOOP: READ NEXT RECORD INTO "MYAREA"
READLOOP GET MYDCB,MYAREA READ RECORD USING QSAM
PUT RPL=MYRPL WRITE RECORD TO VSAM FILE
LTR R15,R15 TEST FOR WRITE ERROR
BZ READLOOP BRANCH IF NO ERROR
* VSAM ERROR: GET ERROR CODE FROM RPL
LR R5,R15 SAVE R15 RETURN CODE
SHOWCB RPL=MYRPL,AREA=REQERR,LENGTH=4,FIELDS=(FDBK)
L R0,REQERR GET ERROR CODE IN R0
LR R15,R5 RESTORE R15 RETURN CODE
LA R7,X'EE2' INDICATE INTENTIONAL P.I.
DC H'0' STOP JOB BY INVALID OP-CODE
* COME HERE WHEN END-OF-FILE ON INPUT: CLOSE THE FILES
EOF CLOSE (MYDCB)
CLOSE (MYACB)
* WRITE MESSAGE TO TERMINAL
WTO 'VSAM SAMPLE PROGRAM ENDED NORMALLY'
* RETURN TO SYSTEM
L R13,4(0,R13) RESTORE SAVE AREA POINTER
LM R14,R12,12(R13) RESTORE REGISTERS
BR R14 RETURN
* STORAGE AREAS
SAVEAREA DS 18F STANDARD SAVE AREA
OPENERRC DS F RECEIVES OPEN ERROR CODE
REQERR DS F RECEIVES ERROR CODE FROM RPL
MYAREA DS CL80 LOGICAL RECORD BUFFER
* DCB FOR SEQUENTIAL INPUT FILE
MYDCB DCB DDNAME=DDNAME1,DSORG=PS,MACRF=GM,LRECL=80,EODAD=EOF
* ACB FOR OPENING VSAM FILE
MYACB ACB DDNAME=DDNAME2,MACRF=(KEY,SEQ,OUT)
* RPL FOR REQUESTS ON THE VSAM FILE
MYRPL RPL ACB=MYACB,AREA=MYAREA,AREALEN=80,RECLEN=80, XX
OPTCD=(KEY,SEQ,NUP)
END
-----
Converted Wed Nov 23, 2005 08:13:36 by help2html from Help file $HLP:@GO.VSAM