You are on page 1of 13

INTERVIEW TOPICS (VSAM):

VSAM (Virtual Access Storage Method): 1) What are VSAM datasets? VSAM data sets are held on direct access storage devices (DASD) auxiliary storage. VSAM divides its data set storage into control areas (CA), hich are !urther divided into control intervals (C"). Control intervals are the unit o! data trans#ission $et een virtual and auxiliary storage. %ach one is o! !ixed si&e and, in general, contains a nu#$er o! records. A 'SDS or %SDS can have records that extend over #ore than one control interval. (hese are called s)anned records.
(here are so#e s)ecial coding considerations !or VSAM !iles under &*+S !or access #ethod services ("DCAMS) co##ands, environ#ent varia$les, and ,C-. A VSAM !ile is availa le i! all o! the !ollo ing conditions are true.

o o o

/ou de!ine it using access #ethod services. /ou de!ine it !or your )rogra# $y )roviding a DD state#ent, an environ#ent varia$le, or an ALLOCATE co##and. "t has )reviously contained a record.

A VSAM !ile is unavailable i! it has never contained a record, even i! you have de!ined it. /ou al ays get a return code o! &ero on co#)letion o! the OPEN state#ent !or a VSAM se0uential !ile. 1se the access #ethod services REPRO co##and to e#)ty a !ile. Deleting records in this #anner resets the high2use relative $yte address (34A) o! the !ile to &ero. (he !ile is e!!ectively e#)ty and a))ears to C+4+- as i! it never contained a record.

5) What are the di!!erent ty)e o! VSAM datasets and de!ine each? (he di!!erent ty)es o! VSAM datasets are as !ollo s. o 'ey2se0uenced data set ('SDS) o %ntry2se0uenced data set (%SDS) o 3elative record data set (33DS) ($oth !ixed and varia$le record lengths) 'ey2se0uenced data set ('SDS) o A 6ey2se0uenced data set has each o! its records identi!ied $y a 6ey. ((he 6ey o! each record is si#)ly a !ield in a )rede!ined )osition ithin the record.) o o %ach 6ey #ust $e uni0ue in the data set. When the data set is initially loaded ith data, or hen ne records are added, the logical order o! the records de)ends on the collating se0uence o! the 6ey !ield. (his also !ixes the order in hich you retrieve records hen you $ro se through the data set.

o (o !ind the )hysical location o! a record in a 'SDS, VSAM creates and


#aintains an index. (his relates the 6ey o! each record to the record7s

relative location in the data set. When you add or delete records, this index is u)dated accordingly. o o 'SDS records can $e retrieved directly ith a 6ey. (he 6ey is s)eci!ied hen you de!ine the dataset and can $e u) to 588 $ytes at any o!!set into the record. A 'SDS is #ade u) o! t o co#)onents, the data and an index. (he data co#)onent contains, the, er, data. (he index contains the 6eys and )ointers into the data co#)onent. 9ote that a 'SDS uses a s)arse index hich assu#es the records are in order ithin the data $loc6s hich is hy you can7t load a 'SDS ith records that are out o! order. (he data and index co#)onents are lin6ed together in a logical entity 6no n as a cluster. 1sually )rocesses re!er to the cluster na#e to use a 'SDS. 1nli6e an %SDS or 33DS, deleted 'SDS records are )hysically re#oved and the s)ace is reclai#ed.

%ntry2se0uenced data set (%SDS) o o An entry2se0uenced data set is one in hich each record is identi!ied $y its relative $yte address (34A). 3ecords are held in an %SDS in the order in hich they ere !irst loaded into the data set. 9e records added to an %SDS al ays go a!ter the last record in the data set. /ou #ay not delete records or alter their lengths. A!ter a record has $een stored in an %SDS, its 34A re#ains constant. When $ro sing, records are retrieved in the order in hich they ere added to the data set. An %SDS is essentially a se0uential dataset here ne records are al ays inserted at the end. /ou cannot access records directly ith a 6ey. :o ever, you #ay access s)eci!ic records ith a relative $yte address (34A), i! you have or can calculate it. "n !act, it7s !airly co##on to see C"CS a))lication use an %SDS as a log !ile to rite records in se0uential order hile retrieving the ne record7s 34A !ro# the 3"D;-D o)erand o! the %<%C C"CS W3"(% co##and. "! the a))lication s0uirrels a ay the 34A it can later retrieve the log record directly. Also note that you cannot )hysically delete a record !ro# an %SDS. "nstead, #ost a))lications utili&e a =logical delete= sche#e here a !ield in the %SDS record is set to a value indicating the record is no longer valid. o 3elative record data set (33DS)

A relative record data set has records that are identi!ied $y their relative record nu#$er (339). (he !irst record in the data set is 339 1> the second is 339 5, and so on. 3ecords in an 33DS can $e !ixed or varia$le length records, and t he ay in hich VSAM handles the data de)ends on hether the data set is a !ixed or varia$le 33DS. A !ixed 33DS has !ixed2length slots

o o o

)rede!ined to VSAM, into hich records are stored. (he length o! a record on a !ixed 33DS is al ays e0ual to the si&e o! the slot. VSAM locates records in a !ixed 33DS $y #ulti)lying the slot si&e $y the 339 ( hich you su))ly on the !ile control re0uest), to calculate the $yte o!!set !ro# the start o! the data set. A varia$le 33DS, on the other hand, can acce)t records o! any length u) to the #axi#u# !or the data set. "n a varia$le 33DS VSAM locates the records $y #eans o! an index. A !ixed 33DS generally o!!ers $etter )er!or#ance. A varia$le 33DS o!!ers greater !unction. An 33DS consists o! )re!or#atted, !ixed length slots that #ay or #ay not have records in the#. 33DS7s can $e )rocessed se0uentially or directly through a relative record nu#$er (339). 9ote that hen a record is erased the slot still holds its )lace in the dataset, unli6e a 'SDS here VSAM reclai#s the e#)ty s)ace.

(he !ollo ing ta$le co#)ares the characteristics o! the di!!erent ty)es o! VSAM data sets.
Comparison of VSAM data-set types

Characteristic

E!tr"#se$ue!ced data set &e"#se$ue!ced data set (ES%S) (&S%S)

Relative#record data set (RR%S)

+rder o! records

+rder in hich they are ritten

Collating se0uence $y 6ey !ield

+rder o! relative record nu#$er

Access

Se0uential

4y 6ey through an index

4y relative record nu#$er, hich is handled li6e a 6ey

Alternate indexes

Can have one or #ore Can have one or #ore alternate indexes, although alternate indexes not su))orted in C+4+-

Cannot have alternate indexes

3elative $yte address (34A) and relative record nu#$er (339) o! a record

34A cannot change.

34A can change.

339 cannot change.

S)ace !or adding records

1ses s)ace at the end o! the data set

1ses distri$uted !ree s)ace !or ;or !ixed2length 33DS, uses inserting records and e#)ty slots in the data set changing their lengths in )lace ;or varia$le2length 33DS, uses distri$uted !ree s)ace and changes the lengths o! added records in )lace

S)ace !ro# deleting records

/ou cannot delete a record, $ut you can reuse its s)ace !or a record o! the sa#e length.

S)ace !ro# a deleted or shortened record is auto#atically reclai#ed in a control interval.

S)ace !ro# a deleted record can $e reused.

Comparison of VSAM data-set types

Characteristic S)anned records 3euse as or6 !ile

E!tr"#se$ue!ced data set &e"#se$ue!ced data set (ES%S) (&S%S) Can have s)anned records Can have s)anned records Can $e reused unless it has an alternate index, is associated ith 6ey ranges, or exceeds 15? extents )er volu#e

Relative#record data set (RR%S) Cannot have s)anned records

Can $e reused unless it has Can $e reused an alternate index, is associated ith 6ey ranges, or exceeds 15? extents )er volu#e

?) :o

are VSAM !iles de!ined? /ou can )rocess VSAM entry2se0uenced, 6ey2se0uenced, and relative2record data sets in %nter)rise C+4+- only a!ter you de!ine the# through access #ethod services (I%CAMS). A VSAM cluster is a logical de!inition !or a VSAM data set and has one or t o co#)onents. (he data co#)onent o! a VSAM cluster contains the data records. (he index co#)onent o! a VSAM 6ey2se0uenced cluster consists o! the index records. 1se the D%;"9% C-1S(%3 access2#ethod services co##and to de!ine VSAM data sets (clusters). (his )rocess includes creating an entry in an integrated catalog ithout any data trans!er. De!ine the !ollo ing in!or#ation a$out the cluster. o o 9a#e o! the entry 9a#e o! the catalog to contain this de!inition and its )ass ord (can use de!ault na#e) o +rgani&ation (se0uential, indexed, or relative) o Device and volu#es that the data set ill occu)y o S)ace re0uired !or the data set o 3ecord si&e and control interval si&es (C"S"@%) o Aass ords (i! any) re0uired !or !uture access De)ending on hat 6ind o! data set is in the cluster, also de!ine the !ollo ing in!or#ation !or each cluster. o o o o ;or VSAM indexed data sets ('SDS), s)eci!y length and )osition o! the )ri#e 6ey in the records. ;or VSAM !ixed2length relative2record data sets (33DS), s)eci!y the record si&e as greater than or e0ual to the #axi#u# si&e C+4+- record. D%;"9% C-1S(%3 91M4%3%D 3%C+3DS"@%(n,n) When you de!ine a data set in this ay, all records are )added to the !ixed slot si&e n. "! you use the 3%C+3D "S VA3/"9B +9 data2na#e !or# o! the 3%C+3D clause, a W3"(% or 3%W3"(% uses the length s)eci!ied in D%A%9D"9B +9 data2na#e as the length o! the record to $e trans!erred $y VSAM. (his data is then )added to the !ixed slot si&e.

3%AD state#ents al ays return the !ixed slot si&e in the D%A%9D"9B +9 data2na#e. o ;or VSAM varia$le2length relative2record data sets (33DS), s)eci!y the average si&e C+4+- record ex)ected and the #axi#u# si&e C+4+record ex)ected. D%;"9% C-1S(%3 91M4%3%D 3%C+3DS"@%(avg,#) (he average si&e C+4+- record ex)ected #ust $e less than the #axi#u# si&e C+4+- record ex)ected. o ;or C+4+- si#ulated varia$le2length relative2record data sets, s)eci!y the average si&e o! the C+4+- records and a si&e that is greater than or e0ual to the #axi#u# si&e C+4+- record )lus C. D%;"9% C-1S(%3 "9D%<%D '%/S(C,D) 3%C+3DS"@%(avg,#) (he average si&e C+4+- record ex)ected #ust $e less than the #axi#u# si&e C+4+- record ex)ected. C) :o

do you de!ine VSAM !ile organi&ations and records in a C+4+- )rogra#


;or all !iles that you )rocess in your C+4+- )rogra#, you need to de!ine the !iles to the o)erating syste# ith an a))ro)riate syste# data de!inition. De)ending on the o)erating syste#, this syste# data de!inition can ta6e any o! the !ollo ing !or#s.

o o

DD state#ent !or MVS ,C-. ALLOCATE co##and under (S+.

(he !ollo ing exa#)les sho the relationshi) o! a FILE-CONTROL entry to the syste# data de!inition and to the FD entry in the FILE SECTION. ,C- DD state#ent.
(1) //OUTFILE (50,5)) /* DD DSNAME=MY.OUT171,UNIT=SYSDA,SPACE=(TRK,

C+4+- code.
EN IRONMENT DI ISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CARPOOL ASSI!N TO OUTFILE (1) OR!ANI"ATION IS SE#UENTIAL. . . . DATA DI ISION. FILE SECTION. FD CARPOOL (2) LA$EL RECORD STANDARD $LOCK CONTAINS 0 C%ARACTERS RECORD CONTAINS &0 C%ARACTERS

(') (he assignment-name in the ASSI!N clause )oints to the ddname OUTFILE in the DD state#ent or the environ#ent varia$le OUTFILE in the '()o*+ co##and. //OUTFILE DD DSNAME=OUT171 . . ., or '()o*+ OUTFILE= . . . (() When you s)eci!y a !ile file-name in a FILE-CONTROL entry, you #ust descri$e the !ile in an FD entry.
SELECT CARPOOL . . . FD CARPOOL

1se an entry in the FILE-CONTROL )aragra)h in the EN IRONMENT DI ISION to de!ine the !ile organi&ation and access #odes !or the VSAM !iles in your C+4+)rogra#. "n the FILE SECTION o! the DATA DI ISION, code a !ile descri)tion (FD) entry !or the !ile. "n the associated record descri)tion entry or entries, de!ine the record-name and record length. Code the logical si&e o! the records ith the RECORD clause. I)*orta!t: /ou can )rocess VSAM data sets in %nter)rise C+4+- )rogra#s only a!ter you de!ine the# ith access #ethod services. Table 26. VSAM file organization, access mode, and record format
+ile orga!i,atio! Se$ue!tial access Ra!do) access %"!a)ic access +i-ed le!gth Varia le le!gth

VSAM se0uential (%SDS)

/es

9o

9o

/es

/es

VSAM indexed ('SDS)

/es

/es

/es

/es

/es

VSAM relative (33DS)

/es

/es

/es

/es

/es

1se the state#ents sho n $elo to load records into a VSAM !ile.

Table 1. Statements to load records into a VSAM file


%ivisio! ES%S &S%S RR%S

%9V"3+9M%9(

DI ISION

S%-%C(

S%-%C(

S%-%C(

ASSI!N FILE STATUS PASS,ORD ACCESS MODE

ASSI!N OR!ANI"ATION IS INDE-ED RECORD KEY

ASSI!N OR!ANI"ATION IS RELATI E RELATI E KEY

Table 1. Statements to load records into a VSAM file


%ivisio! ES%S &S%S RR%S

ALTERNATE RECORD KEY FILE STATUS PASS,ORD ACCESS MODE


DA(A DI

FILE STATUS PASS,ORD ACCESS MODE

ISION

;D entry

;D entry

;D entry

A3+C%D13%

DI ISION

+A%9 +1(A1(

+A%9 +1(A1(

+A%9 +1(A1(

OPEN E-TEND ,RITE CLOSE

OPEN E-TEND ,RITE CLOSE

OPEN E-TEND ,RITE CLOSE

(o u)date a VSAM !ile, use these PROCEDURE

DI ISION state#ents.

Table 1. Statements to update records in a VSAM file


Access )ethod ES%S &S%S RR%S

ACCESS IS SE#UENTIAL

OPEN E-TEND

,RITE CLOSE
or

OPEN E-TEND

,RITE CLOSE
or

OPEN E-TEND

,RITE CLOSE
or

OPEN I-O READ RE,RITE CLOSE


ACCESS IS RANDOM 9ot a))lica$le

OPEN I-O READ RE,RITE DELETE CLOSE


OPEN I-O

OPEN I-O READ RE,RITE DELETE CLOSE


OPEN I-O

READ ,RITE RE,RITE DELETE CLOSE

READ ,RITE RE,RITE DELETE CLOSE

Table 1. Statements to update records in a VSAM file


Access )ethod ES%S &S%S RR%S

ACCESS IS DYNAMIC (se0uential )rocessing)

9ot a))lica$le OPEN I-O

READ NE-T ,RITE RE,RITE START DELETE CLOSE


9ot a))lica$le OPEN I-O

OPEN I-O

READ NE-T ,RITE RE,RITE START DELETE CLOSE


OPEN I-O

ACCESS IS DYNAMIC (rando# )rocessing)

READ ,RITE RE,RITE DELETE CLOSE

READ ,RITE RE,RITE DELETE CLOSE

8) What is an Alternate "ndex (A"<)? :o is it de!ined and loaded? An alternate index is a 6ey2se0uenced data set containing index entries organi&ed $y the alternate 6eys o! its associated $ase data records. "t )rovides another ay o! locating records in the data co#)onent o! a cluster. An alternate index can $e de!ined over a 6ey2se0uenced or entry2se0uenced cluster. An alternate index cannot $e de!ined !or a reusa$le cluster, a !ixed2 or varia$le2 length 33DS, an extended addressa$le %SDS, a catalog, a VVDS (data set na#e 7S/S1.VVDS.Vvolser7), another alternate index, a linear data set, or a non2 VSAM data set. (he data class )ara#eter can $e s)eci!ied !or a syste#2#anaged alternate index. Access #ethod services D%;"9% ill assign the sa#e #anage#ent class and storage class as the alternate index7s $ase cluster. "! a $ase cluster is de!ined as extended !or#at, then the alternate index it relates to #ust $e a$le to $e de!ined as extended !or#at. Alternate indexes cannot $e co#)ressed. (he se0uence !or $uilding an alternate index is as !ollo s. 1. De!ine the $ase cluster, using either the A--+CA(% co##and, the D%;"9% C-1S(%3 co##and, or ,C-. 5. -oad the $ase cluster either $y using the 3%A3+ co##and or $y riting your o n )rogra# to load the data set. ?. De!ine the alternate index, using the D%;"9% A-(%39A(%"9D%< co##and.

C. 3elate the alternate index to the $ase cluster, using the D%;"9% AA(: co##and. (he $ase cluster and alternate index are descri$ed $y entries in the sa#e catalog. 5. 4uild the alternate index, using the 4-D"9D%< co##and. 4-D"9D%< is used to $uild the alternate 6eys and load the alternate indexes.

6) What is the 1se o! the -ist and Veri!y co##and?


(he -"S(CA( co##and is )rovided to list the in!or#ation !ro# catalog entries. "! you have $een reading this )age in se0uence, you have already seen out)ut !ro# the -"S(CA( co##and in the S/S+1( listings !ro# #y exa#)les o! #any o! the other AMS co##ands. "t is al#ost al ays a good idea to list the catalog entries !or o$Eects i##ediately !ollo ing their creation to visually veri!y that all o! the o)tions you intended to s)eci!y ere entered correctly and had the desired e!!ect on the entry created. "t is also !re0uently necessary to list !ields !ro# the catalog entry !or a VSAM o$Eect to diagnose )ro$le#s. (he V%3";/ co##and is used to veri!y VSAM Dataset. "! a Eo$ ter#inates a$nor#ally and a VSAM dataset is not closed, the catalog entry !or the dataset is !lagged to indicate that the dataset #ay $e corru)t. 4e!ore the dataset can $e o)ened again, the V%3";/ co##and #ust $e used to correctly identi!y the end o! the dataset and reset the catalog entry.

F) :o

are e#)ty VSAM !iles loaded? (here are ? techni0ues to initially load a e#)ty VSAM !ile. o "nitially loading a !ile se0uentially o "nitially loading a !ile rando#ly or dyna#ically o -oading a VSAM data set ith access #ethod services

"nitially loading a !ile se0uentially. o "nitially loading a !ile #eans riting records into the !ile !or the !irst ti#e. Doing so is not the sa#e as riting records into a !ile !ro# hich all )revious records have $een deleted. (o initially load a VSAM !ile. 1. +)en the !ile. 2. 1se se0uential )rocessing (ACC%SS "S S%G1%9("A-). (Se0uential )rocessing is !aster than rando# or dyna#ic )rocessing.) 3. 1se W3"(% to add a record to the !ile. 1sing +A%9 +1(A1( to load a VSAM !ile signi!icantly i#)roves the )er!or#ance o! your )rogra#. 1sing +A%9 "2+ or +A%9 %<(%9D has a negative e!!ect on the )er!or#ance o! your )rogra#. When you load VSAM indexed !iles se0uentially, you o)ti#i&e $oth loading )er!or#ance and su$se0uent )rocessing )er!or#ance, $ecause se0uential )rocessing #aintains user2de!ined !ree s)ace. ;uture insertions ill $e #ore e!!icient.

o With ACC%SS "S S%G1%9("A-, you #ust rite the records in ascending
3%C+3D '%/ order. o When you load VSAM relative !iles se0uentially, the records are )laced in the !ile in the ascending order o! relative record nu#$ers.

"nitially loading a !ile rando#ly or dyna#ically.

o /ou can use rando# or dyna#ic )rocessing to load a !ile, $ut they are not as
e!!icient as se0uential )rocessing. 4ecause VSAM does not su))ort rando# or dyna#ic )rocessing, C+4+- has to )er!or# so#e extra )rocessing to ena$le you to use ACC%SS "S 3A9D+M or ACC%SS "S D/9AM"C ith +A%9 +1(A1( or +A%9 "2+. (hese ste)s )re)are the !ile !or use and give it the status o! a loaded !ile $ecause it has $een used at least once. o "n addition to extra overhead !or )re)aring !iles !or use, rando# )rocessing does not consider any user2de!ined !ree s)ace. As a result, any !uture insertions #ight $e ine!!icient. Se0uential )rocessing #aintains user2de!ined !ree s)ace.

o When you are loading an extended2!or#at VSAM data set, !ile status ?D ill
occur !or the +A%9 i! &*+S D;SMS syste#2#anaged $u!!ering sets the $u!!ering to local shared resources (-S3). (o success!ully load the VSAM data set in this case, s)eci!y ACC4"ASH1S%3 in the DD AMA )ara#eter !or the VSAM data set to $y)ass syste#2#anaged $u!!ering.

-oading a VSAM data set


o

ith access #ethod services

/ou can load or u)date a VSAM data set $y using the access #ethod services REPRO co##and. 1se REPRO henever )ossi$le.

I) :o

can records $e added to a non e#)ty VSAM !ile?


1se the C+4+- ,RITE state#ent to add a record to a !ile records. ithout re)lacing any existing

(he record to $e added #ust not $e larger than the #axi#u# record si&e that you set hen you de!ined the !ile. /our )rogra# should chec6 the !ile status 6ey a!ter each ,RITE state#ent. (here are 5 techni0ues )rogra##atically to add records in a VSAM !ile. o o Adding records se0uentially Adding records rando#ly or dyna#ically

Addi!g records se$ue!tiall"

1se ACCESS IS SE#UENTIAL and code the ,RITE state#ent to add records se0uentially to the end o! a VSAM !ile that has $een o)ened ith either OUTPUT or E-TEND. Se0uential !iles are al ays ritten se0uentially.

;or indexed !iles, you #ust rite ne records in ascending 6ey se0uence. "! you o)en the !ile E-TEND, the record 6eys o! the records to $e added #ust $e higher than the highest )ri#ary record 6ey on the !ile hen you o)ened the !ile. ;or relative !iles, the records #ust $e in se0uence. "! you include a RELATI E KEY data ite# in the SELECT clause, the relative record nu#$er o! the record to $e ritten is )laced in that data ite#. Adding records rando#ly or dyna#ically

Addi!g records ra!do)l" or d"!a)icall" o When you rite records to an indexed data set and ACCESS IS RANDOM or ACCESS IS DYNAMIC, you can rite the records in any order.

J) :o

are records in a VSAM !ile u)dated*re)laced?


(o re)lace a record in a VSAM !ile, use REWRITE on a !ile that you o)ened as I-O. "! the !ile as not o)ened as I-O, the record is not re ritten and the status 6ey is set to CJ. Chec6 the !ile status 6ey a!ter each RE,RITE state#ent. ;or se0uential !iles, the length o! the re)lace#ent record #ust $e the sa#e as the length o! the original record. ;or indexed !iles or varia$le2length relative !iles, you can change the length o! the record you re)lace. (o re)lace a record rando#ly or dyna#ically, you do not have to !irst READ the record. "nstead, locate the record you ant to re)lace as !ollo s.

o o

;or indexed !iles, #ove the record 6ey to the RECORD KEY data ite#, and then issue the RE,RITE. ;or relative !iles, #ove the relative record nu#$er to the RELATI E KEY data ite#, and then issue the RE,RITE.

1D) :o

do you delete records !ro# a VSAM !ile?


(o re#ove an existing record !ro# an indexed or relative !ile, o)en the !ile I-O and use the DELETE state#ent. /ou cannot use DELETE on a se0uential !ile.

When you use ACCESS IS SE#UENTIAL or the !ile contains s)anned records, your )rogra# #ust !irst read the record to $e deleted. (he DELETE then re#oves the record that as read. "! the DELETE is not )receded $y a success!ul READ, the deletion is not done and the status 6ey value is set to J5. When you use ACCESS IS RANDOM or ACCESS IS DYNAMIC, your )rogra# does not have to !irst read the record to $e deleted. (o delete a record, #ove the 6ey o! the record to $e deleted to the RECORD KEY data ite#, and then issue the DELETE. /our )rogra# should chec6 the !ile status 6ey a!ter each DELETE state#ent.

11) :o

do you handle errors hen )rocessing VSAM !iles?


When an in)ut or out)ut state#ent o)eration !ails, C+4+- does not )er!or# corrective action !or you. All OPEN and CLOSE errors ith a VSAM !ile, hether logical errors in your )rogra# or in)ut*out)ut errors on the external storage #edia, return control to your C+4+- )rogra# even i! you coded no DECLARATI E and no FILE STATUS clause. "! any other in)ut or out)ut state#ent o)eration !ails, you choose ill continue running a!ter a less2than2severe error. C+4+- )rovides these out)ut errors. hether your )rogra#

ays !or you to interce)t and handle certain VSAM in)ut and

%nd2o!2!ile )hrase (AT END) E-CEPTION/ERROR declarative FILE STATUS clause (!ile status 6ey and VSAM status code) IN ALID KEY )hrase /ou should de!ine a status 6ey !or each VSAM !ile that you de!ine in your )rogra#. Chec6 the status 6ey value a!ter each in)ut or out)ut re0uest, es)ecially OPEN and CLOSE.

o o o o

"! you do not code a !ile status 6ey or a declarative, serious VSAM )rocessing errors ill cause a #essage to $e issued and a -anguage %nviron#ent condition to $e signaled, hich ill cause an a$end i! you s)eci!y the runti#e o)tion A$TERMENC(A$END).

15) What are the co##on C+4+- state#ents to )rocess VSAM !iles? 1se the C+4+- state#ents sho n $elo to )rocess VSAM !iles.

OPEN
(o connect the VSAM data set to your C+4+- )rogra# !or )rocessing.

WRITE
(o add records to a !ile or load a !ile.

START
(o esta$lish the current location in the cluster !or a

READ NE-T state#ent.

S(A3( does not retrieve a record> it only sets the current record )ointer.

REA% and REA% NE.T


(o retrieve records !ro# a !ile.

REWRITE
(o u)date records.

%E/ETE
(o logically re#ove records !ro# indexed and relative !iles only.

C/OSE
(o disconnect the VSAM data set !ro# your )rogra#. All o! the !ollo ing !actors deter#ine hich in)ut and out)ut state#ents you can use !or a given VSAM data set. o Access #ode (se0uential, rando#, or dyna#ic) o ;ile organi&ation (%SDS, 'SDS, or 33DS) o Mode o! +A%9 state#ent ("9A1(, +1(A1(, "2+, or %<(%9D) (he !ields that you code in the FILE STATUS clause are u)dated $y VSAM a!ter each in)ut2out)ut state#ent to indicate the success or !ailure o! the o)eration.

1?) What are the co##on VSAM status codes? DD D5 DC D8 1D 5D 55 5? ?8 C1 C5 JF 2 2 2 2 2 2 2 2 2 2 2 2 S1CC%SS;1- C+MA-%("+9 D1A-"CA(% '%/, 9+9 19"G. A-( "9D< 3%AD, W3+9B -%9B(: 3%C+3D +A%9, ;"-% 9+( A3%S%9( %9D +; ;"-% "9VA-"D '%/ VSAM 'SDS +3 33DS D1A-"CA(% '%/ 3%C+3D +3 ;"-% 9+( ;+19D +A%9, ;"-% 9+( A3%S%9( +A%9, ;"-% "S +A%9 C-+S%, ;"-% "S C-+S%D VSAM 2 +A%9 +', ;"-% "9(%B3"(/ V%3";"%D

1C) What is the !ile )osition indicator?

(he !ile )osition indicator #ar6s the next record to $e accessed !or se0uential C+4+re0uests. /ou do not set the !ile )osition indicator in your )rogra#. "t is set $y success!ul OPEN, START, READ, and READ NE-T state#ents. Su$se0uent READ or READ NE-T re0uests use the esta$lished !ile )osition indicator location and u)date it. (he !ile )osition indicator is not used or a!!ected $y the out)ut state#ents ,RITE, RE,RITE, or DELETE. (he !ile )osition indicator has no #eaning !or rando# )rocessing.

You might also like