|
View previous topic :: View next topic
|
| Author |
Message |
Ariharan S
New User
Joined: 20 Feb 2011 Posts: 6 Location: Chennai
|
|
|
|
A file is of below layout,
Name
Id Type
Effective Date
Id Val
I need to select only records whose effective date is recent for a partuclar Name+ID_Type combination
IF input is this,
ABC ID1 2001-08-25 XXXXX
ABC ID1 2005-04-30 YYYYYY
ABC ID2 1987-08-25 123456
ABC ID2 2011-09-21 123789
ABC ID2 2003-04-25 123456
ABC ID3 2005-04-30 FFFFFFF
DEF ID3 2005-04-30 FFF333
OUTPUT MUST BE,
ABC ID1 2005-04-30 YYYYYY
ABC ID2 2011-09-21 123789
ABC ID3 2005-04-30 FFFFFFF
DEF ID3 2005-04-30 FFF333 |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
| Quote: |
| I need to use JCL sort to select only records whose effective date is recent |
 |
|
| Back to top |
|
 |
THINKSRINIII Warnings : 1 New User
.jpg)
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Use this:
Since you have not mentioed the LRECL, I assumed it to be 39 and file format to be FB.
| Code: |
//SYSIN DD *
SORT FIELDS=(1,7,CH,A,8,10,CH,D)
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(40:SEQ=2))
OUTFIL INCLUDE=(40,2,CH,EQ,C'01'),BUILD=(1,39)
|
|
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
| THINKSRINIII wrote: |
Use this:
Since you have not mentioed the LRECL, I assumed it to be 39 and file format to be FB.
| Code: |
//SYSIN DD *
SORT FIELDS=(1,7,CH,A,8,10,CH,D)
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(40:SEQ=2))
OUTFIL INCLUDE=(40,2,CH,EQ,C'01'),BUILD=(1,39)
|
|
It MUST be Psychic day !!
How did you manage to know what exactly "recent" means to the TS ??
Garry. |
|
| Back to top |
|
 |
Ariharan S
New User
Joined: 20 Feb 2011 Posts: 6 Location: Chennai
|
|
|
|
| Will this work with Syncsort |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
| Ariharan S wrote: |
| Will this work with Syncsort |
No, it won't. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
| Quote: |
| Will this work with Syncsort |
faster to try than ask on a forum |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
The syntax provided will not work with Syncsort. Syncsort does however support WHEN=GROUP.
Sugtgest you read about BEGIN instead of KEYBEGIN (i've never done this, but this is in the manual). |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
This will work with Syncsort:
| Code: |
//STEP0001 EXEC PGM=SYNCSORT
//SORTIN DD *
ABC ID1 2001-08-25 XXXXX
ABC ID1 2005-04-30 YYYYYY
ABC ID2 1987-08-25 123456
ABC ID2 2011-09-21 123789
ABC ID2 2003-04-25 123456
ABC ID3 2005-04-30 FFFFFFF
DEF ID3 2005-04-30 FFF333
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,7,CH,A,9,10,CH,D)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7)))
OUTFIL INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)
/*
|
|
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
I'm with Enrico and Garry, what is "recent"?  |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
The topic subject: Syncsort Sorting & Eliminating Old Records
| Quote: |
| I'm with Enrico and Garry, what is "recent"? |
I guess recent is "not old" - whatever "old" means
Been one of those days. . .
d |
|
| Back to top |
|
 |
Ariharan S
New User
Joined: 20 Feb 2011 Posts: 6 Location: Chennai
|
|
|
|
| Ariharan S wrote: |
A file is of below layout,
Name
Id Type
Effective Date
Id Val
I need to select only records whose effective date is recent for a partuclar Name+ID_Type combination
|
Recent means,
latest Effective Date (Eg: if 1980-01-01 & 2010-01-01 are there, then 2010-01-01 shud be selected) |
|
| Back to top |
|
 |
Ariharan S
New User
Joined: 20 Feb 2011 Posts: 6 Location: Chennai
|
|
|
|
| superk wrote: |
This will work with Syncsort:
| Code: |
//STEP0001 EXEC PGM=SYNCSORT
//SORTIN DD *
ABC ID1 2001-08-25 XXXXX
ABC ID1 2005-04-30 YYYYYY
ABC ID2 1987-08-25 123456
ABC ID2 2011-09-21 123789
ABC ID2 2003-04-25 123456
ABC ID3 2005-04-30 FFFFFFF
DEF ID3 2005-04-30 FFF333
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,7,CH,A,9,10,CH,D)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,7)))
OUTFIL INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)
/*
|
|
Thanks a lot superk!
It works!!!
Can anyone refer any materials related to SYNCSORT, which can be used by beginners for learning? |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| Ariharan S wrote: |
| Can anyone refer any materials related to SYNCSORT, which can be used by beginners for learning? |
Documenation on products from SyncSort is covered under Copyright Act and can not be linked via a forum.
If you want to have a copy of SyncSort Documentation, please contact Alissa Margulies on this board or send a note to SyncSort representative at your shop or write an e-mail to [email protected] and follow the instructions.
Good Luck!  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|