|
Beyond
Mainframe ALTSEQ
If the collating sequence of your data differs with the natural ordering
of that data type, you can either write a custom compare procedure
(/KEYPROCEDURE), or use SortCL's
/ALTSEQ statement. ALTSEQ supports input fields declared as ASCII (the default) or EBCDIC.
As usual, SortCL exceeds the above
mainframe sort functionality by
also enabling ALTSEQ value substitutes in output field displays, and
for conditional evaluations applicable in SortCL.
The syntax for specifying an alternate sequence is:
/INFILE(S)=path(s)/filename(s)
/ALTSEQ=(hex_value1Ahex_value1B
[,hex_value2Ahex_value2B][,etc.])
where the character represented by hex_value1A will be replaced with the character represented by hex_value1B.
You can also specify additional replacements (offset with a comma) such as substituting hex_value2A for hex_value2B, and so on.
Using hex values allows for non-printable characters.
For example, given this input file,
sales.dat:
A book 6.98
C blouse 23.45
1 tablet 2.45
B yarn 10.78
3 skirt 78.98
C coat 235.97
2 thread 4.25
A pen,blk 2.98
The SortCL job specification
file below redefines the 'dept' field to replace every hex 41 value
(=A) with a hex 31 value (=1) and so on. The virtual /INREC record
definition converts the dept field before the sort.
/INFILE=sales.dat
/ALTSEQ=(4131,4232,4333)
/FIELD=(dept,pos=1,size=1)
/FIELD=(alt_dept,pos=1,size=1)
/FIELD=(item,pos=3,size=10)
/FIELD=(amount,pos=14,size=8, NUMERIC)
/INREC
/FIELD=(dept,pos=1,size=1)
/FIELD=(alt_dept,pos=2,size=1, ALTSEQ)
/FIELD=(item,pos=3,size=10)
/FIELD=(amount,pos=14,size=8, NUMERIC)
/SORT
/KEY=(dept, ALTSEQ)
/KEY=item
/OUTFILE=dept1
/INCLUDE WHERE alt_dept == "1"
/FIELD=(alt_dept,pos=1,size=1)
/FIELD=(item,pos=3,size=10)
/FIELD=(amount,pos=14,size=8, NUMERIC)
/OUTFILE=dept2
/INCLUDE WHERE alt_dept == "2"
/FIELD=(dept,pos=1,size=1)
/FIELD=(item,pos=3,size=10)
/FIELD=(amount,pos=14,size=8, NUMERIC)
/OUTFILE=dept3
/INCLUDE WHERE alt_dept == "3"
/FIELD=(dept,pos=1,size=1)
/FIELD=(item,pos=3,size=10)
/FIELD=(amount,pos=14,size=8, NUMERIC)
The end result are three
conditionally segmented output files in the same sort order; first
by the converted dept values, then by item.
In the first output file, dept1,
note that we displayed the changed 'dept' field value:
1 book 6.98
1 pen,blk 2.98
1 tablet 2.45
whereas in the output of
dept2 and dept3, the original dept field value is kept (though its
sort order is based on the alternate dept value). dept2:
2 thread 4.25
B yarn 10.78
dept3:
C blouse 23.45
C coat 235.97
3 skirt 78.98
As always, email questions to support@iri.com.
|