View previous topic :: View next topic
|
Author |
Message |
vinodkumarrs
New User
Joined: 31 Mar 2008 Posts: 8 Location: india
|
|
|
|
Hi,
I have a 12 byte COMP-3 field from byte 230-235 as shown below. i need to sort the records based on the 5-7 bytes of the field, ie with the value 302, in the given record. The input file is of 403 byte length.
[img]C:\Documents and Settings\169685\Desktop\record[/img]
Thanks in advance.[/img] |
|
Back to top |
|
|
vinodkumarrs
New User
Joined: 31 Mar 2008 Posts: 8 Location: india
|
|
|
|
vinodkumarrs wrote: |
Hi,
I have a 12 byte COMP-3 field from byte 230-235 as shown below. i need to sort the records based on the 5-7 bytes of the field, ie with the value 302, in the given record. The input file is of 403 byte length.
[img]C:\Documents and Settings\169685\Desktop\record[/img]
Thanks in advance.[/img] |
|
|
Back to top |
|
|
Girish Firke
New User
Joined: 04 Feb 2009 Posts: 5 Location: Mumbai
|
|
|
|
Hi Vinod,
Sort control card syntax for packed decimal values will be
SORT FIELDS=(Starting Position, Length, PD,A)
By looking at your question I am getting that you want to sort the 3 bytes from 5 character of a comp-3 field. If that is the case then please try below control card and let me know whether it works fine or not.
In your case
SORT FIELDS=(232,02,PD,A) |
|
Back to top |
|
|
vinodkumarrs
New User
Joined: 31 Mar 2008 Posts: 8 Location: india
|
|
|
|
Hi Girish,
The SORT FIELDS=(232,02,PD,A), will take 4 bytes to check. In my case it will take the value '3021' for sorting, I need only upto '302'.
Thanks,
Vinod |
|
Back to top |
|
|
Girish Firke
New User
Joined: 04 Feb 2009 Posts: 5 Location: Mumbai
|
|
|
|
Hi,
Your screenshot shows the hexa-decimal value of the record.
The hex-decimal value X'30' represent one ascii character and X'21' represents another ascii character.
I am not sure whether we can sort those as per your requirement. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Also, since you are not checking the entire packed field, specifying PD for the sort is invalid.
You could try INREC processing to expand the COMP-3 field into an appended work field and sort based on the expanded 3 characters in that field. Then use OUTREC processing to drop the work field.
Garry. |
|
Back to top |
|
|
vinodkumarrs
New User
Joined: 31 Mar 2008 Posts: 8 Location: india
|
|
|
|
I tried the above mentioned logic and it worked. thanks
Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=------
//*
//SORTOUT DD DSN=------
//SYSIN DD *
OPTION EQUALS
INREC OVERLAY=(404:230,6,PD,TO=ZD,LENGTH=11)
SORT FIELDS=(408,3,ZD,A)
OUTREC BUILD=(1,403)
/* |
|
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Thanks for letting us know, Vinod.
Glad to have been able to help.
Garry. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a much easier way to do this using DFSORT's bit notation for the length:
Code: |
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(232,1.4,BI,A)
/*
|
For example, if the value at 232-233 is X'3021', this tells DFSORT to sort on 1 byte and 4 bits, e.g. on 302. |
|
Back to top |
|
|
vinodkumarrs
New User
Joined: 31 Mar 2008 Posts: 8 Location: india
|
|
|
|
This also works fine.
Since I need 3 bytes to compare I modified as below.
Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=------
//*
//SORTOUT DD DSN=------
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(232,1.3,BI,A)
/* |
Thank you very much for the help.
Regards,
Vinod |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Huh? You are dealing with 2 bytes (232-233), not 3 bytes.
1.4 for the length means 1 byte and 4 bits. 1.3 for the length means 1 byte and 3 bits. 1.4 for the length would give the correct results for all cases whereas 1.3 for the length wouldn't.
As an example, if 232-233 had records with these hex values:
3010
3000
3030
3020
Using 232,1.4 you would correctly get these output records:
3000
3010
3020
3030
Using 232,1.3, you would incorrectly get these output records:
3010
3000
3030
3020
As you can see, that fourth bit does matter. |
|
Back to top |
|
|
vinodkumarrs
New User
Joined: 31 Mar 2008 Posts: 8 Location: india
|
|
|
|
Hi,
I got the same results when I tried with 232,1.3 as well as 232,1.4 bytes.
Anyway I got the point that Frank mentioned above. Hence I will follow with the 232,1.4 option. Thanks for the clear explanation.
Regards,
Vinod |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I got the same results when I tried with 232,1.3 as well as 232,1.4 bytes. |
That was due to fortune rather than proper code. . .
At some point the output would have not been the same and that could be an ugly surprise
Using the nnn,1.4 will ensure the proper bits are used for sorting.
Thanks for the update |
|
Back to top |
|
|
|