Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort a file based on value of a particular record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sort a file based on value of a particular record
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 Moderator


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

PostPosted: Fri Dec 07, 2007 4:20 am    Post subject:
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    Post subject: Reply to: Sort a file based on value of a particular record
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: 1439
Location: Bangalore,India

PostPosted: Tue Dec 11, 2007 11:09 am    Post subject:
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    Post subject: Reply to: Sort a file based on value of a particular record
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 Moderator


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

PostPosted: Wed Dec 12, 2007 12:50 am    Post subject:
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:

http://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:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us