DFSORT Sorting a pack decimal field.

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
gonzalezw
Member
Posts: 7
Joined: Sat Nov 27, 2010 7:51 am

DFSORT Sorting a pack decimal field.

Post by gonzalezw » Wed Mar 30, 2011 9:30 pm

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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Mar 30, 2011 10:33 pm

Your explanation of what you want to do is very confusing, especially your OUTFIL statements which have incorrect syntax.
but I only want to sort the "3" or '5' in descending order
Huh? I can't figure out what you mean by this.

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)  
If you want to SORT on the first PD digit in the 5th byte, you can use a SORT statement like this:

Code: Select all

  SORT FIELDS=(5,0.4,BI,D)  
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:

Code: Select all

  SORT FIELDS=(4,2,PD0,D)
If you want to do something else, you need to explain more clearly what it is exactly that you want to do.
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

gonzalezw
Member
Posts: 7
Joined: Sat Nov 27, 2010 7:51 am

Re: DFSORT Sorting a pack decimal field.

Post by gonzalezw » Thu Mar 31, 2011 11:21 pm

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.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Mar 31, 2011 11:44 pm

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

gonzalezw
Member
Posts: 7
Joined: Sat Nov 27, 2010 7:51 am

Post by gonzalezw » Fri Apr 01, 2011 1:06 am

Thank You so much - you guys are nothing but the best. It worked fine.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Apr 01, 2011 1:42 am

"you guys"? It was just you and me in this thread as far as I could see.

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

arif
Member
Posts: 2
Joined: Wed Sep 24, 2014 10:38 am

changeing sign

Post by arif » Fri Oct 31, 2014 12:24 pm

how to change the sign from positive to negative for a given number

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Oct 31, 2014 12:51 pm

You should post this as a new question. Subtract it from zero.

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 9:32 pm

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others