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 required for two types of records in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Mon Nov 05, 2007 3:25 pm    Post subject: Sort required for two types of records in a file
Reply with quote

Hi,

I have two types of records in a file. AB and AC
AB should always be followed by AC.

I need to sort the records on the first 10 digits on both types of records such that the similar numbers at 15th position of AC record are also in sorted.

Below is the data in i/p file:
----+----1----+----2----+----3----+-
***************************** Top of
AB 040526370104052637013----------
AC 0405263701100230000000000
AB 060335810106033581013----------
AC 0603358101100240000000000------
AB 940157730194015773013----------
AC 9401577301100230000000000------


The expected o/p is

----+----1----+----2----+----3----+-
***************************** Top of
AB 040526370104052637013----------
AC 0405263701100230000000000
AB 940157730194015773013----------
AC 9401577301100230000000000------
AB 060335810106033581013----------
AC 0603358101100240000000000------

But unable to get the sortout in the expected way.

Please do help me with this.

Thanks,
Rosmi.
Back to top
View user's profile Send private message

krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Nov 05, 2007 4:28 pm    Post subject:
Reply with quote

rosmi joseph
This SORT JCL does the sorting as per your requirement
Code:
//*******************************************************               
//STEP1    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
AB 040526370104052637013----------                                     
AC 0405263701100230000000000                                           
AB 060335810106033581013----------                                     
AC 0603358101100240000000000------                                     
AC 940157730194015773013----------                                     
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
AB 9401577301100230000000000------                                     
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'AB'),                                 
                OVERLAY=(81:SEQNUM,8,ZD)),                             
        IFTHEN=(WHEN=(1,2,CH,EQ,C'AC'),                                 
                OVERLAY=(81:SEQNUM,8,ZD))                               
           SORT FIELDS=(81,8,CH,A,1,2,CH,A,4,10,ZD,A)                   
  OUTREC FIELDS=(1,80)                                                 
/*                                                                     
                                                                 


SORTOUT
Code:
AB 040526370104052637013----------                                             
AC 0405263701100230000000000                                                   
AB 060335810106033581013----------                                             
AC 0603358101100240000000000------                                             
AB 9401577301100230000000000------                                             
AC 940157730194015773013----------                                             


OR
This SORT card also works, for the i/p you have shown
Code:
//SYSIN    DD *                                                         
  SORT FIELDS=(4,10,ZD,A,1,2,CH,A)                                     
/*                                                                     
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Nov 05, 2007 4:37 pm    Post subject:
Reply with quote

oops icon_redface.gif
i have got the
Code:
AB 060335810106033581013----------                                             
AC 0603358101100240000000000------                                             
records in between.
Its not similar to your o/p.... icon_eek.gif


Quote:
I need to sort the records on the first 10 digits on both types of records such that the similar numbers at 15th position of AC record are also in sorted.
Please clarify this quote, also put your sample records within the CODE tags for better understanding
Back to top
View user's profile Send private message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Mon Nov 05, 2007 8:12 pm    Post subject:
Reply with quote

Hi,

Thanks for the response.

But as you pointed out my output is expected in a diff way.


Here, AB and AC records have the first 10 digits similar. But the 15th digit of AC records vary from the respective AB records.

ie,
For first AB, AC combination the value in AC 15th pos is '100230000000000'

For second AB, AC combination the value in AC 15th pos is '100240000000000'

For third AB, AC combination the value in AC 15th pos is '100230000000000'.

Now i need the output such that this value in the AC record at 15th pos is in sorted order for all AB, AC combinations.

ie,
----+----1----+----2----+----3----+-
***************************** Top of
AB 040526370104052637013----------
AC 0405263701100230000000000
AB 940157730194015773013----------
AC 9401577301100230000000000------
AB 060335810106033581013----------
AC 0603358101100240000000000------

I tried many combinations to get the o/p. But it didnt help.
Please help me.

Thanks,
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Nov 05, 2007 8:27 pm    Post subject: Re: Sort required for two types of records in a file
Reply with quote

rosmi joseph wrote:
I have two types of records in a file. AB and AC
AB should always be followed by AC.

I need to sort the records on the first 10 digits on both types of records such that the similar numbers at 15th position of AC record are also in sorted.

Below is the data in i/p file:
Code:
----+----1----+----2----+----3----+-
***************************** Top of
AB  040526370104052637013----------
AC  0405263701100230000000000       
AB  060335810106033581013----------
AC  0603358101100240000000000------
AB  940157730194015773013----------
AC  9401577301100230000000000------

The expected o/p is
Code:
----+----1----+----2----+----3----+-
***************************** Top of
AB  040526370104052637013----------
AC  0405263701100230000000000       
AB  940157730194015773013----------
AC  9401577301100230000000000------
AB  060335810106033581013----------
AC  0603358101100240000000000------

But unable to get the sortout in the expected way.
If I understand...
if you join the AB & AC on the 'first 10 digits' key (always only one AB to match one AC?),
sort on the '15th position' key followed by the 'first 10 digits' key
and split them appart (first the AB then the AC) in output,
you should have what you need.....
Back to top
View user's profile Send private message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Mon Nov 05, 2007 8:36 pm    Post subject:
Reply with quote

Hi CICS guy,

For the input i have mentioned only one AC will match with an AB.

You have mentioned
' if you join the AB & AC on the 'first 10 digits' key (always only one AB to match one AC?), sort on the '15th position' key followed by the 'first 10 digits' key and split them appart (first the AB then the AC) in output,
you should have what you need'

Could you please clarify.

Thanks.
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: Mon Nov 05, 2007 11:26 pm    Post subject:
Reply with quote

rosmi joseph,

So you want each AB/AC pair with the same value in positions 5-14 to be sorted accordingly to the value in positions 15-29 of the AC record - right?

What is the RECFM and LRECL of your input file?
Back to top
View user's profile Send private message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Tue Nov 06, 2007 8:17 am    Post subject:
Reply with quote

Yeah right...

That is what i want.
Record format is VB and record length is 342.

Thanks.
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 Nov 07, 2007 12:45 am    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (VB/342)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (VB/342)
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(24,10,CH) VLENOVLY KEEPBASE -
  WITH(20,338)
SORT FROM(T2) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  SORT FIELDS=(9,10,CH,A,5,2,CH,D)
  OUTREC IFTHEN=(WHEN=(5,2,CH,EQ,C'AC'),
    BUILD=(1,4,5:19,15,20:5)),
   IFTHEN=(WHEN=(5,2,CH,EQ,C'AB'),
    BUILD=(1,4,20:5))
/*
//CTL2CNTL DD *
  SORT FIELDS=(5,15,CH,A,24,10,CH,A,20,2,CH,A)
  OUTREC BUILD=(1,4,5:20)
/*
Back to top
View user's profile Send private message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Wed Nov 07, 2007 5:21 pm    Post subject:
Reply with quote

Thanks a lot for the method.
But could you let me know the processing that is done here.

SORT FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(24,10,CH) VLENOVLY KEEPBASE -
WITH(20,338)
SORT FROM(T2) TO(OUT) USING(CTL2)

Can you please explain the way the sort is done.

I have never worked on ICETOOL.

Thanks.
Back to top
View user's profile Send private message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Wed Nov 07, 2007 6:23 pm    Post subject:
Reply with quote

Hi Frank Yaeger,

I had some more queries.

Can we have T1 and T2 as permenant datasets with DISP= (NEW, CATLG, DELETE)?

I tried giving the same and it gave return code 16.

Kindly let me know.

Thanks.
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 Nov 07, 2007 10:12 pm    Post subject:
Reply with quote

Quote:
Can we have T1 and T2 as permenant datasets with DISP= (NEW, CATLG, DELETE)?


Yes, but they must have the correct attributes (RECFM=VB, LRECL=357). If you use NEW data sets without specifying any attributes, DFSORT will set the attributes correctly automatically. If you use OLD data sets with the wrong attributes, you will get an error.

Quote:
I tried giving the same and it gave return code 16.


If the problem isn't the attributes as described above, then another possibility is that your site has changed the SOLRF=YES default to SOLRF=NO. In that case, you can set SOLRF=YES for the job using:

Code:

//DFSPARM DD *
   OPTION SOLRF
/*


If it's not one of those problems, then you need to show me the //TOOLMSG and //DFSMSG messages.

Quote:
Can you please explain the way the sort is done.


You can read all about DFSORT and DFSORT's ICETOOL in "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

For complete details on DFSORT's ICETOOL, see:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/6.0?DT=20060615185603
Back to top
View user's profile Send private message
rosmi joseph

New User


Joined: 17 Sep 2007
Posts: 68
Location: Kochi

PostPosted: Thu Nov 08, 2007 10:45 am    Post subject:
Reply with quote

Hi,

Thanks a lot for the help.
My actual data was different from the data specified here.
However, the scenario was similar. I was able to incorporate the logic in my file and it is working fine.

Special thanks to Frank Yaeger for his idea and tips.

Thanks.
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 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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