Simple Sort and Merge Examples
3.5 MERGE EXAMPLE
The following control statements specify that three input files are to be merged into one output file in descending order, using a control field contained in columns 5 through 10 of the input files.
All three input files have been previously sorted in descending order, using the same control field.
1. BATCH
2. SM$SMC CFN = DS01.CONTRLM
3. SM$HD SMT = MERGE,SMS = D,TCL = 10,ORL = 80,MS = 16000 4. SM$OUT FP= DS01.MRGOUT
5. SM$IN FP = DS01.MRG1 6. SM$IN FP = DS01.MRG2
7. SM$IN FP= DS01.MRG3 a. SM$REF FT = N,BL = 5,EL = 10 9. SM$REF FT= D,BL= 1,EL= ao 10. SM$CLS
11. XBSM CFN = DS01.CONTRLM,LDN = LP01 12. EBATCH
3.5.1 SM$SMC Statement
SM$SMC CFN = DS01.CONTRLM
The second line specifies that the Sort/Merge control statement file be placed in a file with the pathname DS01.CONTRLM. Sort/Merge creates a sequential file with this pathname if the file does not already exist. If the file does exist, Sort/Merge replaces the existing contents of the file with the newly created control statement file.
3.5.2 SM$HD Statement
SM$HD SMT= MERGE,SMS= D,TCL=6,ORL=aO,MS= 16000 The third line specifies a merge operation in descending order.
This line uses the following keywords:
• SMT (Sort/Merge Type) - Specifies that a merge process is to be performed.
• SMS (Sort/Merge Sequence) - The
0
specifies that the normal ordering sequence is to be descending. (An A would specify ascending.)• TCL (Total Control Length) - Specifies the total length, in characters, of all control fields. In this example, only one control field, columns 5 through 10, is used. This field has a length of 6 characters. (This parameter has no default.)
• ORL (Output Record Length) - Specifies the total length, in characters, of the output record. Si nce aO·character records are bei ng merged, the length of the output records is ao characters. (This parameter has no default.)
• MS (Memory Size) - Specifies the work memory available for the merge, in bytes. A size of 16,000 bytes is only a suggested size to allow the merge 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.5.3 SM$OUT Statement
SM$OUT FP = DS01.MRGOUT
The fourth line is the pathname of the file (or device) that is to contain the merged output created by Sort/Merge. If the file does not exist, Sort/Merge creates a sequential file with this pathname.
946252-9701
This line uses the following keyword:
• FP (File Pathname) - Specifies the pathname of the file (or the name of the device) that is to contain the output listing. The maximum is 36 characters.
Note that no work file is specified in this command stream since a merge operation does not use a work file.
3.5.4 SM$IN Statement
SM~IN FP= DS01.MRG1 SM$IN FP= DS01.MRG2 SM$IN FP= DS01.MRG3
The fifth through seventh lines specify the pathnames of the three input files. The files must be in the same sequence and must use the same control field. Any out-of-sequence condition may ter-minate the merge process or cause unpredictable results.
These lines use the following keyword:
• FP (File Pathname) - Specifies the pathname of the file (or the name of the device) that contains the input file. The maximum is 36 characters.
3.5.5 SM$REF Statements
The following paragraphs explain the reformatting specification statements.
3.5.5.1 Control Field Specification.
SM$REF FT = N,Bl = 5,El = 10
The eighth line specifies the order and location of the control field.
This line uses the following keywords:
• FT (Field Type) - Specifies that this is a control field ordered in normal (N) order. Since the header specification designated the sequence as descending, normal means descending.
• Bl (Beginning location) - Specifies that column 5 in the input files is the beginning location of the control field.
• El (Ending location) - Specifies that column 10 in the input files is the ending location of the control field.
3.5.5.2 Data Field Specification.
SM$REF FT= D,Bl= 1,El=80
The ninth line specifies that this is a data field.
This line uses the following keywords:
• FT (Field Type) - The 0 specifies that this is a data field.
• BL (Beginning Location) - Specifies column 1 in the input files as the beginning column of the data field.
• EL (Ending Location) - Specifies column 80 in the input files as the ending column of the data field.
3.5.6 SM$CLS Statement SM$CLS
The tenth line terminates generation of the control statement file.
3.5.7 XBSM Statement
XBSM CFN
=
DS01.CONTRLM,LDN=
LP01The elev1enth line executes the Sort/Merge program by using the control statement file that the previous statements built.
This line uses the following keywords:
• CFN (Control File Name) - The name of the file (or device) that is to contain the control file built by the previous command statements.
• LON (Listing Device Name) - The pathname of the file (or device) to which Sort/Merge information, error, and warning messages are to be written. The line printer (LP01) is used as an example.
3.5.8 Executing Sort/Merge in Batch Mode
When you have prepared the batch control stream file by copying the format of the examples in this section, use the Execute Batch (XB) command to execute the batch control statements that will code the control file which will run the Sort/Merge utility. Both the input file (or files) and the batch control stream file must have been previously prepared before you execute this command.
The XB command has the following field prompts:
EXECUTE BATCH
INPUT ACCESS NAME: <path name>
LISTING ACCESS NAME: <pathname>
In response to the INPUT ACCESS NAME prompt, enter the pathname you assigned to the file (or device) that contains the batch control stream. This is not the pathname used in the batch control stream to specify the control file path name (SM$SMC).
In response to the LISTING ACCESS NAME prompt, enter the pathname of a file (or device) to which the listing made by the SCI during the batch processing may be written. This is not the same as the listing of Sort/Merge messages specified for the XBSM command statement in your batch control stream.
To reuse the control file built with the batch control stream, execute Sort/Merge in batch by using the Execute Batch Sort/Merge (XBSM) command.
The XBSM command has the following field prompts:
EXECUTE BATCH SORT/MERGE <VERSION X.X.X>
CONTROL FILE NAME: <pathname>
LISTING DEVICE NAME: <path name>
In response to the CONTROL FILE NAME prompt, enter the path name of the control file, that is, the pathname specified for SM$SMC.
In response to the LISTING DEVICE NAME prompt, enter the path name of a file (or device) to which the listing made by the SCI during the batch processing may be written. This is not the . same as the listing of Sort/Merge messages specified for the XBSM command statement in your
batch control stream.
You can also specify the XBSM command when in the SCI command mode by entering the following:
XBSM CFN = <pathname>,LDN = <path name>
The file name following CFN is the pathname you specified in the batch stream as the control file name.