You are on page 1of 19

IBM Mainframes

COBOL Training Class-12

DataSets

Dataset:

A named collection of data in an IBM mainframe operating system. A data set in an IBM mainframe is the equivalent of a file in other operating systems Direct Access Storage Disk (DASD or magnetic tape .

A dataset is typically stored on

!hese Dataset are of t"o types:


#DS (#artitioned Dataset #S (#hysical Sequential Dataset

Partitioned Data Set & Physical Sequential Dataset

PDS or Partitioned Data Set is a dataset containing multiple partition$s each of "hich may contain a members Members are %&B&' #rograms( )%' #rograms( 'oad Modules etc. !he #artitioned Data Set can only allocate on a single volume "ith the ma*imum si+e of ,--., tracks. PS or Physical Sequential Data Set is a dataset that contains records Records like employee details( customer details etc.(

DASD & Main-Memory

Direct Access Storage Disk ( DASD ) Mainframes /ard Disk "hich stores the physical data

DASD UNITS ( SYSDA & SYSA DA) !" U#$S DATA S$TS #$#%$RS&R$'"RDS

#ain(#e)ory :

Mainframes temporary space used 0y varia0les of an application program.

Steps to follow
*+ ,+ .+ 0+ 1+
Allocation: !he files used in the program should 0e declared1specified in 2I'34%&5!6&' paragraph "ith4in I5#7!4&7!#7! S3%!I&5 of 358I6&53M5! DI8ISI&5. De-inition. !he 6ecord layout of the file and its attri0utes are defined in the 2D #A6A96A#/ "ith4in 2I'3 S3%!I&5 of DA!A DI8ISI&5. "/en: Dataset is connected1readied to your program using &#35 statement. !he mode of &#35 decides the operation allo"ed and the initial pointer in the dataset. Process: #rocess the file as per requirement( using the I4& statements 12I'3 836BS provided 0y %&B&'. (63AD( :6I!3( 63:6I!3 and D3'3!3 'lose: After the processing( close the file to disconnect it from the program.

En ironment !i ision

Define the file in 2I'34%&5!6&' #aragraph of I5#7!4&7!#7! S3%!I&5 "ith in 358I6&5M35! DI8ISI&5. S$ $'T Statement is used to define a file.

358I6&5M35! DI8ISI&5. I5#7!4&7!#7! S3%!I&5. 2I'34%&5!6&'. S3'3%! "2I'A (3I $NA#$ ASSI95 !& DD5AM3 &69A5I;A!I&5 IS S3<735!IA' A%%3SS M&D3 IS S3<735!IA' 2I'3 S!A!7S IS :S4S!A!7S. &rgani+ation and Access mode is optional for a #S file( the default is sequential itself

"oints To #ote

Nu)4er o- S$ $'T statements specifies num0er of files used in a program. 'ogical file name is used through out the program e*ecution.

Must not e*ceed = characters. 'ike 3M#2I'3( %7S!2I'3( I542I'3 ( &7!2I'3 etc.

DD5AM3 Acts as a link 0et"een logical and physical file name "hich is used in the e*ecution )%'.

Must 5ot 3*ceed = %haracters. 'ike 3M#DD( %7S!DD( I54DD( &7!4DD 3!%.

Organi$ation an! A%%ess Mo!e



"rgani5ation : !he "ay in "hich records are arranged in the file. 6ays o- organi5ation 7

Sequential &ne record after other Inde8ed Based on a inde* key value ( 8SAM Relati9e Based on a relative record num0er ( 8SAM

Access )ode : !he "ay in "hich records can 0e accessed ( 63!I63D from a file. Access )ode are 7(

Sequential &ne after other record only till end of the file Rando) Access directly a record from the file Dyna)ic Both direct and sequential com0ined

&ile Stat's Co!e



It is a t:o(4yte "orking storage item. !he first 0yte denotes the general category "hereas second 0yte denotes the particular type of error message under that category. 0 Successful OPEN/READ/WRITE Operation

>> Successful completion


10 When AT END con ition fails ?> Sequential 63AD is attempted a-ter the end o- -ile is reached @>A B>

@?( @@( @.( @C A B>( B@( BD all these are related to 8SAM.
.> &pening 3rror 'ike.. .B mostly C> 'ogical 3rror in programs

DATA DI(ISIO#

2ile has to 0e descri0ed in 2D #aragraph of 2I'3 S3%!I&5 "ith in DA!A DI8ISI&5. 2ile section should 0e the first section if coded.

Synta*: DA!A DI8ISI&5. 2I'3 S3%!I&5. 2D '&9I%A'42I'35AM3 'AB3' 63%&6DS A63 S!A5DA6D1&MMI!3D. >? 63%&6D4'AE&7!. >- F.. 1 %&#E %&#EB&&G45AM3. Instead of record layout specifying here "e mostly use %&#EB&&G.

Open an! Close

Any file operated in an application program need to 0e opened first and later on closed after the task completion . Synta* :

&#35 &#35I594M&D3 2I'3?H(2I'3@I. %'&S3 2I'3?H(2I'3@I.

&ile Opening mo!es

:e have C type of opening modes. !hey are :



INPUT Mode :4 "ut/ut Mode :4 I(" Mode :4 $8tend Mode:4 %an perform only read %an perform only "rite %an perform read and re"rite %an append a ne" record to e*isting file

&ile Operation & &ile (er)s


!o perform any operation on file "e use one file ver0 "hich are listed 0elo"
3ile 9er4 &#35 %'&S3 63AD :6I!3 63:6I!3 Action %onnect to file 6elease the file 6etrieves a record Adds a ne" record 7pdate an e*isting record "/ening )ode 444 444 I5#7! &7!#7! I4&

D3'3!3

Delete$s a record

I4&

*EAD (er)

63AD ver0 reads a single record at a time. 6ecord fetch 0y read statement "ill 0e moved into the record layout( defined at 2D "ithin 2I'34 S3%!I&5. 2ile must 0e opened in I5#7! 1 I4& Mode Synta* ?. !o read only one record 63AD 3I $NA#$ HI5!& :S463%&6D4'AE&7!I( Synta* @. !o read till end of the file sequentially 63AD 3I $NA#$ A! 35D S!A!3M35! 5&! A! 35D S!A!3M35! 35D463AD.

+*ITE (er)

6RIT$ 836B is used to "rite a ne" record into the file. 2ile must 0e opened in "UTPUT Mode. !he data has to 0e moved into the record layout 0efore making a "rite statement. Synta* :

:6I!3 63%&6D4'AE&7!.
63%&6D 'AE&7! defined in 2I'34S3%!I&5 along "ith 2D

:6I!3 63%&6D4'AE&7! 26&M :S496&7#45AM3.


:S :&6GI594S!&6A93 S3%!I&5 data4area

*E+*ITE (er)

63:6I!3 836B updates a specific record "hich is already e*ists in the file. 2ile must 0e opened in I(" Mode. !he updated data has to 0e moved into the record layout 0efore making a re"rite statement. Synta* :

R$6RIT$ 63%&6D4'AE&7!.

DELETE (er)

Delete ver0 delete;s a record from the file. 6ecord present in #S 2I'3 cannot 4e deleted instead "e move space to remove a record from the file. Synta* :

D$ $T$ 2I'35AM3.

Deletes only one record not the file.

Sample "rograms

In Practical

T,an- .o'

You might also like