• Aucun résultat trouvé

SECOND SORT EXAMPLE

Dans le document TEXAS INSTRUMENTS (Page 42-46)

Simple Sort and Merge Examples

3.4 SECOND SORT EXAMPLE

This example shows a sort with record selection. It sorts (tag-along sort) aO-character records from the input file DS01.INFILE and places the output in DS03.0UTFIX. Assume that DS03.0UTFIX has been previously created; it is not necessary to specify logical or physical record length. Also, only records with a value greater than 100 in columns 5 through 10 are to be included in the sort. These records will be selected and will appear in the output file. The primary control field (columns 5 through 10) specifies ascending order. A second control field (columns 12 through 15) is specified with descending order. The total length of the combined control fields is 10.

This sort demonstrates the optimal positioning of the output file, work file, and input file for max-imum sort speed. The input and output files can be on the same disk volume, but the work file should be on a different volume.

The batch control stream statements are as follows:

1. BATCH

2. SM$SMC CFN = DS01.CONTRlA

3. SM$H D TCl = 10,PO = O,ORl = aO,MS = 16000 4. SM$OUT FP = DS03.0UTFIX

5. SM$WKF WFV = DS02 6. SM$I N FP = DS01.1 NFl lE

7. SM$SlC CP = C,01 B = 5,01 E = 10,REl = GT,FOC = C,02C = 000100 a. SM$REF FT = N,Bl = 5,El = 10

9. SM$REF FT=O,Bl= 12,El= 15 10. SM$REF FT = D,Bl= 1,El= ao 11. SM$ClS

12. XBSM CFN = DS01.CONTRlA,lDN = DS01.LlST 13. EBATCH

3.4.1 SM$SMC Statement

SM$SMC CFN = DS01.CONTRlA

The second line specifies that the Sort/Merge control file be created and placed in a file named DS01.CONTRlA.

3.4.2 SM$HD Statement

SM$HD TCl = 10,PO = O,ORl = aO,MS = 16000

The third line specifies by default a full sort in ascending order.

This line uses the following keywords:

• TCl (Total Control length) - Specifies the total length, in characters, of all control fields. In this example, an ascending field is in columns 5 through 10 and a descending field is in columns 12 through 15. This gives a total length of 10 characters. (This parameter has no default.)

• PO (Print Option) - Specifies that the generated control statements be listed along with information, error, and warning messages.

• ORl (Output Record length) - Specifies the total length, in characters, of the output record. Since aO-character records are being sorted, the length of the output records is ao characters. (This parameter has no default.)

• MS (Memory Size) - Specifies the work memory available for the sort, in bytes. A size of 16,000 bytes is only a suggested size to allow the sort to run faster than when the default value (2,aOO bytes) is used. If 32,000 bytes are available, you should specify that amount.

3.4.3 SM$OUT Statement

SM$OUT FP = DS03.0UTFIX

The fourth line specifies the output file path name. No file attributes are specified since, in this ex·

ample, the file has been previously created on DS03. If not previously created, a sequential file will be created by Sort/Merge with BO-character records unblocked.

This line uses the following keyword:

• FP (File Pathname) - Specifies the path name of the file (or device) that is to contain the output listing. The maximum is 36 characters.

3.4.4 SM$WKF Statement SM$WKF WFV = DS02

The fifth line specifies that the work file be allocated on disk DS02. The work file is allocated as a temporary file. For maximum efficiency, always allocate the work file on a volume that contains neither the input nor the output file.

This line uses the following keyword:

• WFV (Work File Volume) - Defines the device or volume to which the work file is to be allocated.

3.4.5 SM$IN Statement

SM$IN FP= DS01.INFILE

The sixth line defines the pathname for the input file (or device). Since the attributes assigned to the file when created are available to Sort/Merge, no attributes are specified.

This line uses the following keyword:

• FP (File Pathname) - Specifies the pathname of the file (or device) that contains the in-put file. The maximum is 36 characters.

3.4.6 SM$SLC Statement

SM$SLC CP = C,01 B = 5,01 E = 10,REL= GT,FOC = C,02C = 000100

The seventh line specifies selection of certain records to be included in the sort. Records that meet the criteria are sorted and appear in the output file. All records that do not meet the criteria are omitted. Omitted records are not sorted and do not appear in the output file. In this example, all records with a value greater than 100 in columns 5 through 10 are included.

This line uses the following keywords:

• CP (Character Portion) - Specifies an ASCII character comparison.

• 01 B (Operand 1 Beginning) - Specifies the high-order, leftmost column of the com-parison field. In this example, columns 5 through 10 have an 01 B of 5.

• 01 E (Operand 1 Ending) - Specifies the low-order, rightmost column of the comparison field. In this example, columns 5 through 10 have an 01 E of 10.

• IREL (Relationship) - Specifies the type of comparison, as follows:

G T - Greater than L T - Less than E Q - Equal N E - Not equal

L E - Less than or equal G E - Greater than or equal

• FOC (Field or Constant) - Specifies if the comparison is to another field within the record or to a constant. The C specifies constant. (See Section 6 for additional informa-tion.)

• 02C (Operand 2 Constant) - Specifies the constant to be used in the comparison.

Since a number must be specified for each position within the field, leading zeros are re-quired. In this example, the constant 000100 is to b~ compared with the value in columns 5 through 10.

3.4.7 SMSREF Statements

The following paragraphs explain the reformatting specifications in this example.

3.4.7.1 Control Field Specification.

SM$REF FT = N,BL = 5,EL = 10 SM$REF FT=O,BL= 12,EL= 15

The eighth and ninth lines specify the control fields. Since columns 5 through 10 are specified first, they constitute the primary control field; columns 12 through 15 are the secondary field.

This line uses the following keywords:

• FT (Field Type) - An N specifies normal control field or ascending sequence in this ex-ample. An 0 specifies opposite control field or descending sequence.

• BL (Beginning Location) - Specifies the beginning column position of the control field in the input file.

• EL (Ending Location) - Specifies the ending column position of the control field in the input file.

3.4.7.2 Data Field Specification.

SM$REF FT= D,BL= 1,EL= 80 The tenth line specifies the data field.

946252·9701

This line uses the following keywords:

• FT (Field Type) - The 0 specifies that this is the data field to be written to the output file for each sorted record. Since the order of the fields within the record remains the same as in the input file, the entire data field (columns 1 through 80) is specified.

• BL (Beginning Location) - Specifies the beginning column position of the data field in the input file.

• EL (Ending Location) - Specifies the ending column position of the data field in the in-put file.

3.4.8 SM$CLS Statement SM$CLS

The eleventh line terminates generation of the control statement file.

3.4.9 XBSM Statement

XBSM CFN = DS01.CONTRLA,LDN = DS01.LlST

The XBSM statement executes the Sort/Merge program using the control statement file that the previous statements built.

This line uses the following keywords:

• CFN (Control File Name) - Assigns the pathname DS01.CONTROLA to the control file created by this batch stream.

• LON (Listing Device Name) - Specifies the path name of the device or file to which Sort/Merge is to list the information, error, and warning messages produced during the sort process. In this example, the file name is DS01.LlST. If this file already exists, Sort/Merge replaces the contents of the current file with the messages listing. If the file does not exist, Sort/Merge creates a sequential file to contain the messages listing.

Delete this file after checking it for errors.

Dans le document TEXAS INSTRUMENTS (Page 42-46)