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: To include qualified records based on current date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: SYNCSORT: To include qualified records based on current date
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

Site Director


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

PostPosted: Tue Oct 11, 2011 10:47 pm    Post subject:
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    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Oct 11, 2011 11:59 pm    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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

Site Director


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

PostPosted: Wed Oct 12, 2011 12:18 am    Post subject:
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

Moderator Team Head


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

PostPosted: Wed Oct 12, 2011 1:20 am    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
Reply with quote

Maybe the topic about date conversions a few weeks back:

http://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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Oct 12, 2011 2:05 am    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Oct 12, 2011 2:58 am    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Oct 12, 2011 12:23 pm    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Oct 12, 2011 3:21 pm    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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    Post subject:
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: 1703
Location: Australia

PostPosted: Thu Oct 13, 2011 4:36 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Oct 13, 2011 11:17 am    Post subject: Reply to: SYNCSORT: To include qualified records based on cu
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: 1703
Location: Australia

PostPosted: Thu Oct 13, 2011 11:23 am    Post subject:
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    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 7 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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


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