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
 

 

Using the current-date or todays-date in a sort compare

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Sysaron

New User


Joined: 28 Sep 2005
Posts: 55
Location: USA

PostPosted: Thu Oct 11, 2007 6:33 am    Post subject: Using the current-date or todays-date in a sort compare
Reply with quote

I would like to compare a year in a file (columns 1-2) again the current-date, todays-date, the run-date, system-date or whatever it is called in dfsort. If the files date is less that 3 years from the system-date year, put it in one file, or else put it in another.

Sharon in LA
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Oct 11, 2007 8:47 pm    Post subject:
Reply with quote

Quote:
If the files date is less that 3 years from the system-date year


That requirement is a little confusing. Am example of input and output would have helped. However, here's a DFSORT job that should give you the idea of how to do this kind of thing.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD *
YR,S'&YR2'
/*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
* Create a DFSORT Symbol as:
* TARG_YR,Y'xx'
* where xx is current_yy-3
  INREC OVERLAY=(51:YR,
    1:C'TARG_YR,Y''',51,2,ZD,SUB,+3,EDIT=(TT),C'''')
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD *
98
99
00
01
02
03
04
05
06
07
/*
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY,Y2PAST=1980
* Use the TARG_YR symbol in INCLUDE.
  OUTFIL FNAMES=OUT1,INCLUDE=(1,2,Y2C,LT,TARG_YR)
  OUTFIL FNAMES=OUT2,SAVE
/*


OUT1 would have:

98
99
00
01
02
03

OUT2 would have:

04
05
06
07

If that's not what you want, then please explain more clearly what you want and show an example of input and expected output.
Back to top
View user's profile Send private message
Sysaron

New User


Joined: 28 Sep 2005
Posts: 55
Location: USA

PostPosted: Wed Oct 17, 2007 3:20 am    Post subject: Can you compare to the system-date in a SORT?
Reply with quote

HI Frank,

I have an unsorted input file with YYMMDDxxxxxxxxxxxx for the records.
Like:
941025xxxxxxxxxxxxxx
061003xxxxxxxxxxxxxx
970314xxxxxxxxxxxxxx
070809xxxxxxxxxxxxxx

The current-date or system-date is now "2007-10-16 14:50"
Records 2 and 4 have a 'difference year' that is not greater than 3
2007-2006=1
2007-2007=0
Records 2 and 4 go into output file 1.

Records 1 and 3 go into output file 2.
2007-1994=13
2007-1997=10

Of course I will compare the month and day as well, but I was keeping it simple.

Thank you so much for your help. I know it will be simple if ICEMAN can access the system-date/time. But I dont know what format it will look like, or how to store it for the compare.

Sysaron
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Oct 17, 2007 3:38 am    Post subject: Re: Can you compare to the system-date in a SORT?
Reply with quote

Sysaron wrote:
I know it will be simple if ICEMAN can access the system-date/time. But I dont know what format it will look like, or how to store it for the compare.
Have you looked at the manual?
DFSORT Data Formats
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Oct 17, 2007 11:33 am    Post subject:
Reply with quote

This SORT JOB compares the Year and puts the records in to File1 and File2 as per your specifications
Code:
//*******************************************************               
//STEP1    EXEC PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
941025XXXXXXXXXXXXXX                                                   
061003XXXXXXXXXXXXXX                                                   
970314XXXXXXXXXXXXXX                                                   
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
070809XXXXXXXXXXXXXX                                                   
/*                                                                     
//FILE1    DD SYSOUT=*                                                 
//FILE2    DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
   OPTION COPY                                                         
   OUTREC OVERLAY=(25:DATE1,35:27,2,ZD,SUB,1,2,ZD,TO=ZD,LENGTH=2)       
   OUTFIL FNAMES=FILE2,INCLUDE=(35,2,ZD,LT,0),BUILD=(1,22)             
   OUTFIL FNAMES=FILE1,SAVE,BUILD=(1,22)                               
/*                                                                     

FILE1:
Code:
061003XXXXXXXXXXXXXX
070809XXXXXXXXXXXXXX

File2:
Code:
941025XXXXXXXXXXXXXX
970314XXXXXXXXXXXXXX
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Oct 17, 2007 9:06 pm    Post subject:
Reply with quote

Sysaron,

The job I provided gives the output you asked for. For your example, the output is:

OUT1:

941025XXXXXXXXXXXXXX
970314XXXXXXXXXXXXXX

OUT2:

061003XXXXXXXXXXXXXX
070809XXXXXXXXXXXXXX

If you want to switch the output, you could use:

Code:

  OUTFIL FNAMES=OUT2,INCLUDE=(1,2,Y2C,LT,TARG_YR)
  OUTFIL FNAMES=OUT1,SAVE


Quote:
Of course I will compare the month and day as well, but I was keeping it simple.

Thank you so much for your help. I know it will be simple if ICEMAN can access the system-date/time. But I dont know what format it will look like, or how to store it for the compare.


I set up the solution to just handle the 2-digit year date as you requested. Using the entire date would require a different solution. If you want help with that, you need to explain exactly what you want to do in terms of comparing the month and day as well.

Note: "Keeping it simple" by providing only a part of the requirement isn't a good strategy on this board. You give a piece of your requirement - I show you how to do it - then you come back and say that wasn't really my requirement so now I need this. That just wastes time.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am


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