This section explains the examples of using the bsortex command via the main options.
Example 1 : Sort processing
It sorts records of the binary fixed length file bsortin of which the record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of 10 bytes ASCII code in 10 bytes from the head of the record in ascending order.
bsortex -sort key=0.10asca -input reclen=100 file=bsortin -output file=bsortout -sort : Sort function key=0.10asca : Key field -input reclen=100 : Record length file=bsortin : Input file name -output file=bsortout : Output file name
Example 2 : Merge processing
It merges records of the binary fixed length file bsortin1 and bsortin2 of which the record length is 100 bytes and outputs them to the file bsortout. File bsortin1 and bsortin2 are files that sorted the field of ASCII code in 10 bytes from the head of the record in ascending order respectively.
bsortex -merge key=0.10asca -input reclen=100 file=bsortin1,bsortin2 -output file=bsortout -merge : Merge function key=0.10asca : Key field -input reclen=100 : Record length file=bsortin1,bsortin2 : Input file name -output file=bsortout : Output file name
Example 3 : Copy processing
It copies records of the binary fixed length file bsortin of which the record length is 100 bytes to the sequential file bsortout of NetCOBOL.
bsortex -copy -record recform=fix -input reclen=100 file=bsortin filesys=dos -output file=bsortout filesys=cobs64 -copy : Copy function -record recform=fix : Record format -input reclen=100 : Record length file=bsortin : Input file name filesys=dos : Input file system -output file=bsortout : Output file name filesys=cobs64 : Output file system
Example 4 : Using the record selection option
It merges records of the binary fixed length file bsortin1 and bsortin2 of which the record length is 100 bytes and outputs them to the sequential file bsortout of NetCOBOL. The input file is to be sorted in the field of the fixed-point binary number that is in 4 bytes from the 21st byte in ascending order. In addition, when merging the records, the records with the value of the fixed-point binary number that is in 4 bytes from 31st byte is more than 30 and less than 40 are to be merged.
bsortex -merge key=20.4fbia -record recform=fix -input reclen=100 file=bsortin1,bsortin2 filesys=dos include=30.4fbi.ge.d30.and.30.4fbi.lt.d40 -output file=bsortout filesys=cobs64 -merge : Merge function key=20.4fbia : Key field -record recform=fix : Record format -input reclen=100 : Record length file=bsortin1,bsortin2 : Input file name filesys=dos : Input file system include=30.4fbi.ge.d30.and.30.4fbi.lt.d40 : Selection field -output file=bsortout : Output file name filesys=cobs64 : Output file system
Example 5 : Using the record reconstruction option
It sorts records of the binary file bsortin of which the record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of ASCII code in 20 bytes from the 11th bytes of the record in descending order. In addition, the records are reconstructed at the same time of the sort processing. Reconstruction is to be specified to put 20 bytes from the 11th bytes of the input record in the left end of the input record and to put a field of 10 bytes in the form of external decimal number on the right of that and set 0 for that value.
bsortex -sort key=0.20ascr -input reclen=100 file=bsortin reconst=9.20,d0.10zdl -output file=bsortout -sort : Sort function key=0.20ascr : Key field -input reclen=100 : Record length file=bsortin : Input file name reconst=10.20,d0.10zdl : Reconstruction field -output file=bsortout : Output file name
Point
In specifying the command to execute sort processing and reconstruction at the same time, the value after the reconstruction is specified for the position of key field.
Example 6 : Using the record summation option
It sorts records of the binary file bsortin of which the record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of ASCII code in 20 bytes from the 11th bytes of the record in descending order. In sorting, if the same record appears in the key field, the field of the packed decimal number in 8 bytes from the 51st byte is added to it and the records are to be summated. And the first input record out of the records in the same key record is output.
bsortex -sort key=10.20ascr -input reclen=100 file=bsortin -summary field=50.8pdl first -output file=bsortout -sort : Sort function key=10.20ascr : Key field -input reclen=100 : Record length file=bsortin : Input file name -summary field=50.8pdl : Summation field first : Output the first input record -output file=bsortout : Output file name
Example 7 : Using the suppression option
It sorts records of the binary file bsortin of which the record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of ASCII code in 20 bytes from the 11th bytes of the record in descending order. In sorting, if the same record appears in the key field, the record input last is kept and others are deleted.
bsortex -sort key=10.20ascr -input reclen=100 file=bsortin -summary suppress last -output file=bsortout -sort : Sort function key=10.20ascr : Key field -input reclen=100 : Record length file=bsortin : Input file name -summary suppress : Suppression option last : Output the last input record -output file=bsortout : Output file name
Example 8 : Using the FIFO option
It sorts records of the binary file bsortin of which the record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of ASCII code in 20 bytes from the 11th bytes of the record in descending order. In sorting, if the same record appears in the key field, the records are output in the order of storing in the input file.
bsortex -sort key=10.20ascr -input reclen=100 file=bsortin -output file=bsortout -option fifo -sort : Sort function key=10.20ascr : Key field -input reclen=100 : Record length file=bsortin : Input file name -output file=bsortout : Output file name -option fifo : FIFO option
Example 9 : Sorting the text files (specifying fixed fields)
It sorts records of the text file bsortin of which the maximum record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of ASCII code in 4 bytes from the 9th bytes of the record in ascending order.
bsortex -sort key=8.4asca -record recform=txtfix -input reclen=100 file=bsortin -output file=bsortout -sort : Sort function key=8.4asca : Key field -record recform=txtfix : Record format (text file fixed field specification) -input reclen=100 : Maximum record length file=bsortin : Input file name -output file=bsortout : Output file name
Example 10 : Sorting the text files (specifying floating fields)
It sorts records of the text file bsortin of which the maximum record length is 100 bytes and outputs them to the file bsortout. The key field is to be specified to sort the field of the ASCII code in 4 bytes from the head of the 2nd field delimited by record separator colon (:) in ascending order.
bsortex -sort key=1.4asca -record recform=txtflt fldsep=: -input reclen=100 file=bsortin -output file=bsortout -sort : Sort function key=1.4asca : Key field -record recform=txtflt : Record format (text file floating field specification) fldsep=: : Field separation character -input reclen=100 : Maximum record length file=bsortin : Input file name -output file=bsortout : Output file name
Example 11 : Using the output file switching option
It sorts records of the binary file bsortin of which the record length is 100 bytes and outputs them to the file bsortout1 and file bsortout2. When outputting them, the file size is no more than 1 GB. The key field is to be specified to sort the field of ASCII code in 10 bytes from the head of the record in ascending order.
bsortex -sort key=0.10asca -input reclen=100 file=bsortin -output file=bsortout1,bsortout2 maxfilesize=1G -sort : Sort function key=0.10asca : Key field -input reclen=100 : Record length file=bsortin : Input file name -output file=bsortout1,bsortout2 : Output file name maxfilesize=1G : Maximum output file size
Example 12 : Using the conditional file output option (No.1)
It sorts records of the file bsortin of which the record length is 100 bytes and outputs them to the file bsortout1 and file bsortout2. When outputting the records, the records in which the field of a packed decimal number in 4 bytes from 31st byte is more than 100 are output to bsortout1, and the records in which the field of an external decimal number in 8 bytes from 51st byte is less than 50 is output to bsortout2. The key field is to be specified to sort the field of the ASCII code in 10 bytes from the head of the record in ascending order.
bsortex -sort key=0.10asca -input reclen=100 file=bsortin -output file=bsortout1 include=30.4pdl.ge.d100 -output file=bsortout2 include=50.8zdl.lt.d50 -sort : Sort function key=0.10asca : Key field -input reclen=100 : Record length file=bsortin : Input file name -output file=bsortout1 : Output file name include=30.4pdl.ge.d100 : Selection field -output file=bsortout2 : Output file name include=50.8zdl.lt.d50 : Selection field
Point
In the include operand, the record where the selection condition of each -output option is approved is output to each output file. Therefore, Record3 is output to both bsortout1 and bsortout2 in this example.
Example 13 : Using the conditional file output option (No.2)
It sorts records of the file bsortin of which the record length is 100 bytes and outputs them to the file bsortout1 and bsortout2 and bsortout3. When outputting the records, the records in which the field of a packed decimal number in 4 bytes from 31st byte is more than 100 are output to bsortout1, and among the records that were not output to bsortout1, the records in which the field of an external decimal number in 8 bytes from 51st byte is less than 50 are output to bsortout2, and the rest of the records that were not output to either bsortout1 nor bsortout2 are to be output to bsortout3. The key field is to be specified to sort the field of the ASCII code in 10 bytes from the head of the record in ascending order.
bsortex -sort key=0.10asca -input reclen=100 file=bsortin -output file=bsortout1 case=30.4pdl.ge.d100 -output file=bsortout2 case=50.8zdl.lt.d50 -output file=bsortout3 case=other -sort : Sort function key=0.10asca : Key field -input reclen=100 : Record length file=bsortin : Input file name -output file=bsortout1 : Output file name case=30.4pdl.ge.d100 : Selection field -output file=bsortout2 : Output file name case=50.8zdl.lt.d50 : Selection field -output file=bsortout3 : Output file name case=other : Selection field (Other record)
Point
In the case operand, the record where the selection condition of the -output option is approved is output to the output file. The record that has already been output is not output in the following -output options. Therefore, Record3 is output only to bsortout1 in this example.
Example 14 : Sorting the Btrieve files
It sorts records of the fixed length file bsortin in the Btrieve file system of which the record length is 100 bytes and outputs them to the sequential file bsortout of NetCOBOL. The key field is to be specified to sort the field of the ASCII code in 20 bytes from the head of the record in ascending order.
bsortex -sort key=0.20asca -record recform=fix -input reclen=100 file=bsortin filesys=btrv -output file=bsortout filesys=cobs64 -sort : Sort function key=0.20asca : Key field -record recform=fix : Record format -input reclen=100 : Record length file=bsortin : Input file name filesys=btrv : Input file system -output file=bsortout : Output file name filesys=cobs64 : Output file system
Example 17 : Sorting the files of the Micro Focus COBOL file system
It sorts records of the index file bsortin in Micro Focus COBOL file system of which the record length is 100 bytes and outputs them to the sequential file bsortout of Micro Focus COBOL file system. The key field is to be specified to sort the field of the ASCII code in 10 bytes from the head of the record and 4 bytes from the 51st bytes of the record in ascending order.
bsortex -sort key=0.10asca,50.4asca -record recform=fix -input reclen=100 file=bsortin filesys=mfcidx -output file=bsortout filesys=mfcseq -sort : Sort function key=0.10asca,50.4asca : Key field -record recform=fix : Record format -input reclen=100 : Record length file=bsortin : Input file name filesys=mfcidx : Input file system -output file=bsortout : Output file name filesys=mfcseq : Output file system