The Sort Text command sorts the records in a text member according to
a control record.
Assume you have entered a list of names into a text member as
follows:
JB Smith
AH Jones
BR Smith
.
.
After entering the list, you decide that it would be better to keep
the list in alphabetical sequence. The SORTTXT command will allow
you to do this in a few simple steps.
1. Set up a separate source member with the list you want sorted.
For example, you could set up a new source member and copy the
list. Only the records you want sorted should exist in the
new member. The SORTTXT command will default to use the
SORTOUT member name. You could use this member name for all
of your sorting requirements.
2. Enter a control record as the first record in the new member.
You enter the characters directly over the values to be sorted
as:
22 11111111111
JB Smith
AH Jones
In this case you are describing that the sequence should be
last name (high order) followed by the initials. The result
of the sort is to place the sorted records into a new member
(the same member could be used). The control record will be
dropped.
3. Specify the SORTTXT command such as:
SORTTXT
The default of the command is to use the QTXTSRC file on the
library list and to sort the SORTOUT member and replace it
with the sorted version. The control record is deleted
automatically.
4. You can then copy the sorted records back to your original
source or use an 'include' function.
Up to 4 sort fields can be described. Descending sequence can be
specified on the command.
The control record must be the first record in the source member. It
cannot be all blank.
The control record can only contain blanks and the characters 1 2 3
4. You cannot have a split control field (a single sort field must
be in consecutive positions). If you enter any other characters on
the control record, an error will occur.
You can use consecutive positions for sort fields. For example, if
you had a date field to sort on as:
060188 Jones
052288 Smith
032187 Miller
011299 Williams
You could specify the high order to be on year followed by MMDD and
then the name field.
222211 33333333333
060188 Jones
The FROMMBR and TOMBR can be the same. In this case, the control
record will be deleted and the records written back in sequence.
By default, if the Text Management special statement .PRT is read,
the source is assumed to be complete. All records read up to that
point will be sorted. The special records added by Text Management
will not be included.
The source file can be up to 240 bytes and be sorted correctly.
Command parameters *CMD
------------------
FROMMBR The member name which contains the records to be
sorted. The default is SORTOUT.
TOMBR The member name which will contain the output of the
command. The default is *FROMMBR meaning to copy
the sorted output back into the from member. If the
member does not exist, it is added with the source
type and text of the 'from member'.
FROMFILE The qualified name of the from file. The library
defaults to *LIBL. *CURLIB may also be specified.
TOFILE The qualified name of the to file. The name
defaults to *FROMFILE. The library defaults to
*LIBL. *CURLIB may also be used. If *FROMFILE is
specified and the library qualifier is *LIBL, the
library is taken from the FROMFILE parameter.
SRT1SEQ The sequence of the Sort 1 field. *ASCEND is the
default, *DESCEND may be specified.
SRT2SEQ The sequence of the Sort 2 field. *ASCEND is the
default, *DESCEND may be specified.
SRT3SEQ The sequence of the Sort 3 field. *ASCEND is the
default, *DESCEND may be specified.
SRT4SEQ The sequence of the Sort 4 field. *ASCEND is the
default, *DESCEND may be specified.
TXTMGT Whether to end the source being read if the special
Text Management End statements (beginning with .PRT)
are read.
The default is *YES. All records read up to that
point will be sorted. The special records added by
Text Management will not be included.
*NO may be specified to sort the Text Management
statements.
Restrictions
------------
None.
Prerequisites
-------------
The following TAA Tools must be on your system:
HLRMVMSG HLL Remove message
SNDCOMPMSG Send completion message
SNDESCMSG Send escape message
SNDSTSMSG Send status message
WRTSRC Write source records
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ----- --------- ---------- -----------
SORTTXT *CMD TAAMBRC QATTCMD
TAAMBRCC *PGM CLP TAAMBRCC QATTCL
TAAMBRCR *PGM RPG TAAMBRCR QATTRPG
TAAMBRCR2 *PGM RPG TAAMBRCR QATTRPG
|