• Aucun résultat trouvé

How to Access a Data Set

Dans le document OS PL/I (Page 23-26)

To access (that is, read or update) an existing data set, your DD statement should include information similar to that given when the data set is created. However, for data sets on labeled magnetic tape or on direct-access devices, you can omit several parameters because the information they contain is recorded with the data set by the operating system when the data set is created; Figure 3-3 summarizes the

essential information and Figure 3-5 is an example of accessing this type of data set.

The subparameters of the DCB pararreter are described in Appendix A, and the job

control language reference publication explains how to code a DD statement.

Except in the special case of data in the input stream (descrited under "s~ecial­

purpose parameters," later in this

chapter), you rrust always include the name of the data set (DSNAME) and ,its

disposition (DISP).

TYPE OF INPUT DEVICE (UNIT=)

You can omit the UNIT ~ararreter if the data set is cataloged or if i t is created with DISP=(NEW,PASS) in a previous job step of the same jot. Otherwise, i t must always appear. (PASS specifies that the data set .' is to be passed for use by a subsequent job step in the sarre job).

VOLUME SERIAL NUMBER (VOLUME=SER=)

You can omit the VOLUME parameter if the data set is cataloged or if i t is created with DISP=(,FASS) in a previous job step of the same job. Otherwise i t must always appear.

NAME OF DATA SET (DSNAME=)

The DSNAME parameter can either refer back to the DD statement that defined the data

set in a previous job step, e~ i t can give the actual name of the data set. (Yeu would have to uS,e the former method to refer to an unnan:ed terrpcrary data set.)

,RECORD TYPE (DCE=)

You can omit the DCE paranetet i f the record information is specified in your PL/I program, using the ENVIRONMENT

attribute, or if you are accessing a data set on a direct-access device or standard labeled magnetic tape. otherwise yeu must specify the DCB parameter for punched cards, paper tape, or unlabeled magnetic tape.

AUXILIARY STORAGE RECUIRED (SPACE=)

You cannot add to, or otherwise rrodify, the space allocation made for a data set when i t is created. Accordingly, the SPACE parameter is never required in a DD statement for an existing data set.

10 OS PL/I Optimi zing Compi ler: Programmer' s Guide

r---,

1

Pararreters of DD Staterrent

1---~---1

When required

1

What you must state

1

Parameters

1---1 INarre of data set 1 DSN=

IAlways

1---1 IDispositicn of data set 1 DISP=

1---1 1

All devices

1

Input device

1

UNIT=

IIf data. set not

1---I cataloged IMagnetic tape andlVclurre serial nurrber I VOL=SER=

1 1

direct access

1 1

1---IFor punched cards, paper tape, or I Blcck size1 I DCB=(BLKSIZE= ••• )

lunlabeled magnetic tape 1 I

1---11Alternatively, you can specify the block size in your PL/I program by using the IENVIRONMENT attribute.

L---~

_____________________________________________ ---______________________

J

Figure 3-3. Accessing a CCNSECUTIVE data set: essential pararreters cf DD staterrent DISPOSITION OF DATA SET (DISP=)

Except for unit record devices (such as card readers), you must always include the DISP parameter to indicate to the operating system that the data set exists. Code DISP=SHR if you want to read the data set, DISP=OLD if you want to read and/er

overwrite it, or DISP=MOD if you want to add records to the end of it.

Specia I-purpose Parameters

Three parameters of the DD staterrent have special significance because you can use a very Simple form of DD statement; they are:

SYSOUT=

*

DATA

SYSOUT= is particularly useful for printed or punched-card output, and

*

and DA!A allow you to include data in the input stream.

system Output (SYSOUT=)

A system output device is any unit (but usually a printer or a card punch) that is used in common by all jobs. The computer operator allocates all the system output devices to specific classes according to

the type of device. !he usual convention is for class A to refer to a printer and class B to a card punCh; the IBM-supplied catalcged procedures assurre that this convention is followed.

Te rcute your output through a system output device, use the SYSOU! pararreter in your DD statement. For example, to punch cards, use the DD staterrent:

I/GO.PUNCH DD SYSOU!=B

Data in the Input Strearr (* and DATA) A convenient way to introduce data to your program is to include i t in the input strearr with your job control statements.

Data in the input strearr rrust, like job contrel statements, be in the form of 80-byte records (usually punched cards), and must be immediately preceded by a DD statement with the single pararreter

*

in its operand field. For example:

IIGO.SYSIN DD

*

To indicate the end of the data, you may optionally include a delirriter jeb ccntrol statement (/*). If you omit the /*

delimiter, the end of the data is deterrrined by the next jcb ccntrel

staterrent (commencing II in the first two columns) in the input strearr.

If your data includes reccrds that start with II in the first two columns use the parameter DATA. For exarrple:

/ /OPT3#4 JOB

//STEP1 EXEC PLIXCLG //PLI.SYSIN DD *

CREATE: PROC OPTIONSCMAIN):

DCL PUNCH FILE STREAM OUTPU'r,

DISK FILE RECORD OUTPUT SEQUENTIAL, 1 RECORD,

2CA,B,C,X1,X2) FLOAT DEC(6) COMPLEX:

ON ENDFlLE CSYSIN) GO TO FINISH:

OPEN FILE CPUNCH), FILE (DISK):

NEX'I': GET FILE (SYSIN) LISTCA, B,C) ; X1=(-B+SQRT(B**2-4*A*C»/(2*A);

X2=(-B-SQRT(B**2-4*A*C»/(2*A);

PUT FILE (PUNCH) EDIT (RECORD) (C (E (16,9») ; WRITE FILE(DISK) FROM(RECORD):

GO TO NEXT;

FINISH: CLOSE FILE (PUNCH), FILE (DISK) : END CREATE:

/*

//GO.PUNCH DD SYSOUT=B

//GO.DISK DD DSN=ROOTS,UNIT=2311,VOL=SER=D186,DISP=CNEW,REEP), / / SPACE=CTRK,C1,1»,DCB=CRECFM=FB,BLKSIZE=400,LRECL=40) //GO.SYSIN DO *

5 12 4 4 -10 4 5 16 2 4 -12 10 5 12 9 29 -20 4

/*

Figure 3-4. Creating a CONSECUTIVE data set

/ /OPT3#5 JOB

//STEP1 EXEC PLIXCLG //PLI.SYSIN DD *

ACCESS: PROC OPTIONS(MAIN)i

DCL RESULTS FILE RECORD INPUT SEQUENTIAL, 1 RECORD,

2CA,B,C,X1,X2) FLOAT DEC(6) COMPLEX;

ON ENDFILECRESULTS) GO TO FINISH:

PUT FILECSYSPRINT) EDITC'A' ,'B','C','Xl','X2') CX(7),3(A,X(23»,A,X(22),A);

OPEN FILE CRESUL'I'S) ;

NEXT: READ FI LE (RESULTS) I NrO (RECORD);

PUT FILECSYSPRINT) SKIP EDIT(RECORD) (CCF(12,2»);

GO TO NEXT;

FINISH: CLOSE FILE(RESULTS);

END ACCESS;

/*

//GO.RESULTS DD DSN=ROOTS,UNIT=2311,VOL=SER=D186,DISP=(OLD,KEEP) Figure 3-5. Accessing a CONSECUTIVE data set

12 OS PL/I Optimizing compiler: Programmer's Guide

//GO.SYSIN DD DATA

In this case, you must always indicate the end of the data by the job control delimiter statement (/*).

Dans le document OS PL/I (Page 23-26)