|
View previous topic :: View next topic
|
| Author |
Message |
Sysaron
New User

Joined: 28 Sep 2005 Posts: 55 Location: USA
|
|
|
|
Hello All,
I was wondering if you could help me set up a sort step where I would not have to reset the condition every year.
Right now I have a file with records with both years 2011 and 2012 (these values are in the data). I can easily separate those into two files right now.
But, next year I will have records with data of 2012 and 2013, and the following year 2013 and 2014.
Is there a way to create a sort that will write two separate files based on the year (data) and I won't have to revise the sysin every year with the specific years that need to be sorted out?
Thank you very much for all your advice!!
Sharon |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Ummmm - as usual - show us some sample data including the positions, formats and lengths of the two fields, tell us the lrecl and recfm, and show us the expected output. Yes, I know that the output is going to be the same as the input but with both years incremented by one. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Sysaron,
Use the following DFSORT Which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
2012 FILE-1
2012 FILE-1
2012 FILE-1
2013 FILE-2
2013 FILE-2
2014 DROP
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(81:DATE1,81,8,Y4T,ADDYEARS,+1,TOGREG=Y4T)
OUTFIL FNAMES=OUT1,BUILD=(1,80),INCLUDE=(1,4,CH,EQ,81,4,CH)
OUTFIL FNAMES=OUT2,BUILD=(1,80),INCLUDE=(1,4,CH,EQ,89,4,CH)
//* |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's another way to do this with DFSORT using the system symbol for the current year:
| Code: |
//STEP0100 EXEC PGM=SORT
//SYMNAMES DD *
CURYR,S'&LYR4'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
2012 FILE-1
2012 FILE-1
2012 FILE-1
2013 FILE-2
2013 FILE-2
2014 DROP
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(81:CURYR,81:81,4,ZD,ADD,+1,EDIT=(TTTT))
OUTFIL FNAMES=OUT1,BUILD=(1,80),INCLUDE=(1,4,CH,EQ,CURYR)
OUTFIL FNAMES=OUT2,BUILD=(1,80),INCLUDE=(1,4,CH,EQ,81,4,CH)
//*
|
|
|
| Back to top |
|
 |
Sysaron
New User

Joined: 28 Sep 2005 Posts: 55 Location: USA
|
|
|
|
Hello again everyone!
Thank you so much for all your advice. It is obvious to me though, that I should have been more precise about my situation.
Here is the file layout of my 57 character length file. The first 2 bytes are the year shown as 11 or 12. I have to put the 11's in one file and the 12's in another. Next year the 12's in one file and 13's in another.
EDIT SYSTC.ADD.EXTRACT.TEST Columns 00001 00057
Command ===> Scroll ===> CSR
****** ***************************** Top of Data 110103054000000303520111105000000045000000000000020120330
110150003000011358720110806000006815000000000000020120330
110150005000000000020110806000000000000000000000020120330
120150006000010974920110806000006584000000000000020120330
120150012000022387920120121000013432000000000000020120330
120150013000004085020120121000002451000000000000020120330
Based on the info I received, I tried this SYSIN without good results.
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(58:DATE1,58,8,Y4T,ADDYEARS,+1,TOGREG=Y4T)
OUTFIL FNAMES=OUT1,BUILD=(1,57),INCLUDE=(1,2,CH,EQ,58,2,CH)
OUTFIL FNAMES=OUT2,BUILD=(1,57),INCLUDE=(1,2,CH,EQ,60,2,CH)
/*
Thanks again for your patience and understanding |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you need year minus one and current year, does subtracting instead of adding help you for this year?
What you haven't told is is the year with which you want to run the data. If you have 11 and 12 in the data, do you always run with 12? Same situation in future years? I think the subtract should work.
If not, what are the rules for the "current year" when you run? |
|
| Back to top |
|
 |
Sysaron
New User

Joined: 28 Sep 2005 Posts: 55 Location: USA
|
|
|
|
Hi Bill,
You are right. This year I run with 12's and the old year 11's.
Next Year with 13's and the old year 12's.
I tried using subtraction, but my problem is that I'm not familiar with the overlay reserved words. Could you please help me with the overlay? I have this now.
SORT FIELDS=COPY
INREC OVERLAY=(58:DATE1,58,8,Y4T,ADDYEARS,-1,TOGREG=Y4T)
OUTFIL FNAMES=OUT1,BUILD=(1,57),INCLUDE=(1,2,CH,EQ,58,2,CH)
OUTFIL FNAMES=OUT2,BUILD=(1,57),INCLUDE=(1,2,CH,EQ,60,2,CH) |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
sysaron,
You got the include condition wrong. Use the following DFSORT JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYMNAMES DD *
CURYR,S'&LYR4'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+----6-
110150003000011358720110806000006815000000000000020120330
110150005000000000020110806000000000000000000000020120330
120150006000010974920110806000006584000000000000020120330
120150012000022387920120121000013432000000000000020120330
120150013000004085020120121000002451000000000000020120330
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(58:CURYR,58,4,ZD,SUB,+1,EDIT=(TTTT))
OUTFIL FNAMES=OUT1,BUILD=(1,57),INCLUDE=(1,2,CH,EQ,60,2,CH)
OUTFIL FNAMES=OUT2,BUILD=(1,57),INCLUDE=(1,2,CH,EQ,64,2,CH)
//* |
|
|
| Back to top |
|
 |
Sysaron
New User

Joined: 28 Sep 2005 Posts: 55 Location: USA
|
|
|
|
It worked Perfectly Skolusu !!!!
Thank you Thank you Thank you Sooooooo Much !!!!!!!! |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
For the record, you can also do this with the symbols method like this:
| Code: |
//STEP0100 EXEC PGM=SORT
//SYMNAMES DD *
CURYR2,S'&LYR2'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
110150003000011358720110806000006815000000000000020120330
110150005000000000020110806000000000000000000000020120330
120150006000010974920110806000006584000000000000020120330
120150012000022387920120121000013432000000000000020120330
120150013000004085020120121000002451000000000000020120330
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(81:CURYR2,81:81,2,ZD,SUB,+1,EDIT=(TT))
OUTFIL FNAMES=OUT1,BUILD=(1,80),INCLUDE=(1,2,CH,EQ,CURYR2)
OUTFIL FNAMES=OUT2,BUILD=(1,80),INCLUDE=(1,2,CH,EQ,81,2,CH)
//*
|
Of course, this will only work correctly until 2099.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|