View previous topic :: View next topic
Author
Message
ksouren007 New User Joined: 30 Jun 2010Posts: 85 Location: Toronto, ON
Hi,
I have a FB file with a cloumn storing date as YYYYMM e.g. 201108.
Now I want to extract records from the file for the immediate previous year always. Like YYYY - 1.
Is there any way to do it using DATE parameter?
Back to top
Soumik Das New User Joined: 06 Aug 2011Posts: 25 Location: India
I prefer to use SYMNAMES....I believe syncsort works with DFSORT symnames.
I have only dfsort in my shop but I believe this will work for syncsort as well.
Code:
//S010 EXEC SORT
//SYMNAMES DD *
THISYEAR,C'2011'
LASTYEAR,C'2010'
//SORTIN DD *
AAA200901
BBB201002
CCC201003
CCC201101
DDD201004
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(4,4,CH,LT,THISYEAR,AND,4,4,CH,GE,LASTYEAR)
You can create symnames like this.
Code:
/TSOBATCH EXEC PGM=IKJEFT1A,DYNAMNBR=200
//SYSEXEC DD DSN=GEP29.QUELL.REXX,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//OUTFILE DD DSN=&&DSN1,UNIT=SYSDA,SPACE=(TRK,(1,1)),
// DISP=(,PASS),LRECL=80,RECFM=FB,DSORG=PS
//SYSTSIN DD *
%REXXDT1
//S020 EXEC SORT
//SYMNAMES DD DSN=&&DSN1,DISP=(OLD,PASS)
//SORTIN DD *
AAA200901
BBB201002
CCC201003
CCC201101
DDD201004
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(4,4,CH,LT,THISYEAR,AND,4,4,CH,GE,LASTYEAR)
Here REXXDT1 will have the below REXX code (this is untested but I believe you can get the idea)
Code:
/* REXX */
"EXECIO 0 DISKW OUTFILE(OPEN"
A1=DATE('S',DATE('B'),'B')
A2=SUBSTR(A1,1,4)
B1=DATE('S',DATE('B')-365,'B')
B2=SUBSTR(B1,1,4)
QUEUE "THISYEAR,C"||"'"||A2||"'"
QUEUE "LASTYEAR,C"||"'"||B2||"'"
"EXECIO * DISKW OUTFILE (FINIS"
"FREE FI(OUTFILE)"
Let me know if you get stuck.....
Back to top
ksouren007 New User Joined: 30 Jun 2010Posts: 85 Location: Toronto, ON
Soumik,
If at all I had to hardcode my year, then I would have preferred a simple 4,4,CH,EQ,C'2010'!!!!!!!!!
Neways thanks for responding.
Back to top
gylbharat Active Member Joined: 31 Jul 2009Posts: 565 Location: Bangalore
This is not hardcoding... Rexx is generating the year...
Back to top
ksouren007 New User Joined: 30 Jun 2010Posts: 85 Location: Toronto, ON
ok..but i am not a REXX programmer so couldn't get that part.
Neways..I got my ctlcard as below after some trial and error..it solved my issue. Thanks all for replying.
INCLUDE COND=(3,4,CH,EQ,DATE1-365)
Back to top
Craq Giegerich Senior Member Joined: 19 May 2007Posts: 1512 Location: Virginia, USA
What about leap years?
Back to top
Nic Clouston Global Moderator Joined: 10 May 2007Posts: 2455 Location: Hampshire, UK
It is NOT neways but ANYWAY
Back to top
ksouren007 New User Joined: 30 Jun 2010Posts: 85 Location: Toronto, ON
Craq,
That scenario will not arrive as my sort would run only once in a year on Jan.
who cares for grammer in this wild wild west...
Back to top
ksouren007 New User Joined: 30 Jun 2010Posts: 85 Location: Toronto, ON
ksouren007 wrote:
Thanks all for replying.
Neways thanks for responding.
Yeah..but I thought Mr Zuckerberg's words suits people more appropriately who questions the above attitude..
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Souren,
If the job only runs in January, why not just subtract 31 :-)
Do you ever write anything at your site for others to read? Documentation? Specifications? Memos? Anything? Assuming that you do, do you use the same slang, or do you write it the best you can so that the receiver is most likely to be able to understand it? Assuming the latter, how about extending us the same courtesy?
Looking at your mainframe skills, your life is full of syntax and correct spelling - you'd not do it there, so why with us? I know you can take the brick-bats, but do you have to? When seeking information and ideas from elsewhere, I've never found the "wind-up" to be an effective tactic.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Quote:
who cares for grammer in this wild wild west...
Anyone who wants to appear to be and be taken as a professional. . . And most of the people who might be able to help you.
Kiddie chat speak is just insulting to those you want to read it (unless it is a private text message to your BFF). . .
This attitude plus the growing lack of even basic knowledge is causing IT to get more and more disrespect.
You decide how you want to be considered for your career. . .
Back to top
Please enable JavaScript!