Joined: 19 May 2004 Posts: 51 Topics: 25 Location: My House
Posted: Sun Dec 12, 2004 2:06 am Post subject: ALTSEQ in sort
Hi,
I am not very clear on usage of ALTSEQ.
I want 'M' to come after 'Z' in the collating sequence.
How to code the command ?
How to conver the character to HEX ?
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Dec 12, 2004 11:23 am Post subject:
Quote:
I want 'M' to come after 'Z' in the collating sequence.
How to code the command ?
To sort 'M' after 'Z', you can use the following DFSORT statements:
Code:
ALTSEQ CODE=(D4EA)
SORT FIELDS=(p,m,AQ,A)
p is the starting position of the key and m is the length of the key (e.g. 21,4,AQ,A).
M is X'D4' and Z is X'E9'. D4EA in the ALTSEQ statement tells DFSORT to set up the alternate collating sequence table (ALTSEQ table) with M after Z.
The AQ format in the SORT statement tells DFSORT to SORT that key using the alternate collating sequence table.
Quote:
How to conver the character to HEX ?
If you do a Google search on "EBCDIC", you'll find many tables that show you the hex equivalent for each EBCDIC character. Here's the URL of the first one Google found when I did the search:
Of course, you could use DFSORT's p,m,HEX parameter to convert EBCDIC characters to hex characters, but looking at a table is probably easier when you just want the hex codes for ALTSEQ. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Dec 12, 2004 7:56 pm Post subject:
(1) If you use D4E9, then 'M' will collate the same as 'Z'. Since you want 'M' to collate after 'Z', you need to use D4EA.
(2) NOPQRSTUVWXYZM ( M to be considered after Z )
The ALTSEQ table is 256 bytes. The default is the EBCDIC table which runs from X'00'-X'FF'. ALTSEQ CODE=(D4EA) changes the entry in the table at offset X'D4' to X'EA'. So when we sort an 'M' (X'D4'), we pick up the character after 'Z' (X'EA') from the table instead of the 'M' (X'D4'). Thus, X'EA' is used for 'M' instead of X'D4'. None of the other entries in the table are changed by D4EA, so the offset at X'E9' ('Z') is still X'E9' ('Z').
If you wanted 'M' to collate the same as 'Z', you would use ALTSEQ CODE=(D4E9), so when we sort an 'M' (X'D4') we would pick up the character 'Z' (X'E9') from the table instead of the 'M' (X'D4').
To get the equivalent of:
ZNOPQRSTUVWXYM
you'd need to use ALTSEQ CODE=(D4E9,E9D4). That would exchange 'M' and 'Z'.
If you know Assembler, then think of the ALTSEQ table as working like the translation table for TR and TRT. You can read about how those instructions work in "Principles of Operation". _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum