|
View previous topic :: View next topic
|
| Author |
Message |
CICS fan
New User

Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
Hello all,
I have an input file, length 400, where we have a date field in format CCYY-MM-DD(e.g. 2011-07-31).
This runs on a particular day of every month say 1st or 2nd. The requirement is to exclude all records other than those of previous month's date.
So if it is running on 2011-11-01(1st Nov), the output file should only have records with date from 2011-10-01 to 2011-10-31.
Can you help me on this please? |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Just code an INCLUDE for only those dates for the CCYYMM you want to process. |
|
| Back to top |
|
 |
CICS fan
New User

Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
Hello Dick,
Thanks for replying.
The process will run every month, day 2nd. So wee need to make it dynamic so that only records of last month are included.
Hardcoding wont make it dynamic.
Let me know if I understood wrong. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, you need a file with a business date on it. Do you have one handy?
In one step take the date from that file and generate a SYMNAME, along the lines of
| Code: |
| BUSINESS-DATE-MONTH,C'CCYY-MM' |
Then, in your existing sort step,
| Code: |
| INCLUDE COND=(TRANSACTION-MONTH,EQ,BUSINESS-DATE-MONTH) |
Where TRANSACTION-MONTH is another SYMNAME, something like
| Code: |
| TRANSACTION-MONTH,startpos,length,CH |
Where startpos and length are apporpriate to your file.
Should be dynamic enough. It is also what Dick has already suggested. There are some recent examples in JCL forum here (where SYNCSORT questions live). |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
You could dynamically generate the INCLUDE statement and then use it in the process.
You could "can" several years of these as members in a PDS and then use them by specifying a symbolic parameter for the member needed for a particular run (coordinating with the scheduling people).
You might also talk with the scheduling people and learn how they do this in other processes. |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
|
|
for DFSORT this works
| Code: |
000006 //SORTIN DD *
000007 2011-11-01
000008 2011-10-01
000009 2011-09-01
000010 //SORTOUT DD SYSOUT=*,
000011 // DCB=(RECFM=FB,LRECL=80)
000012 //SYSIN DD *
000013 OPTION COPY
000014 INREC OVERLAY=(81:1,4,85:6,2)
000015 OUTFIL BUILD=(1,80),
000016 INCLUDE=(81,6,CH,EQ,DATE2-1)
|
and gives as output
for DFSORT DATE2 is the current date in the format YYYYMM
seems that something similar could be done with the syncsort &DATE stuff
check the manuals
and chanage the offsets according to Your record layout |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I was thinking of something like this one. Through this you should find some differing examples.
If you have a business date available, use it. Will always work, assuming restored correctly for re-run.
If you don't have a business date, first castigate anyone remaining who was involved in the original "design" of your system, then you can try to adapt enrico's solution to Syncsort, just remember that for a re-run after the end of the month you'd have to hard-code a value. And watch for any schedule changes. If it is scheduled for last day of the month, will work if step starts before midnight, won't work if after midnight. |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
Try the below code
| Code: |
//STEP1 EXEC PGM=SORT
//SORTIN DD *
2011-07-31
2011-09-21
2011-09-07
2011-09-05
2011-09-30
2011-10-01
//SORTOUT DD DSN=&&TEMP,DISP=(,CATLG,),
// DCB=(LRECL=100,RECFM=FB),SPACE=(TRK,(1,1))
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFOUTLEN=100,IFTHEN=(WHEN=INIT,OVERLAY=(81:&DATE4)),
IFTHEN=(WHEN=(86,2,CH,EQ,C'01'),OVERLAY=(86:C'12')),
IFTHEN=(WHEN=(86,2,CH,NE,C'01'),
OVERLAY=(86:86,2,ZD,SUB,+1,EDIT=(TT)))
//STEP2 EXEC PGM=SORT
//SORTIN DD DSN=&&TEMP,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(1,7,CH,EQ,81,7,CH)
OUTREC BUILD=(1,80) |
Output will be
| Code: |
2011-09-21
2011-09-07
2011-09-05
2011-09-30 |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
|
|
Just curious... why two steps
I do not believe SYNCSORT so dumb not to able to do it just in ONE |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
The sort is designed in such a way the include and omit conditions are processed before INREC/OUTREC statements. So with the approach i followed you cannot have the include statement in the same step of formatting the input file.
In ICETOOL you can do it in single step using the same approach. |
|
| Back to top |
|
 |
xknight
Active User

Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
| Quote: |
| The sort is designed in such a way |
But still, we can make use of SYNCTOOL isn't it..
| Code: |
//STEP1 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN1 DD *
2011-07-31
2011-09-21
2011-09-07
2011-09-05
2011-09-30
2011-10-01
//OUT1 DD DSN=&&TEMP,DISP=(,PASS,),
// DCB=(LRECL=100,RECFM=FB),SPACE=(TRK,(1,1))
//OUT2 DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CTL1)
COPY FROM(OUT1) TO(OUT2) USING(CTL2)
//CTL1CNTL DD *
SORT FIELDS=COPY
OUTREC IFOUTLEN=100,IFTHEN=(WHEN=INIT,OVERLAY=(81:&DATE4)),
IFTHEN=(WHEN=(86,2,CH,EQ,C'01'),OVERLAY=(86:C'12')),
IFTHEN=(WHEN=(86,2,CH,NE,C'01'),
OVERLAY=(86:86,2,ZD,SUB,+1,EDIT=(TT)))
/*
//CTL2CNTL DD *
SORT FIELDS=COPY
INCLUDE COND=(1,7,CH,EQ,81,7,CH)
OUTREC BUILD=(1,80)
/* |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
|
|
the issue I was curious about is not the two steps,
but the two passes over the data done anyway also in SYNCTOOL approach
I thought that SYNCSORT would be able/smart to do it in the same way dfsort does it in the snippet I posted |
|
| Back to top |
|
 |
xknight
Active User

Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
| Quote: |
the issue I was curious about is not the two steps,
but the two passes over the data done anyway also in SYNCTOOL approach |
Now i have understand your curiousity
| Quote: |
for DFSORT this works
Code:
000006 //SORTIN DD *
000007 2011-11-01
000008 2011-10-01
000009 2011-09-01
000010 //SORTOUT DD SYSOUT=*,
000011 // DCB=(RECFM=FB,LRECL=80)
000012 //SYSIN DD *
000013 OPTION COPY
000014 INREC OVERLAY=(81:1,4,85:6,2)
000015 OUTFIL BUILD=(1,80),
000016 INCLUDE=(81,6,CH,EQ,DATE2-1) |
Between, the snippet you posted works well on syncsort too.  |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try this
| Code: |
//PS005 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXXXX
1XXXXXX
XXXXX
1XXXX
XXXXX
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),OVERLAY=(81:SEQNUM,8,ZD))
OUTFIL IFOUTLEN=80,
IFTHEN=(WHEN=(1,1,CH,EQ,C'1',&,81,08,ZD,GT,+1),
BUILD=(C'XX COMENT LINEXXXXX',/,
1,80)),
TRAILER1=(C'XX COMENT LINEXXXXX'),REMOVECC
END
/*
|
Gerry |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| I think this is attached to the wrong topic. Should be this one. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Bill,
thanks for pointing it out
Gerry |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|