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
 

 

SYNCSORT - Sort based on year

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Thu Dec 18, 2008 11:42 pm    Post subject: SYNCSORT - Sort based on year
Reply with quote

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
View user's profile Send private message

Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Thu Dec 18, 2008 11:53 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Dec 19, 2008 12:04 am    Post subject:
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 3:01 am    Post subject: Reply to: Sort based on year
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 8:16 am    Post subject: Reply to: SYNCSORT - Sort based on year
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 19, 2008 8:31 am    Post subject:
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 8:36 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 19, 2008 9:02 am    Post subject:
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 9:21 am    Post subject:
Reply with quote

I will run this only once a year.so it will always be current year - 2.
Can you please help?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Dec 19, 2008 10:01 am    Post subject:
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 10:35 am    Post subject:
Reply with quote

only change is current year -2. rest everything is the same.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Dec 19, 2008 11:16 am    Post subject:
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 11:28 am    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Dec 19, 2008 12:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Dec 19, 2008 2:20 pm    Post subject: Reply to: SYNCSORT - Sort based on year
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Fri Dec 19, 2008 7:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Dec 19, 2008 8:18 pm    Post subject:
Reply with quote

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
View user's profile Send private message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Mon Dec 22, 2008 9:10 am    Post subject:
Reply with quote

Thanks Arun. This works.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Mon Dec 22, 2008 9:25 am    Post subject:
Reply with quote

Anand,

You're welcome.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts Wishing everyone a very Happy Diwali ... Rohit Umarjikar General Talk & Fun Stuff 1 Sat Oct 29, 2016 1:54 am


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