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.
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
AB 060335810106033581013----------
AC 0603358101100240000000000------
records in between.
Its not similar to your o/p....
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
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.
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
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.....
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'
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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:
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.