SUNSORT
The SUNSORT utility sequences a data file in a particular order. The command line syntax for SUNSORT is as follows:
|
|
|
Note the following:
If a path specification is not given on {int}, the current path is searched followed by all search paths.
When no file extension is given for {in} or {out}, the default text extension as specified in the screen definition file is used.
If neither {in} nor {out} are located in the current directory, the directories specified in the PLB_PATH environment variable are searched for the existence of both {in} and {out} files.
If {output} is not specified, the file is sorted to a temporary file and when the sort is finished, the temporary file is renamed to the original file.
If a path specification is not given on {out}, the file is placed in the same location as {in}.
If the {log} file option is specified, all program messages are written to the file named by the {log} parameter. The following are the values for the {mode} parameter:
|
Mode |
Meaning |
|
L |
Write all messages to the log file. |
|
Q |
Append all messages to the log file. |
{opts} refers to special options that affect the output of the sort.
B
F={nn}
Records are fixed length binary with NO end of record bytes.
G={nn}
Records are fixed length binary with normal end of record bytes.
I{ininame}
When specified, the utility will first look for any operational keywords in {inifile}. If the keyword is not found, the UET is searched. The filename specified by {ininame} must be a fully qualified name. If a full path is not specified, the filename must exist in the current working directory.
K
M
P{nn}{=|#}{c}
P{=|#}"{comp}{logical}{comp}...}"
R#{{startpos}-{endpos},'{literal}'}{,...}# // MS-DOS
R\"{{startpos}-{endpos},'{literal}'}{,...}\" // MS-DOS
R#{{startpos}-{endpos},\'{literal}\'}{,...}# // Linux
R\"{{startpos}-{endpos},\'{literal}\'}{,...}\" // Linux
Record Reformat. If specified, the sorted output is reformatted to the specifications identified. This option allows output of only certain columns of the input and allows adding constant data to the output. The reformat option generates fixed length records. If the input record was shorter, it is filled with spaces. If the input record was longer, it is truncated. {startpos} identifies a starting column position within a record. {endpos} identifies an ending column position within a record. {literal} - Identifies a literal string to be included in all records being output. The literal string must be enclosed between double quote (") characters and can include space characters. Additionally, some operating systems strip off the double quote character if it is not forced with a leading slash (\) as in the third format above.
S{nn}{=|#}{c}
S{=|#}"{comp}{logical}{comp}...}"
{comp} is of the form {c}{op}{string}, where {c} is the starting column position, {op} is the match operator and {string} is the string to test with. The match operator may be one of the following: =, E, !=, <>, NE, <, L, <=, LE, >, G, >=, or GE. The {string} is specified by a starting single quote, the actual text string and an ending single quote. To include a single quote in the string, use two single quotes.
{logical} is the optional operator to allow more than one selective output specification. It may be a '&' for an 'and' condition, or a '|' for an 'or' condition.
A valid example of a selective output specification with two different strings in the same columns would be: s="5='CREDIT'|5='DEBIT '"
T
W
X
{keys} refers to the actual key information used in the sequencing of the file. Any keyspec may be preceded by one of the following options. The options affect every keyspec that follow until an alternate option is given.
A
D
L
U
N
O{c}
A maximum aggregate key length plus primary specifications of one hundred and fifty (150) bytes is permitted.
The amount of work space required may be approximated by:
2 * ( ( keylength + 6 ) * records )
If TMPDIR=path is defined in the User Environment Table when the SUNSORT utility is executed, the specified path is used as the default path for creating the temporary files. If neither {tmp} nor TMPDIR is specified, the temporary work files are placed in the root directory of the current drive.
The {seq} file is generated with the SORTSEQ utility. This utility allows the user to change the order that characters are sorted and/or change the character value that a character is sorted as. For example, one could swap 'A' and 'B' and then all sequences of uppercase 'B' would sort ahead of all sequences of uppercase 'A'. You could also alias lowercase 'a' with uppercase 'A' and then all sequences of both 'a' and 'A' would sort together as the same character 'A'.
SUNSORT supports the PLB_FNC keyword that forces file names to lowercase or mixed case when they are created.
The Alternate Primary Record Specification and the Alternate Selective output Specification expressions support mathematical comparisons for the {op} operations. This allows a mathematical type indicator ( i.e. {N|n} ) to be included in the expression after the {c} starting column position.
The mathematical type indicator can be specified in the {comp} expression using the following syntax format:
{comp} format using {N|n} mathematical type indicator:
Where:
Note:
If the optional {N|n} comparison type is used, the {string} must be specified as a valid numeric string as follows:
Leading blanks are skipped and count against the total field size being compared. Any blank or white-space characters found after the first valid numeric character causes and invalid numeric {string} declaration.
A single leading '-' (i.e. negative character) is supported which can ONLY be specified after any leading blanks and before any valid numeric digits or decimal point.
A single decimal point character can be specified in the {string} numeric declaration.
All other characters specified in the {string} numeric declaration must be '0' to '9' digits.
If the optional {N|n} comparison type is used, an invalid numeric {string} declaration causes an error from the sor tutility as follows:
If the optional {N|n} comparison type is used, the record that includes an invalid numeric field found at the {c} starting position may or may not be included in the selection record output depending on the logical evaluation of the 'S=' or 'S#' expression being used.
Examples for {N|n} usage:
Examples for {N|n} numeric type usage with invalid record fields:
In this scenario, any invalid numeric fields found in the in the record at character position 10 are ignored and not included in the sorted output. The output should only include records that have a field value of '1.00'.
In this scenario, all records that do NOT have a value of '1.00' are included in the output records including records with invalid numeric fields.
In this scenario, the selected record output does not include any invalid numeric fields encountered. In this case, the selected record output ONLY includes records that have valid numeric fields whose value is not equal to '1.00'.
See Also: SUNSORT Examples, Utilities
![]() |