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

Extracts records matching with todays date using sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Tue Jan 29, 2008 6:30 pm
Reply with quote

My file has dates in the format mm/dd/yyyy, and I want to extract the records with dates matching with the current date. How we can do this using sort?

Bipin Peter
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Jan 29, 2008 7:00 pm
Reply with quote

Look at the topic "Only include records with today's date " in Smart DFSORT Tricks at
http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Tue Jan 29, 2008 7:06 pm
Reply with quote

i checked that but it dont have the format of mm/dd/yyyy
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jan 29, 2008 10:01 pm
Reply with quote

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                             
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
01/29/2008                                             
01/30/2008                                             
01/31/2008                                             
02/01/2008                                             
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                     
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:DATE1(/))),     
         IFTHEN=(WHEN=INIT,OVERLAY=(91:86,5,85,1,81,4))
  OUTFIL INCLUDE=(01,10,CH,EQ,91,10,CH),               
  BUILD=(01,80)                                       
//*                                                   
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Wed Jan 30, 2008 9:12 am
Reply with quote

Hi,
You can also try out with the below mentioned JCL

Code:
//VZM1CKKN JOB (3GAHF3,R),                                   
//         'RAJAT TEST',CLASS=X,MSGCLASS=Y,NOTIFY=&SYSUID   
//S1    EXEC  PGM=ICETOOL                                   
//TOOLMSG DD SYSOUT=*                                       
//DFSMSG  DD SYSOUT=*                                       
//T1      DD DSN=&&TEMP1,                                   
//           DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA   
//CON     DD *                                               
01/29/2008                                                   
01/30/2008                                                   
01/31/2008                                                   
02/01/2008                                                   
/*                                                           
//OUT  DD SYSOUT=*                                           
//TOOLIN DD *                                               
   COPY FROM(CON) TO(T1) USING(CTL1)                         
   COPY FROM(T1) TO(OUT) USING(CTL2)                         
/*                                                           
//CTL1CNTL DD *                       
  OPTION COPY                         
  OUTREC FIELDS=(7,4,5:C'/',1,2,3,3) 
/*                                   
//CTL2CNTL DD *                       
  OPTION COPY                         
  INCLUDE COND=(1,10,CH,EQ,DATE1(/)) 
/*                                   
 
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Wed Jan 30, 2008 9:15 am
Reply with quote

But i think the JCL posted by Skolusu is more effective. icon_smile.gif
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Wed Jan 30, 2008 10:14 am
Reply with quote

Thanx Skolusu,it's working fine
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jan 30, 2008 10:04 pm
Reply with quote

Here's a really cool way to do it with DFSORT using System Symbols:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD *
* Create symbol for 'mm/dd/yyyy'
Cur_Date,S'&MON./&DAY./&YR4'
/*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INCLUDE COND=(1,10,CH,EQ,Cur_Date)
/*
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Thu Jan 31, 2008 7:41 am
Reply with quote

hello Frank,

I tried the above JCL posted by you and i am getting the following error

ICE270I 0 PROCESSING SYMNAMES STATEMENTS
DATE,S'&MON./&DAY./&YR4'
$
ICE276A 0 RESERVED WORD - NOT ALLOWED FOR SYMBOL
ICE279A 0 ONE OR MORE ERRORS ENCOUNTERED DURING SYMNAMES PROCESSING
ICE052I 3 END OF DFSORT
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 31, 2008 9:55 pm
Reply with quote

You used DATE in uppercase which is a reserved word. I used Date in mixed case which is NOT a reserved word. If you want to use an uppercase symbol name, use something like CUR_DATE instead of DATE.
I changed my example to avoid confusion.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Fri Feb 01, 2008 10:42 am
Reply with quote

i am using the follwing JCl

Code:
//S1    EXEC  PGM=ICEMAN               
//SYSOUT    DD  SYSOUT=*               
//SYMNAMES DD *                         
CUR_DATE,S'&MON./&DAY./&YR4'           
/*                                     
//SORTIN   DD *                         
07/17/2006                             
05/01/2009                             
03/03/2007                             
12/26/2005                             
/*                                     
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD    *                     
  OPTION COPY                           
  INCLUDE COND=(1,10,CH,EQ,CUR_DATE)   
/*                                     


And I am getting the following Error:

Code:
PROCESSING SYMNAMES STATEMENTS                           
 CUR_DATE,S'&MON./&DAY./&YR4'                             
          $                                               
SYMBOL, VALUE OR SYNTAX IS INVALID                       
ONE OR MORE ERRORS ENCOUNTERED DURING SYMNAMES PROCESSING
END OF DFSORT     



Please let me know where I am wrong
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Fri Feb 01, 2008 11:42 am
Reply with quote

I even tried using
Code:
Cur_Date,C'&MON./&DAY./&YR4'


instead of using
Code:
Cur_Date,S'&MON./&DAY./&YR4'


and changed input date to todays date in mm/dd/yyyy format. In this case the JOB was not abending but I was not getting the output i.e. todays date.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Fri Feb 01, 2008 11:46 am
Reply with quote

And also please let me know how we are getting the current date in this case. i mean how the value of current date will be mapped to CUR_DATE
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 01, 2008 10:22 pm
Reply with quote

You need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 in order to use DFSORT's S constants in SYMNAMES. The error message indicates you don't have that PTF which has been available since April, 2006. Ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

Use [URL] BBCode for External Links

Quote:
And also please let me know how we are getting the current date in this case. i mean how the value of current date will be mapped to CUR_DATE


Cur_Date,S'&MON./&DAY./&YR4'

S'string' allows you to use system constants to construct a DFSORT symbol constant.
&MON is the system symbol for the 2-digit month (e.g. 02 for February).
&DAY is the system symbol for the 2-digit day (e.g. 01 today).
&YR4 is the system symbol for the 4-digit year (2008).
the dot means concatenation.

So the resulting constant is mm concatenated with / concatenated with dd concatenated with / concatenated with yyyy = mm/dd/yyyy
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Sat Feb 02, 2008 11:03 am
Reply with quote

Thank you very much for the information frank.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top