|
View previous topic :: View next topic
|
| Author |
Message |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Say input file is :
ADMIN DATE
123 20100501
123 20100501
123 20100501
123 20100501
124 20100501
124 20100501
124 20100501
127 20100502
127 20100502
127 20100502
I have to sort on admin and date and do a sort sum such that
the expected output file must be :
123 on 20100501 = 4
124 on 20100501 = 3
127 on 20100502 = 3 |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
techslam,
Assuming that the data is already sorted on admin and date field , the following DFSORT JCL will give you the desired results. If the data is not sorted change SORT FIELDS=COPY to SORT FIELDS=(1,12,CH,A)
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123 20100501
123 20100501
123 20100501
123 20100501
124 20100501
124 20100501
124 20100501
127 20100502
127 20100502
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
127 20100502
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,12,TRAILER3=(1,3,' ON ',5,8,' = ',COUNT=(M10,LENGTH=3)))
//* |
The output of this job is
| Code: |
123 ON 20100501 = 4
124 ON 20100501 = 3
127 ON 20100502 = 3
|
|
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Thanks Skolusu,
Actually i have an input file whose LRECL = 4508.
Admin starts from 1 and length is 9
Date starts from 4501 and length is 8
So in this case how do I code the sort card.
I tried following, but I am getting abend :
| Code: |
//SYSIN DD *
SORT FIELDS=(1,9,4501,4508,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,4508,
TRAILER3=(1,9,' ON ',4501,4508,' = ',COUNT=(M10,LENGTH=9)))
//*
|
Kindly advice. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
techslam,
Use the following control cards which would create a 30 byte output file
| Code: |
//SYSIN DD *
INREC BUILD=(1,9,4501,8)
SORT FIELDS=(1,17,CH,A)
OUTFIL REMOVECC,NODETAIL,BUILD=(30X),
SECTIONS=(1,17,
TRAILER3=(1,9,' ON ',10,8,' = ',COUNT=(M10,LENGTH=6)))
//* |
|
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Thanks a lot Skolusu,
I have modified it according to my requirement and it worked fine.
| Code: |
//SYSIN DD *
INREC BUILD=(1,9,4414,1,4443,1,4501,8)
SORT FIELDS=(1,9,CH,A,10,1,CH,A,11,1,CH,A,12,8,CH,A)
OUTFIL REMOVECC,NODETAIL,BUILD=(30X),
SECTIONS=(1,19,
TRAILER3=(1,9,' ON ',12,8,' = ',COUNT=(M10,LENGTH=6)))
//*
|
|
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
| I can see, you have moved the required fields to a different file and then sorted it from there and performed the count from there. What will be my code, if I want to view that sorted file with required fields? |
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hi
I have used the latest sort control statements given here by Skolusu.
It works fine for a small test file will less number of records,
But when I gave the original input file which has 1250000 records in it, there is issue in the out put file generated :
| Code: |
123456789 ON 20100701 = 2
123456789 ON 20100707 = 2006
123456789 ON 20100702 = 14
123456789 ON 20100706 = 2
123456789 ON 20100701 = 4
|
here for the date 20100701 there are two counts, 2 and 4, it should have been
| Code: |
123456789 ON 20100701 = 6
|
What is causing this issue to occur ?
It happens with many admin id's in the file.
Please advice.... |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| techslam wrote: |
Hi
I have used the latest sort control statements given here by Skolusu.
It works fine for a small test file will less number of records,
But when I gave the original input file which has 1250000 records in it, there is issue in the out put file generated : |
NO. You did not use the same control cards as I have shown as you added 2 more fields from pos 4414 for 1 byte and from position 4443 for 1 byte. These 2 bytes are also used in the control break processing and hence the wrong results. I used 17 bytes for key break where as you used 19 bytes for the key break. Please don't attribute your mistakes as mine.
| techslam wrote: |
| I can see, you have moved the required fields to a different file and then sorted it from there and performed the count from there. What will be my code, if I want to view that sorted file with required fields? |
I can't keep working on the same requirement over and over whenever you change the requirements. You need to do a better job of explaining the complete requirement in one go rather than in bits and pieces. |
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hi Skolusu,
I appreciate you helping me out in this requirement and I apologise for making changes in my requirements. I have worked on your code and now I am getting the desired output the way I wanted . It is given below
| Code: |
123456789 XP 20100701 2
123456789 XP 20100707 2006
123456789 XP 20100702 14
123456789 XP 20100706 2
123456789 YP 20100701 4
|
Everything looks fine here, I just need one final thing, I have made the counter of length 9 bytes and I want the counter output appended with zeros rather than spaces.
that is :
| Code: |
123456789 XP 20100701 000000002
123456789 XP 20100707 000002006
123456789 XP 20100702 000000014
123456789 XP 20100706 000000002
123456789 YP 20100701 000000004
|
Kindly advice. I really appreciate this help through this forums.
Thanks a lot. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Thanks a lot Skolusu and Frank ,
I got my desired output.
Iam a newbie to DFSORT, so I really appreciate all the help provided here.
Getting Started DFSORT and DFSORT Application programming guide are awesome documents and I am reading them to get good knowledge.
Thanks a ton. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|