IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SYNCSORT: To include qualified records based on current date


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Tue Oct 11, 2011 9:45 pm
Reply with quote

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

Moderator Emeritus


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

PostPosted: Tue Oct 11, 2011 10:47 pm
Reply with quote

Hello,

Just code an INCLUDE for only those dates for the CCYYMM you want to process.
Back to top
View user's profile Send private message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Tue Oct 11, 2011 10:56 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Oct 11, 2011 11:59 pm
Reply with quote

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

Moderator Emeritus


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

PostPosted: Wed Oct 12, 2011 12:18 am
Reply with quote

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

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Oct 12, 2011 1:20 am
Reply with quote

Maybe the topic about date conversions a few weeks back:

www.ibmmainframes.com/viewtopic.php?t=56263

could be tweaked a bit to do this? If I get a chance I'll look into the possibility.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 12, 2011 2:05 am
Reply with 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)                                   


and gives as output
Code:
2011-09-01


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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 12, 2011 2:58 am
Reply with quote

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

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Wed Oct 12, 2011 12:21 pm
Reply with quote

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 12, 2011 12:23 pm
Reply with quote

Just curious... why two steps
I do not believe SYNCSORT so dumb not to able to do it just in ONE
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Wed Oct 12, 2011 1:44 pm
Reply with quote

Quote:
why two steps

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

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Oct 12, 2011 2:10 pm
Reply with quote

Quote:
The sort is designed in such a way


But still, we can make use of SYNCTOOL isn't it.. icon_smile.gif

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 12, 2011 3:21 pm
Reply with 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

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

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Oct 12, 2011 3:52 pm
Reply with quote

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 icon_biggrin.gif

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. icon_smile.gif
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Oct 13, 2011 4:36 am
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Oct 13, 2011 11:17 am
Reply with quote

I think this is attached to the wrong topic. Should be this one.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Oct 13, 2011 11:23 am
Reply with quote

Hi Bill,

thanks for pointing it out icon_redface.gif


Gerry
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top