dfsort on file with mutiple 3 byte codes

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
nina22
Member
Posts: 6
Joined: Sun Apr 19, 2009 2:00 am

dfsort on file with mutiple 3 byte codes

Post by nina22 » Sun Apr 19, 2009 2:08 am

I was given a file that has five 3 byte codes in it. For example...

xxxxx000000000222631
xxxxx000000632000222
xxxxx631999000000000

I am supposed to sort the file in ascending sequence. This input file will always contain codes of either 631, 632 or 633. Some will have ONLY one field containing either 631, 632 or 633. Other records will have codes (like 222 above) in them. I don't see any way to sort this file with the 631 and 632 and 633 codes in ascending order if sometimes another code exists.

Hope this makes sense.

krishna.rms
Member
Posts: 6
Joined: Thu Apr 16, 2009 5:29 pm

Post by krishna.rms » Mon Apr 20, 2009 12:28 pm

Do you want to keep those other Codes also in the file after sorting or you want to skip those/delete from the file/want to keep in some othere file. Please specify

nina22
Member
Posts: 6
Joined: Sun Apr 19, 2009 2:00 am

Post by nina22 » Mon Apr 20, 2009 6:11 pm

I want to only keep codes 631 632 and 633 in the sorted file

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

Post by Frank Yaeger » Mon Apr 20, 2009 8:14 pm

Nina,

Your requirement is not clear.

Does every record have one of the three codes 631, 632 or 633 in one of those 5 fields? Or do some records not have 631, 632 or 633?

Please show a better example with more than 3 input records. Show records without any of the 3 codes if that's possible. Show the expected output records.
I want to only keep codes 631 632 and 633 in the sorted file
I don't understand what you mean by this. Hopefully, showing the expected output will make it clear what you want.

Also, give the RECFM and LRECL of the input file.

Do the set of 5 codes start in position 6 as shown in your example?
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

nina22
Member
Posts: 6
Joined: Sun Apr 19, 2009 2:00 am

Post by nina22 » Mon Apr 20, 2009 8:54 pm

every record will have one of the three codes...the last 15 bytes of the sorted file below are the five 3 byte codes, but because there could be an additional code along with a 631 or 632 or 633, the 600 series codes won't always sort in ascending seq

For example, the first 2 record have additional codes along with 632 and 633. So I don't think it's possible to sort the 600 codes since another code
could be there also

20090401D2009040320090403000000041109632
20090401D2009040320090403000000041109633
20090401C2009032620090413000000000631000
20090401C2009032620090413000000631000000
20090401C2009032620090413000000631000000
20090401C2009032620090413000000631000000
20090401C2009041520090417000000631000000
20090401C2009041520090417000000631000000
20090402C2009041520090417000000631000000
20090401C2009041520090417000000631000000
20090401C2009041520090417000000631000000
20090401C2009021420090414000000632000000
20090401C2009021420090414000000633000000
20090401C2009041320090414000000633000000

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

Post by Frank Yaeger » Mon Apr 20, 2009 9:28 pm

Please stop saying that it isn't possible. Of course it is.

Instead, give me the information I asked for so I can show you how to do what you want.

Again:

Show the expected output records.

Give the RECFM and LRECL of the input file.

What position do the "last 15 bytes" start in?

Also, you say that you want to sort on the three codes. For records that all have the same code (e.g. 631), do you want to sort them on an additional field (which one) or output them in the same order as they were input, or what?
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

nina22
Member
Posts: 6
Joined: Sun Apr 19, 2009 2:00 am

Post by nina22 » Mon Apr 20, 2009 9:37 pm

recfm=fb, lrecl=40, last 15 bytes start in column 26

the file I displayed was the output on the sort I did incorrectly.

no matter where the 631 or 632 or 633 is in the last 15 bytes, I need the output to have all the 600 codes in ascending seq

nina22
Member
Posts: 6
Joined: Sun Apr 19, 2009 2:00 am

Post by nina22 » Mon Apr 20, 2009 9:38 pm

I don't care if the other codes OTHER than 631, 632 or 633 end up in the sorted file

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

Post by Frank Yaeger » Mon Apr 20, 2009 9:57 pm

Here's a DFSORT job that will do what I think you asked for:

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/40)
//SORTOUT DD DSN=...  output file (FB/40)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(26,3,SS,EQ,C'631,632,633'),OVERLAY=(41:26,3)),
    IFTHEN=(WHEN=(29,3,SS,EQ,C'631,632,633'),OVERLAY=(41:29,3)),
    IFTHEN=(WHEN=(32,3,SS,EQ,C'631,632,633'),OVERLAY=(41:32,3)),
    IFTHEN=(WHEN=(35,3,SS,EQ,C'631,632,633'),OVERLAY=(41:35,3)),
    IFTHEN=(WHEN=(38,3,SS,EQ,C'631,632,633'),OVERLAY=(41:38,3))
  OPTION EQUALS
  SORT FIELDS=(41,3,CH,A)
  OUTREC BUILD=(1,40)
/*
For your input example, SORTOUT will have:

Code: Select all

20090401C2009032620090413000000000631000     
20090401C2009032620090413000000631000000     
20090401C2009032620090413000000631000000     
20090401C2009032620090413000000631000000     
20090401C2009041520090417000000631000000     
20090401C2009041520090417000000631000000     
20090402C2009041520090417000000631000000     
20090401C2009041520090417000000631000000     
20090401C2009041520090417000000631000000     
20090401D2009040320090403000000041109632     
20090401C2009021420090414000000632000000     
20090401D2009040320090403000000041109633     
20090401C2009021420090414000000633000000     
20090401C2009041320090414000000633000000     
The 631 records are first, then the 632 records and then the 633 records. I kept duplicate records (e.g. all 631 records) in their original order.
I don't care if the other codes OTHER than 631, 632 or 633 end up in the sorted file
I couldn't figure out what you mean by this so I ignored it.
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

nina22
Member
Posts: 6
Joined: Sun Apr 19, 2009 2:00 am

Post by nina22 » Mon Apr 20, 2009 10:19 pm

Thank you. That is the result I wanted.

Sorry, I wasn't very clear....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 » Mon Apr 20, 2009 10:47 pm

Ok, good. Try to describe your requirement more clearly in your first post next time for a faster solution.
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

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