Top
PowerBSORT V7.0 User's Guide
FUJITSU Software

A.1 Examples of using bsort command

This section explains the examples of using the bsort 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.

bsort -s -z100 -0.10asca -o bsortout bsortin

  -s          : Sort function
  -z100       : Record length
  -0.10asca   : Key field
  -o bsortout : Output file name
  bsortin     : Input 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.

bsort -m -z100 -0.10asca -o bsortout bsortin1 bsortin2

  -m          : Merge function
  -z100       : Record length
  -0.10asca   : Key field
  -o bsortout : Output file name
  bsortin1    : Input file name
  bsortin2    : Input 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.

bsort -c -z100 -Zf -Fcobs64,dos -o bsortout bsortin

  -c           : Copy function
  -z100        : Record length
  -Zf          : Record format
  -Fcobs64,dos : Input/Output file system
  -o bsortout  : Output file name
  bsortin      : Input file name

Example 4 : Using the record selection option

It merges records of the binary fixed length file bsortin1 of which the record length is 100 bytes and the records of the sequential file bsortin2 of NetCOBOL 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.

bsort -m -z100 -Zf -20.4fbia -p30.4fbi.ge.d30,30.4fbi.lt.d40 -Fcobs64,dos,cobs64 -o bsortout bsortin1 bsortin2

  -m                              : Merge function
  -z100                           : Record length
  -Zf                             : Record format
  -20.4fbia                       : Key field
  -p30.4fbi.ge.d30,30.4fbi.lt.d40 : Selection field
  -Fcobs64,dos,cobs64             : Input/Output file system
  -o bsortout                     : Output file name
  bsortin1                        : Input file name
  bsortin2                        : Input file name

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.

bsort -s -z100 -0.20ascr -e10.20,d0.10zdl -o bsortout bsortin

  -s               : Sort function
  -z100            : Record length
  -0.20ascr        : Key field
  -e10.20,d0.10zdl : Reconstruction field
  -o bsortout      : Output file name
  bsortin          : Input 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.

bsort -s -z100 -10.20ascr -g50.8pdl -o bsortout bsortin

  -s           : Sort function
  -z100        : Record length
  -10.20ascr   : Key field
  -g50.8pdl    : Summation field
  -o bsortout  : Output file name
  bsortin      : Input file name

Point

It is irregular which record output from among the record where the key field is equal.

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, arbitrary 1 record is kept and others are deleted.

bsort -s -u -z100 -10.20ascr -o bsortout bsortin

  -s           : Sort function
  -u           : Suppression option
  -z100        : Record length
  -10.20ascr   : Key field
  -o bsortout  : Output file name
  bsortin      : Input file name

Point

It is irregular which record output from among the record where the key field is equal.

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.

bsort -s -f -z100 -10.20ascr -o bsortout bsortin

  -s           : Sort function
  -f           : FIFO option
  -z100        : Record length
  -10.20ascr   : Key field
  -o bsortout  : Output file name
  bsortin      : Input file name

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.

bsort -s -z100 -8.4asca -Tfix -o bsortout bsortin

  -s          : Sort function
  -z100       : Maximum record length
  -8.4asca    : Key field
  -Tfix       : Text file fixed field specification
  -o bsortout : Output file name
  bsortin     : Input 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.

bsort -s -z100 -1.4asca -Tflt -t: -o bsortout bsortin

  -s          : Sort function
  -z100       : Maximum record length
  -1.4asca    : Key field
  -Tflt       : Text file floating field specification
  -t:         : Field separation character
  -o bsortout : Output file name
  bsortin     : Input 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 bsortout. When the file bsortout1 abnormally terminates, the remaining records are output to file 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.

bsort -s -z100 -0.10asca -o bsortout1 -o bsortout2 bsortin

  -s           : Sort function
  -z100        : Record length
  -0.10asca    : Key field
  -o bsortout1 : Output file name
  -o bsortout2 : Output file name (When the file bsortout1 abnormally terminates)
  bsortin      : Input file name

Example 12 : 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.

bsort -s -z100 -Zf -0.20asca -Fcobs64,btrv -o bsortout bsortin

  -s            : Sort function
  -z100         : Record length
  -Zf           : Record format
  -0.20asca     : Key field
  -Fcobs64,btrv : Input/Output file system
  -o bsortout   : Output file name
  bsortin       : Input file name

Example 13 : 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.

bsort -s -z100 -Zf -0.10asca,50.4asca -Fmfcseq,mfcidx -o bsortout bsortin

  -s                 : Sort function
  -z100              : Record length
  -Zf                : Record format
  -0.10asca,50.4asca : Key field
  -Fmfcseq,mfcidx    : Input/Output file system
  -o bsortout        : Output file name
  bsortin            : Input file name