IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sort a file based on value of a particular record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pkg23

New User


Joined: 06 Dec 2007
Posts: 7
Location: India

PostPosted: Thu Dec 06, 2007 1:34 pm
Reply with quote

Hi,
I have a requirement to sort a group of record in according to a value in a particular record.

My input file is as below -

CN@@abcd$$
VW@@cfer$$
SEQ@@1001
DD@@100$$
CN@@xyz$$
CO@@mn$$
ST@@EA$$
SEQ@@1000
DD@@101$$
CN@@MN$$
AS@@EA$$
SEQ@@1002
DD@@102$$

The records from CN@@ to DD@@ belongs to one particular set. Each set Starts with CN@@ and ends with DD@@ and has only one SEQ@@ record with numeric value. Now, my requirement is to sort based on the value of SEQ@@ records such that the set CN@@ and DD @@ set is not disturbed.

The output file should look as below -
CN@@xyz$$
CO@@mn$$
ST@@EA$$
SEQ@@1000
DD@@101$$
CN@@abcd$$
VW@@cfer$$
SEQ@@1001
DD@@100$$
CN@@MN$$
AS@@EA$$
SEQ@@1002
DD@@102$$

Thanks
Prashant
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Dec 07, 2007 4:20 am
Reply with quote

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//**IN DD DSN=&&IN,DISP=(OLD,PASS)
//IN DD *
CN@@abcd$$
VW@@cfer$$
SEQ@@1001
DD@@100$$
CN@@xyz$$
CO@@mn$$
ST@@EA$$
SEQ@@1000
DD@@101$$
CN@@MN$$
AS@@EA$$
SEQ@@1002
DD@@102$$
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//T3 DD DSN=&&T3,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(85,8,ZD) -
  WITHALL WITH(1,80)
SORT FROM(T3) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'CN@@'),
                OVERLAY=(85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(93:SEQNUM,8,ZD,
                         85:85,8,ZD,SUB,93,8,ZD,TO=ZD,LENGTH=8))
  OUTFIL FNAMES=T1,INCLUDE=(1,5,CH,EQ,C'SEQ@@'),OVERLAY=(81:6,4)
  OUTFIL FNAMES=T2
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(81,4,CH,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
pkg23

New User


Joined: 06 Dec 2007
Posts: 7
Location: India

PostPosted: Tue Dec 11, 2007 10:43 am
Reply with quote

ICETOOL is not avaliable. ICEMAN is avaliable,How can we do this thru ICEMAN?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Dec 11, 2007 11:09 am
Reply with quote

Prasanth,

Quote:
ICETOOL is not avaliable. ICEMAN is avaliable,How can we do this thru ICEMAN?

Check which 'sort product' is installed at your site? If its a DFSORT, you can use ICETOOL.
Back to top
View user's profile Send private message
pkg23

New User


Joined: 06 Dec 2007
Posts: 7
Location: India

PostPosted: Tue Dec 11, 2007 6:05 pm
Reply with quote

For my understanding. Can you explain the CTL1CNTL as below step by step?

What is the function of SUB keyword ?

//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(85:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,4,CH,EQ,C'CN@@'),
OVERLAY=(85:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,
OVERLAY=(93:SEQNUM,8,ZD,
85:85,8,ZD,SUB,93,8,ZD,TO=ZD,LENGTH=8))
OUTFIL FNAMES=T1,INCLUDE=(1,5,CH,EQ,C'SEQ@@'),OVERLAY=(81:6,4)
OUTFIL FNAMES=T2


Thanks
Prashant
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Dec 12, 2007 12:50 am
Reply with quote

Quote:
ICETOOL is not avaliable. ICEMAN is avaliable,How can we do this thru ICEMAN?


If DFSORT is available, then DFSORT's ICETOOL is available. ICETOOL has been part of DFSORT since 1991.


SUB is the subtract function.

Quote:
Can you explain the CTL1CNTL as below step by step?


Code:

  INREC IFTHEN=(WHEN=INIT,OVERLAY=(85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'CN@@'),
                OVERLAY=(85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(93:SEQNUM,8,ZD,
                         85:85,8,ZD,SUB,93,8,ZD,TO=ZD,LENGTH=8))


This is a "trick" for adding a group number in positions 85-92. The first group of records starting with CN@@ will be given group number 1. The second group of records starting with CN@@ will be given group number 2. And so on. For more information on the group trick, see the "Include or omit groups of records" and "Sort groups of records" Smart DFSORT Tricks at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

Code:

  OUTFIL FNAMES=T1,INCLUDE=(1,5,CH,EQ,C'SEQ@@'),OVERLAY=(81:6,4)
  OUTFIL FNAMES=T2


The first OUTFIL statement copies the value in each SEQ@@ record to positions 81-84 and writes the reformatted records to T1.

The second OUTFIL statement writes the reformatted records to T2.

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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top