Need Sort JCL

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
ujwal.borkar
Member
Posts: 7
Joined: Fri Jun 17, 2011 3:25 pm

Need Sort JCL

Post by ujwal.borkar » Thu Nov 10, 2011 4:09 pm

Hi

I have a file with certain recods in it as below. I want to extract the 2 records where B is immidiate after A .
As indicated by arrow. B is after A so I have to write those 2 records in different file.
Is this possible using SORT JCL?


A
C
D
E
R
F
B
A -->
B -->
C
X
X
z
A
M
C
B

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 Nov 11, 2011 1:31 am

Will there only be one occurrence of A followed by B, or could there be more? If more, do you want all of the A followed by B pairs of records in the output data set or just the first pair?

What is the RECFM and LRECL of your input file?
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

ujwal.borkar
Member
Posts: 7
Joined: Fri Jun 17, 2011 3:25 pm

Post by ujwal.borkar » Fri Nov 11, 2011 3:54 pm

Hi Frank,

There can be multiple occurrence of A followed by B. I want all such records in output file.

Record Format = FB
Record Length = 80

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 Nov 11, 2011 11:23 pm

You can use a DFSORT job like the following to do what you asked for:

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),
    RECORDS=2,PUSH=(81:1,80))
  OUTFIL INCLUDE=(1,1,CH,EQ,C'B',AND,81,1,CH,EQ,C'A'),
    BUILD=(81,80,/,1,80)
/*
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

ujwal.borkar
Member
Posts: 7
Joined: Fri Jun 17, 2011 3:25 pm

Post by ujwal.borkar » Mon Nov 14, 2011 3:00 pm

Dear Frank,

Thanks for your reply. Could you please explain each terminology in SORT how it works?


Regards
Ujwal Borkar

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 Nov 14, 2011 11:57 pm

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
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

ujwal.borkar
Member
Posts: 7
Joined: Fri Jun 17, 2011 3:25 pm

Post by ujwal.borkar » Tue Nov 15, 2011 11:39 am

Dear Frank thanks for the reference book.

In actual my file is like below

Command ===> Scrol
----+----1----+----2----+----3----+----4----+----5----+----6----+---
********************************* Top of Data **********************
FDR009530348357051111 301S1051111000000000 -----> FDR Record
10580511 XC003360847 55
0980808082 00106142CA000006865 CM
8978979796 00106143CA000003943 CV
ZZ006949776 ------>ZZ record
FDR009530348358051111 301S1051111000000000
ZZ000000000
FDR009530348359051111 301S1051111000000000
13940511 XC002288177 55
7896987800 00139401CA000010010 CZ
8979789727 00139402CA000001011 CX
8980800898 00139666CA000003090 CX
6868990897 00139667CA000024468 CX
ZZ005587694
FDR009530348360051111 301S1051111000000000
ZZ000520773



Here FDR comes in 1st position and ZZ record comes in 38th Position.

I want to find out all such records where ZZ is followed by FDR records.

With ref to your SORT, I have used below SORT card

//SORTIN DD DSN=ZPRACE2.SSTD.RPAYB01.MERGED.G4089,DISP=SHR
//SORTOUT DD DSN=ZPRACE2.SSTD.RPAYB01.MERGED.G4089.OUT,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(150,110),RLSE),
// LRECL=80,RECFM=FB,AVGREC=K
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'FDR'),
RECORDS=2,PUSH=(81:3,80))
OUTFIL INCLUDE=(38,2,CH,EQ,C'ZZ',AND,81,3,CH,EQ,C'FDR'),
BUILD=(81,80,/,3,80)
/*


This is not working. Caould you please help ?

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

Post by Frank Yaeger » Tue Nov 15, 2011 11:30 pm

If you want the records where ZZ is followed by FDR, then you have the logic backwards. Here's the DFSORT job you need:

Code: Select all

//S1 EXEC PGM=SORT 
//SYSOUT DD SYSOUT=* 
//SORTIN DD DSN=...  input file (FB/80) 
//SORTOUT DD DSN=...  output file (FB/80) 
//SYSIN DD * 
  OPTION COPY                                                
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(38,2,CH,EQ,C'ZZ'),         
    RECORDS=2,PUSH=(81:1,80))                                
  OUTFIL INCLUDE=(1,1,CH,EQ,C'FDR',AND,118,2,CH,EQ,C'ZZ'),   
    BUILD=(81,80,/,1,80)                                     
/* 
For your input example, SORTOUT would have:

Code: Select all

                                     ZZ006949776   
FDR009530348358051111 301S1051111000000000         
                                     ZZ000000000   
FDR009530348359051111 301S1051111000000000         
                                     ZZ005587694   
FDR009530348360051111 301S1051111000000000         
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

ujwal.borkar
Member
Posts: 7
Joined: Fri Jun 17, 2011 3:25 pm

Post by ujwal.borkar » Wed Nov 16, 2011 5:18 pm

Dear Frank, Thanks for your reply.

But I am expecting a output where ZZ record comes immidiate after FDR record.

So Output file should look like as below

FDR009530348358051111 301S1051111000000000
ZZ000000000
FDR009530348360051111 301S1051111000000000
ZZ000520773

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 Nov 16, 2011 11:15 pm

I want to find out all such records where ZZ is followed by FDR records.

But I am expecting a output where ZZ record comes immidiate after FDR record.
These statements are exact opposites. Please try a little harder to state your requirement clearly the first time.

I would have thought you could work out the details yourself from the given example, but here are the DFSORT control statements for FDR followed by ZZ:

Code: Select all

  OPTION COPY                                                
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'FDR'),         
    RECORDS=2,PUSH=(81:1,80))                                
  OUTFIL INCLUDE=(81,3,CH,EQ,C'FDR',AND,38,2,CH,EQ,C'ZZ'),   
    BUILD=(81,80,/,1,80)                                     
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