DFSORT Sorting a pack decimal field.
Moderators: Frank Yaeger, Moderator Group
DFSORT Sorting a pack decimal field.
Using DFSORT how can I sort por "one" number in a pack decimal field.
If the field has a part numbe S9(7) COMP-3 and it has '0003864358421C'
menaing PD = each byte will have 00 03 86 43 58 42 1C and want to sort the fourth byte (which has 43) but I only want to sort the "3" or '5' in descending order. Then I want to select those records on an output file..
These I think is a problem if I put:
SORT FIELDS=(4,1,PD,D,)
OUTFIL INCLUDE=(4,1,BI,EQ,3,4,1,BI,EQ,5) or
OUTFIL INCLUDE=(4,1,PD,EQ,3,4,1,PD,EQ,5)
This will sort 43 and not 3 and in case of descending it will put put a 23 or 33 or any combination of a high number before the "3" before a "15" or "25" etc.
I look at the PD0 but it does not apply to this example.
Again all I want to do is sort one digit within a pack field which has two digits in each byte.
Thanks
If the field has a part numbe S9(7) COMP-3 and it has '0003864358421C'
menaing PD = each byte will have 00 03 86 43 58 42 1C and want to sort the fourth byte (which has 43) but I only want to sort the "3" or '5' in descending order. Then I want to select those records on an output file..
These I think is a problem if I put:
SORT FIELDS=(4,1,PD,D,)
OUTFIL INCLUDE=(4,1,BI,EQ,3,4,1,BI,EQ,5) or
OUTFIL INCLUDE=(4,1,PD,EQ,3,4,1,PD,EQ,5)
This will sort 43 and not 3 and in case of descending it will put put a 23 or 33 or any combination of a high number before the "3" before a "15" or "25" etc.
I look at the PD0 but it does not apply to this example.
Again all I want to do is sort one digit within a pack field which has two digits in each byte.
Thanks
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Your explanation of what you want to do is very confusing, especially your OUTFIL statements which have incorrect syntax.
If you want to SORT on the second PD digit in the 4th byte, you can use a SORT statement like this:
If you want to SORT on the first PD digit in the 5th byte, you can use a SORT statement like this:
If you want to sort on the second PD digit in the 4th byte and on the first PD digit in the 5th byte, you can use a SORT statement like this:
If you want to do something else, you need to explain more clearly what it is exactly that you want to do.
Huh? I can't figure out what you mean by this.but I only want to sort the "3" or '5' in descending order
If you want to SORT on the second PD digit in the 4th byte, you can use a SORT statement like this:
Code: Select all
SORT FIELDS=(4.4,0.4,BI,D)
Code: Select all
SORT FIELDS=(5,0.4,BI,D)
Code: Select all
SORT FIELDS=(4,2,PD0,D)
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Re: DFSORT Sorting a pack decimal field.
Hello again.
I want to apologize for not explaining well what I wanted although you already answer part of the original question.
Let me rephrase it.
I have a field which is defined as PIC S9(7) COMP-3.
The field is holding the following numbers: 00 03 86 43 58 42 1C for the first record.
That is byte one has 00, byte two has 03, byte three has 86, byte four has 43, byte five has 58, byte six has 42 and byte seve has 1C (they are in pack decimal format). This is example one but the next record has 00 04 72 35 12 31 2C and the following will have 00 32 66 87 99 21 3C (meaning the number changes base on part number). The right most number of the fourth byte has a special meaning there fore I want to sort ONLY for that number.
I used the following code:
SORT FIELDS=(4,1,PD,D,)
OUTFIL INCLUDE=(4,1,BI,EQ,3,4,1,BI,EQ,5) or
OUTFIL INCLUDE=(4,1,PD,EQ,3,4,1,PD,EQ,5)
This will sort the fourth byte but the two positions.
What I want is to sort for the number 3 on the first number and number 5 on the second number which is the right most number of the fourth byte. Because this numbers changes base on the part number I also want to select only those parts which have a 3 or a 5 in the rightmost of the fourth byte. That is where I put the OUTFIL INCLUDE= statement but in there I need to tell the sort to only include the output file only those records which have a 3 or a 5 on the rightmost number of the fourth byte. In the above numbers the third record will not be selected because it has a 7 on the right most position of the fourth byte. The output file I want it to be sorted in descending order.
Thanks a million. I hope my question is clearer now.
I want to apologize for not explaining well what I wanted although you already answer part of the original question.
Let me rephrase it.
I have a field which is defined as PIC S9(7) COMP-3.
The field is holding the following numbers: 00 03 86 43 58 42 1C for the first record.
That is byte one has 00, byte two has 03, byte three has 86, byte four has 43, byte five has 58, byte six has 42 and byte seve has 1C (they are in pack decimal format). This is example one but the next record has 00 04 72 35 12 31 2C and the following will have 00 32 66 87 99 21 3C (meaning the number changes base on part number). The right most number of the fourth byte has a special meaning there fore I want to sort ONLY for that number.
I used the following code:
SORT FIELDS=(4,1,PD,D,)
OUTFIL INCLUDE=(4,1,BI,EQ,3,4,1,BI,EQ,5) or
OUTFIL INCLUDE=(4,1,PD,EQ,3,4,1,PD,EQ,5)
This will sort the fourth byte but the two positions.
What I want is to sort for the number 3 on the first number and number 5 on the second number which is the right most number of the fourth byte. Because this numbers changes base on the part number I also want to select only those parts which have a 3 or a 5 in the rightmost of the fourth byte. That is where I put the OUTFIL INCLUDE= statement but in there I need to tell the sort to only include the output file only those records which have a 3 or a 5 on the rightmost number of the fourth byte. In the above numbers the third record will not be selected because it has a 7 on the right most position of the fourth byte. The output file I want it to be sorted in descending order.
Thanks a million. I hope my question is clearer now.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Your OUTFIL syntax is incorrect. But you don't need OUTFIL statements unless you are trying to put the '3' records in one file and the '5' records in another file. Assuming you really just want the '3' and '5' records in one output file, you can use these DFSORT statements to do what you asked for:
Code: Select all
INCLUDE COND=(4,1,BI,EQ,B'....0011',OR,4,1,BI,EQ,B'....0101')
SORT FIELDS=(4.4,0.4,BI,D)
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
"you guys"? It was just you and me in this thread as far as I could see.
Anyway, glad I could help.
Anyway, glad I could help.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
changeing sign
how to change the sign from positive to negative for a given number
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page