View previous topic :: View next topic
|
Author |
Message |
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
I have an input file with the following data
field1, 2004
field1, 2005
field1, 2006
field1, 2007
field1, 2008
I need to move all the data < 2007 i.e 2004, 2005 and 2006 into file1 and 2008 data into file2. How can I achieve this using syncsort? next year i will have to move data < 2008 into file1.
How can I create this dynamically using the sort? Also let me know how this can be accomplished if the year in character or PD mode? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
itmanand,
Welcome to the forums.
SyncSort questions are discussed in the JCL part of the forum and NOT in DFSORT forum. Please keep this in mind for your future posts. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
itmanand,
What is the input year format? Is it PD or CH? Please post the actual date format with relevant field positions. |
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
Input is in PD. Let me know how you do that even if it's in Char.
Only the year part is present in the Input. |
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
The year in my file is present in the PD format..This is the sample data
field1,07D8
field1,07D4
field1,07D7
field1,07D6
field1,07D8
Here 07D8 is the PD value for 2008.
07D4 - 2004
07D7 - 2007
07D6 - 2006
I want to move all the data less than 2007(07D7) to file1 and the rest to file2.
This should happen for the next year ie when year is 2009(07D9), I want to move all the data less than 2008(07D8) to file1.
Please help me on this. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Those are not PD (packed decimal) values - they are binary. . .
You can do what you want using OUTFIL - i'm not connected, so this is only a guideline, not something that is tested. . .
Code: |
OPTION COPY
OUTFIL FNAMES=OUT1,
INCLUDE=(s,l,BI,LT,2007)
OUTFIL FNAMES=OUT2,
INCLUDE=(s,l,BI,GE,2007)
|
You'll need DD statements for the 2 output files. |
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
Thanks. However the I do not want to change my sort card for the next year and would like to have a dynamic year. Can you please let me know how this can be done? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
You could consider generating the needed "sort cards".
No matter how you do it, somehow the "key" year needs to be entered or computed.
If this were run next month (Jan) and the "key" was still 2007, how would some code know whether to subtract 1 or 2 from 2009 to get the key? |
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
I will run this only once a year.so it will always be current year - 2.
Can you please help? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
I will run this only once a year.so it will always be current year - 2. |
Now this statement has made me confused. This was my understanding. If this is not what you are trying to achieve, please explain further with all possible combinations of input.
* You have a file with an year field (YYYY format) in binary.
* Extract all the records with year < (current year-1) into file1
* Extract all the records with year = current year into file2
* And by doing the above you are ignoring the data for year = current year-1. |
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
only change is current year -2. rest everything is the same. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
itmanand,
I assumed FB files of LRECL=80 and the binary date field(yyyy) at pos-8,length-2. You can modify it as per your needs.
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN= Input file, FB/LRECL=80
//OUT1 DD DSN= Output file-1, FB/LRECL=80
//OUT2 DD DSN= Output file-2, FB/LRECL=80
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:&DATE2)),
IFTHEN=(WHEN=INIT,BUILD=(1,80,87:81,4,ZD,SUB,8,2,BI,M11))
SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,INCLUDE=(87,15,ZD,GT,2),BUILD=(1,80)
OUTFIL FNAMES=OUT2,INCLUDE=(87,15,ZD,EQ,0),BUILD=(1,80)
/* |
Input
Code: |
7/AN 2/BI
(1-7) (8-9)
1------- 2-------
field1, 2004
field1, 2005
field1, 2006
field1, 2007
field1, 2008
|
OUT1
Code: |
7/AN 2/BI
(1-7) (8-9)
1------- 2-------
field1, 2004
field1, 2005 |
OUT2
Code: |
7/AN 2/BI
(1-7) (8-9)
1------- 2-------
field1, 2008
|
|
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
Thanks Arun. I have one question. How does this work and also if I want all year - 2 records in file1 and all other records in file2, how do I modify this?
ie
2004
2005
2006
are in file1
and 2007 and 2008 in file2 and also what is M11? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
itmanand wrote: |
I want all year - 2 records in file1 and all other records in file2 |
Now this is a deviation from what you agreed upon earlier.
itmanand wrote: |
only change is current year -2. rest everything is the same. |
Can you answer these questions before we proceed any further?
1) Input and output RECFM/LRECL?
2) position of date-field?
3) data in file-1 . is this year<current year-2 ?
3) data in file-2 . is this year=current year or just the remaining records.? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
Here x'07D8' is the PD value for 2008.
x'07D8' - 2008
x'07D4' - 2004
x'07D7' - 2007
x'07D6' - 2006 |
a friendly advice... review Your understanding of number representation
the samples You posted are not PD ( packed decimal ) values,
they are binary ( halfword ) values
the PD representation would be
Quote: |
x'00 02 00 8C' - 2008
x'00 02 00 4C' - 2004
x'00 02 00 7C' - 2007
x'00 02 00 6C' - 2006 |
|
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
Arun,
My replies below.
) Input and output RECFM/LRECL?
Anand >> 80
2) position of date-field?
Anand >> 13
3) data in file-1 . is this year<current year-2 ?
Anand >> Yes
4) data in file-2 . is this year=current year or just the remaining records.?
Anand >> All the remaining records. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Anand,
You can achieve this using the below SyncSort job. I have included a few future years to have a better test.
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN= Input File FB/LRECL=80
//OUT1 DD DSN= Output file1 FB/LRECL=80
//OUT2 DD DSN= Output file2 FB/LRECL=80
//SYSIN DD *
INREC OVERLAY=(81:&DATE2,87:81,4,ZD,SUB,+2,BI,LENGTH=2)
SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,INCLUDE=(13,2,BI,LT,87,2,BI),BUILD=(1,80)
OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80) |
Input
Code: |
12/AN 2/BI
(1-12) (13-14)
1----------- 2-------
field1, 2004
field1, 2003
field1, 2005
field1, 2006
field1, 2007
field1, 2008
field1, 2012
field1, 2009 |
OUT1
Code: |
(1-12) (13-14)
1----------- 2-------
field1, 2004
field1, 2003
field1, 2005 |
OUT2
Code: |
12/AN 2/BI
(1-12) (13-14)
1----------- 2-------
field1, 2006
field1, 2007
field1, 2008
field1, 2012
field1, 2009 |
|
|
Back to top |
|
|
itmanand
New User
Joined: 18 Dec 2008 Posts: 24 Location: Newyork
|
|
|
|
Thanks Arun. This works. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Anand,
You're welcome. |
|
Back to top |
|
|
|