ALTSEQ (Alternate Sequence) in DFSORT lets you define a custom character mapping. It has two main uses: (1) as an alternate collating sequence so that sort comparisons use your mapping instead of the default EBCDIC order, and (2) for character translation when building records—you reference TRAN=ALTSEQ on fields in INREC or OUTREC so that bytes are translated according to the ALTSEQ table. You define the table with ALTSEQ CODE= using pairs of (input_hex, output_hex). For example, you can build a full EBCDIC-to-ASCII translation table and apply it to selected fields. This page covers ALTSEQ CODE=, using TRAN=ALTSEQ in INREC/OUTREC, and typical uses like case conversion or code page conversion.
ALTSEQ defines a mapping from one byte value to another. Once defined with CODE=, that mapping can be used so that sort comparisons follow a different order (alternate collating sequence), and/or so that when you build records in INREC or OUTREC, specified fields are translated—each byte is replaced by its mapped value. So ALTSEQ is both "how to compare" and "how to transform" characters, depending on where you reference it.
ALTSEQ CODE=(pair1,pair2,...). Each pair is (input_hex, output_hex): when the mapping is applied, a byte with value input_hex is treated as or replaced by output_hex. Hex values are typically given in the format your DFSORT expects (e.g. two hex digits per byte). So CODE=(C1,41) might map EBCDIC A (X'C1') to ASCII A (X'41'). You can specify many pairs to cover the full 256 bytes if needed (e.g. for EBCDIC to ASCII conversion).
To translate a field when building a record, specify TRAN=ALTSEQ for that field in INREC or OUTREC. For example, OUTREC FIELDS=(1,80,TRAN=ALTSEQ) copies the full 80-byte record and applies the ALTSEQ translation to it. You can apply translation to selected segments: e.g. (1,20,21,60,TRAN=ALTSEQ) might translate only bytes 21–80. The exact syntax (which segment gets TRAN=ALTSEQ) depends on your DFSORT version; see your documentation.
When ALTSEQ is used as the collating sequence for the sort, the key comparison uses your mapping—so the sort order can differ from standard EBCDIC. This is useful for custom sort orders (e.g. a specific national character order) or when you want certain characters to sort as if they were others.
ALTSEQ is like a "replace this letter with that letter" list. You write down: when you see A, treat it as B; when you see C, treat it as D; and so on. Then when DFSORT sorts or when it builds a new card, it can use that list to change the letters. So ALTSEQ = your own translation or sort-order rule.
1. What is ALTSEQ used for in DFSORT?
2. How do you apply ALTSEQ translation to a field in OUTREC?
3. What does ALTSEQ CODE= define?
4. Can ALTSEQ be used for EBCDIC to ASCII conversion?