• Aucun résultat trouvé

Stream-Oriented Transmission

Dans le document It System/360 (Page 114-119)

i DeL MASTER FILE ENV(F(400~.40)); i

Chapter 10: Stream-Oriented Transmission

Stream-oriented transmission allows a PLII program to ignore block and record

boundaries and treat a data set as a continuous stream of data items in character form. For output, the data management subroutines of the PL/I library convert the data items from the program variables into character form if necessary, and build the stream of characters into records for transmission to the data set.

For input, the library subroutines ·take records from the data set and separate them into the data items requested by the

program, converting them into the appropriate form for assignment to ·the program variables. Because stream-oriented transmission always treats the data in a data set as a continuous stream, i t can be used only to process data sets with

CONSECUTIVE organization.

Record Format

Although in stream-oriented transmission a PL/I program sees a data set as a

continuous stream of data items, the data set actually comprises a series of discrete records in one of the three formats,

fixed-length, variable-length, and undefined-length. Fixed-length and

variable-length records can be blocked or unblocked; variable-length records,

however, cannot be spanned.

When you create a data set, you must specify the record format either in your PL/I program or in a DD statement. In the PL/I program, you can state the record format directly in the ENVIRONMENT attribute, or you can indicate it indirectly in the LINESIZE option of an OPEN statement; the ENVIR.ONMENT attribute and the LINESIZE option are described in IBM System/360 Operating system: PLII (F) Language Reference Manual. To specify the record format in a DD statement, use the DCB subparameters RECFM, BLKSIZE, and

LRECL; these subparameters are described in Appendix B.

FIXED-LENGTH RECORDS

In a data set with fixed-length records, each record, except possibly the last, contains the same number of characters.

Although the options and format items PAGE,

LINE, and SKIP, and the format item COLUMN can cause a new output record (line) to be started, the current record is not

truncated, but is padded to the specified length with blanks. The minimum length of a fixed-length record is 1 byte, except fo:r magnetic tapes of density 800 per inch or less, in which case records of this length are treated as noise,.

VARIABLE-LENGTH RECORDS

Variable-length output records are filled with characters up to the maximum length specified, unless they are truncated by tbe execution of one of the options or format items PAGE, LINE" SKIP, or COLUMN. If necessary, a variable-length record is padded with blanks to ensure that it

contains the minimum ten characters of data that are required by the operating system.

(With the eight bytes required for block and record control fields, this gives a minimum block size of 18 bytes.)

UNDEFINED-LENGTH RECORDS

Undefined-length records are processed in ia

similar manner to variable-length records, but, since the minimum length for these records is 1 byte, padding is never

required.. In the case of magnetic tapes o:f density 800 bytes per inch or less, i-byte records are treated as noise.

CHOICE OF RECORD FORMAT

For a data set that is intended to be

printed, you can usefully relate the record size to the length of the printed line (fo:r example. by using the LINESIZE option);

this is discussed under 'PRINT Files,' below. Similar considerations apply when you use the SKIP option or format item or the COLUMN format item with a non-PRINT file. For all other data sets that you create by stream-oriented transmission, program considerations do not affect the choice of record format (unless the data set will later be processed by

record-oriented transmission). You will not normally gain any advantage by blocking your records; for unblocked records,

specify a block size, but no record size. management routines for the transmission of a block of data to or from auxiliary

storage; such requests carry a substantial time overhead.)

E'or a direct-access device, the ideal block size is the capacity of one track:

th,is co:mbines maximum transmission

efficiency with optimum use of auxiliary storage space. A block can exceed the capacity of one track only if your

installation includes the track overflow feature; this allows the block to be continu1ed on the next track. Although track overflow can increase data-packing efficiency, i t reduces transmission speed.

'1'he use of small blocks wastes storage

In gEmeral, fixed-length records are transmi1:ted faster than variable-length or undefinE!d-length records. For maximum efficiency in sequential processing of a data s~; on a direct-access device, specify

'standard' format records (RECFM=FS or RECFM=FBS). If you use variable-length records" VBS-format allows you to specify block size independently of record size

(and thus to select the optimum block size).

Buffers

Stream-oriented transmission requires the use of at least one data-management buffer. an explanation of chained scheduiing" see Chapter 9 'Buffers'.)

You can request buffers either in your PL/I program (in the ENVIRONMENT attribute) or in a DD statement (BUFNO subparameter).

If you omit the information or specify zero buffers, the operating system will allocate two buffers.

DCB Subparameters

Figure 11-2 lists the DCB subparameters that are applicable to a data set processed by stream-oriented transmission; they are described in Appendix B. You can specify stream-oriented transmission must have CONSECUTIVE organization, but it is not negessary for you to specify this in the ENVIRONMENT attribute, since CONSECUTIVE is the default organization.

Your program deals only with data items, record-oriented transmission to access the data set at a later date.

To create a data set, you must give the operating system certain information either in the DD statement that defines the data set or in your PL/I program. The following paragraphs indicate the essential

information, and discuss some of the optional information you may supply.

Appendix B describes the parameters

referred to, and explains how to code them:

the ENVIRONMENT attribute and the LINESIZE option are discussed fully in IBM

System/360 Operating system: PL/I (F) Language Reference Manual.

Chapter 10: Stream-Oriented Transmission 115

ESSENTIAL INFORMATION

You must supply the following information:

1. Device that will write or punch your data set (UNIT, SYSOUT, or VOLUME parameter of DO statement).

2. Block size: you can give the block size in the DO statement (BLKSIZE subparameter of DCB parameter), or in your PL/I program (in the ENVIRONMENT attribute or the LINESIZE option).

Note: If you do not specify a record size, unblocked records are assumed and the record size is determined from the block size. If you do not specify a record format, U- :format is assumed

(except for PRINT files: see 'PRINT Files,' below).

If you want to keep a magnetic-tape or direct-access data set (that is, you do not want the operating system to delete it at the end of your job), the DO statement must, name the data set and indicate how i t is to be disposed of (DSNAME and DISP

parameters). The DISP parameter alone will suffice if you want to use the data set in

a later step but will not need it after thE~

end of your job.

If you are creating a data set on a direct-access device, you must specify the amount of space required for it (SPACE parameter of DD statement).

If you want your data set written on a particular magnetic-tape or direct-access volume, you must indicate the volume serial number in the DD statement (SER or REF subparameter of VOLUME parameter). If you do not supply a serial number for a

magnetic-tape data set that you want to keep, the operating system will allocate one and request the operator to print the number on your program listing.

If your data set is to follow another data set on a magnetic-tape volume, you must use the LABEL parameter of the DD statement to indicate its sequence number on the tape.

Figure 10-1 summarizes the essential parameters of the DO statements used for creating a data set with stream-oriented transmission.

r---T---'---'.

I 1 Parameters of DO Statem~t ,

I storage Device ~---,---T---...,.---·1

I , When required I What you must state , Parameters I

~---+---,---.---+---+---·1

I I I Output device I UNIT= or SYSOUT= or I

I All I A l w a y s ' I VOLUME=REF= ,

I I ~---+_---~

I I I Block size~ I DCB=BLKSIZE= I

~---+---+---_._--+---_., I Direct access only I Always I storage space I SPACE= I

I I I required I I

~---+---+---+---_.,

I Magnetic tape only I Data set nat first I Sequence number I LABEL= I

I I in volume and for I I I

1 I magnetic tapes t~hat I I ,

I I do not have I I I

I , standard labels , I I

~---+---,---+---+---_.,

Diz:'ect access and standard labeled magnetic tape

I Data set to be used I I I

I by another job step I Disposition I DISP= ,

I but is not required I I I

I after end o:f job J I I

~---,---+---,---+---i

, Data set to be kept I Disposition , DISP= , I after end o:f job ~---+---i

, I Name of dataset I DSNAME= ,

~---+---+_---i I Data set to be on I Volume serial number, VOLUME=SER= or ,

I particular 'volume I I VOLUME=REF= I

~---J.---J.---L---,f

'~Alternatively, you can specify the block size in your PL/I program by using either I

I the ENVIRONMENT attribute or the :LINESIZE option. ,

L ______________ ~---__ - -__ - - - -________________________ J

Figure 10-1. Creating a Data Set: :Essential Parameters of DO Statement

//J0301?GEX JOB

/ /COLE1~X EXEC PL1LFCLG, PARM. PL1L=' SIZE=99999 9' , PARM. LKED=' LIST' //PL1L .. SYSIN DD *

PEOPLE: PROC OPTIONSCMAIN):

DCL WORK FILE STREAM OUTPUT, 1 REC,

2 FREC,

3 NAME CHAR(20), 3 NUM CHAR(1), 3 PAD CHAR(24), 2 VREC CHAR(35), IN CHAR (SO) DEF REC;

ON ENDFILE(SYSIN) GO TO FINISH:

OPEN FILE(WORK) LINESIZE(400);

MORE: GET FILE(SYSIN) EDIT (IN) (A(80»:

PUT FILE(WORK) EDIT(IN)(A(45+7*mJM»;

GO TO MORE;

FINISH: CLOSE FILE(WORK);

END PEOPLE;

/*

//GO.WORK DD UNIT=2311,SPACE=(400,10),DISP=(NEW,KEEP),DSNAME=PEOPLE,

/ / VOLUME=SER=D186

//GO.SYSIN DD * R.C.ANDERSON B.F.BENNETT R. E.COI.E J.F.COOPER A.J.COHNELL E.F.FERRIS /*

0 2 5 5 3 4

202848 DOCTOR 771239 PLUMBER 698635 COOK 418915 LAWYER 237837 BARBER 158636 CARPENTER

VICTOR HAZEL

ELLEN VICTOR JOAN ANN OTTO FRANK CAROL DONALD NORMAN BRENDA ALBERT ERIC JANET

GERALD ANNA MARY HAROLD Figure 10-2. Using Stream-Oriented Transmission to Create a Data set

EXAMPLE records the data set contains; or you can

open the file for output, and extend the data set by adding records at the end.

Figure 10-2 illustrates the use of stream-'oriented transmission to create a data se~t on a 2311 disk drive. The data read from the input stream by the standard file SYSIN includes a field VREC that contain.s five unnamed 7-character

subfields; the field NUM defines the number of these subfields that contain

information. The output file WORK

transmi"ts to the data set the whole of the field FREC and only those subfields of VREC that contain information. The data set has U-forma"t unblocked records (by default) with a maximum block size of 400 bytes

(defined by the LINESIZE option in the statement that opens the file WORK). All blocks except the last will contain exactly 400 bytes.

Accessing a Data Set

A data set that you access using

stream-oriented transmission need not have been created by stream-oriented

transmission, but i t must have CONSECUTIVE organization, and all the data in i t must be in character form. You can open the associated file for input, and read the

To access an existing data set, you must identify i t to the operating system in a DD statement. The following paragraphs

indicate the essential information you must include in the DD statement, and discuss some of the other information you may supply: this discussion does not apply to data sets in the input stream, which are dealt with in Chapter 9 "Data Sets and PL/I Files". Appendix B describes the

parameters referred to, and tells you how to code them.

ESSENTIAL INFORMATION

If the data set is cataloged, you need supply only the following information in the DO statement:

1. The name of the data set (DSNAME

parameter). The operating system will locate the information that describes the data set in the system catalog, and, if necessary, will request the operator to mount the volume that contains i t .

Chapter 10: Stream-Oriented Transmission 117

r---.---,

I Parameters of DD statement I

~---T---T---~

I When required I What you must state I Parameters I

~---~---.+---.---+---~

I I Name of data set I DSNAME= I

I Always ~---+---~

I I Disposition of data set I DISP= I

~---T---·+---+---~

I 'All devices I Input device I UNIT= or VOLUME=REF= I

IIf data set not ~---+---+_---~

I cataloged 'Standard labeled' I ,

I Imagnetic tape andl Volume serial number 'VOLUME=SER= I

I Idirect access , , I

~---~---.+---+---~

,Magnetic tape: if data set not , sequence number I LABEL= I

I first in volume or which does not , , Ii

I have standard labels I , II

~---.-+---+---~I

I If data set does not have standard , Block size2.. I DCB=BLKSIZE= II

I labels , I ~

~---~---~---~

I2..Alternatively, you can specify the block size in your PL/I program by using either

II

I the ENVIRONMENT attribute or the J .. INESIZE option., II l _______________________________________________________________________________________ J,

Figure 10-3. Accessing a Data Set: Essential Parameters of DD statement 2. Confirmation that the data set already

exists CDISP parameter). If you are opening the data set for output with the intention of extending it by adding records at the end, code

DISP=MOD; otherwise, to open the data set for output will result in it being overwritten.

If the data set is no·t cataloged" you must, in additon, specify the devic~:! that will read the data set and, for

magnetic-tape and direct-access devices, give the serial number of the volume that contains the data set (UNIT and VOLUME parameters).

If the data set is on paper tape or punched cards, you must specify the block size either in the DD statement (BLKSIZE subparameter) or in your PL/I program

CENVIRONMEN'I' attribute).

If the data set follows another data set on a magnetic-tape volume, you must use the LABEL parameter of the DD statement to indicate its sequence number on the tape.

figure 10-3 summarizes the essential parameters of the DO statements for data sets accessed using stream-oriented transmission.

MAGNETIC TAPE WITHOUT STANDARD LABELS

If a magnetic-tape data set has nonstandard labels or is unlabeled, you must specify

the block size either in the DD statement (BLKSIZE subparameter) or in your PL/I program (ENVIRONMENT attribute). But the DSNAME parameter is not essential if the data set is not cataloged.

PL/I data management includes no facilities for processing nonstandard labels. To the operating system, such labels appear as data sets preceding or following your data set. You can either process the labels as independent data setB or use the LABEL parameter of the DD

statement to bypass them: to bypass the labels, code LABEL=(2,NL) or LABEL=(,BLP).

RECORD FORMAT

When you use stream-oriented transmission to read a data se't, you do not need to know the record format of the data set (except when you must specify a block size); each GET statement transfers a discrete number of characters to your program from the dati:t stream.

If you do give record-format

information, it must be compatible with the actual structure of the data set. For example, if a data set was created with F-format records, a record size of 600 bytes, and a block size of 3600 bytes, you can access the records as if they were U-format with a maximum block size of 3600 bytes; but if you specify a block size of 3500 bytes, your data will be truncated.

//J033PGEX JOB

/ /COLEE~X EXEC PL1LFCLG,PARM. PL1L=' SIZE=999999' ,PARM.LKED=" LIST' //PL1L.SYSIN DD *

PEOPLE:: PROC OPTIONS (MAIN);

DCL WORK FILE STREAM INPUT, 1 REC,

2 FREC,

3 NAME CHAR(20), 3 NUM CHAR(2), 3 SERNO CHAR (7) , 3 PROF CHAR(16), 2 VREC CHAR(35), IN CHAR(80) DEF REC;

ON ENDFILE(WORK) GO TO FINISH;

OPEN FILE(WORK):

MORE: GET FILE(WORK) EDITCIN,VREC)CA(45),A(7*NUM»;

PUT FILE(SYSPRINT) SKIP EDIT (REC) (A);

GO TO MORE;

FINISH: CLOSE FILE(WORK):

END PEOPLE;

/*

//GO.WORK DD DSNAME=PEOPLE,DISP=COLD,KEEP),UNIT=2311,VOLUME=SER=D186 Figure 10-4. Using Stream-Oriented Transmission to Access a Data Set EXAMPLE:

The program im Figure 10-4 reads the data set cre!ated in Figure 10-2 and uses the standard file SYSPRINT to list the data it

contai~~. CSYSPRINT is discussed later in this chapter.) Each set of data is read, by the GET statement, into two variables:

FREe, "'hich always contains 45 characters;

and VRE:C, which contains the number of charact.ers generated by the expression 7*NUM. Note that the DISP parameter of the DD stat,ement could read simply DISP=OLD; if the second term is omitted, an existing data se~t will not be deleted.

Dans le document It System/360 (Page 114-119)