Posted: Mon Sep 06, 2004 11:27 am Post subject: Reformat to PD using OUTREC
Hi All,
There is an input file with the following format :
1,9 - PD
10,29 - CHAR
Now I want to sort the file based on the following criteria :
1) Expand 1-9 Packed decimal fields into ZD
2) Sort the 15th byte of the expanded record,
3) Reformat the expanded ZD fields into original PD and write an sorted o/p file that has the same record structure as i/p file.
Summed up as : Want to sort the PD field based on the 15th digit and write it back as it was.
Actually Step1 & Step2 worked fine with the Hex Trick (i.e) :
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Sep 06, 2004 12:23 pm Post subject:
Hariharan,
I really don't get what you are trying to do. If your intention is to sort the PD fields ignoring the sign bit , then you can simply use the PD0 Format.
For the PD0 format (packed decimal, with sign and first digit ignored). The PD0 format can be represented as follows:
Code:
xddd...ds
x is hexadecimal 0-F and is ignored.
d is hexadecimal 0-9 and represents a decimal digit.
s is hexadecimal 0-F and is ignored.
PD0 can be used for parts of PD fields. For example, in the PD field P'mmddyy' (hexadecimal 0mmddyyC), PD0 can be used separately for 0mmd (mm), mddy (dd) and dyyC (yy).
The problem is that the sort should be done on a single digit of a COMP-3 record. Ex. to sort the 17th digit of a PD record having 9 Bytes storage space.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Sep 06, 2004 2:23 pm Post subject:
Quote:
But I am stuck in Step 3. i.e to reformat the expanded 9byte PD (17 digits) back to its original format.
Is there any way that the input file format remains intact after sorting?
I'm not sure what you're trying to do either, but ...
Yes, you could get the PD value back by a trick involving converting the first 4 ZD bytes to two PD bytes and only using the first PD byte (2 digits), but you're really taking the entirely wrong approach here. Rather than transforming the ZD field back to a PD field, it makes more sense to keep the original record intact and just add on the ZD key, sort on it and remove it.
Here's a DFSORT job that shows what I mean:
Code:
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
INREC FIELDS=(1,29, ORIGINAL FIELDS
30:1,1,HEX,2,8,PD,TO=ZD) Add ZD field converted from PD field
SORT FIELDS=(30,15,CH,A, Sort on ZD field
11,1,CH,A, Sort on original field
45,2,CH,A) Sort on ZD field
OUTREC FIELDS=(1,29) Remove ZD field
/*
_________________ 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: Mon Sep 06, 2004 2:30 pm Post subject:
Well, I just read your post on what you really want to do. You can sort on the 17th digit by using bytes.bit notation for the DFSORT SORT statement like this:
Code:
SORT FIELDS=(9,0.4,BI,A)
9 says to start at the first bit of position 9.
0.4 gives the length as 4 bits.
The format must be BI.
Note that if all of the PD values had the same sign (e.g. C), you could just sort on the last byte (digit+sign = 9,1,BI,A) as binary. And if the sign mattered, you could sort on the last byte (digit+sign = 9,1,PD,A) as PD.
It helps us to help you if you give us ALL the information about what you're trying to do. _________________ 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