Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Date comparision using DFSORT

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

Active User


Joined: 11 Mar 2007
Posts: 195
Location: india

PostPosted: Wed Mar 07, 2012 5:00 am    Post subject: Date comparision using DFSORT
Reply with quote

Hello People

I need to compare the month in the two date fields mentioned
below based on the freq code M=01, R=01, Q=03, H=06, A=12.

when month of the first date (cols 9,10) is added with the value of freq
code and is not equal to month of the second date(cols 19,20) then write
the records to OUTFILE1 else write the records to OUTFILE2

Input file :-

Code:
----+----1----+----2----+----3----+----4
M  020120130 020120228  183750912
M  020120130 020120329  183750438
Q  020111229 020120329  183745434
Q  020111229 020120228  183767431
H  020120227 020120827  343750435
A  020110929 020120927  183750432


OUTFILE1 :-

Code:
----+----1----+----2----+----3----+----4
M  020120130 020120329  183750438
Q  020111229 020120228  183767431


OUTFILE2 :-

Code:
----+----1----+----2----+----3----+----4
M  020120130 020120329  183750438
Q  020111229 020120329  183745434
H  020120227 020120827  343750435
A  020110929 020120927  183750432


Thank you,
Rajat
Back to top
View user's profile Send private message

rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 195
Location: india

PostPosted: Wed Mar 07, 2012 5:08 am    Post subject:
Reply with quote

ops.. apologies.. there was a typo.. below should be OUTFILE2:-


OUTFILE2 :-

----+----1----+----2----+----3----+----4
M 020120130 020120228 183750912
Q 020111229 020120329 183745434
H 020120227 020120827 343750435
A 020110929 020120927 183750432


Thank you,
Rajat
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 Mar 07, 2012 5:09 am    Post subject:
Reply with quote

I don't see how your "rules" match your example. I interpret your rules to give the following for the input records:

Code:

----+----1----+----2----+----3----+----4      Freq +  M1 = Tot   M2  Tot:M2
M  020120130 020120228  183750912             01      01    02   02  eq
M  020120130 020120329  183750438             01      01    02   03  ne
Q  020111229 020120329  183745434             03      12    15   03  ne
Q  020111229 020120228  183767431             03      12    15   02  ne
H  020120227 020120827  343750435             06      02    08   08  eq
A  020110929 020120927  183750432             12      09    21   09  ne


This does NOT match your expected output.

So please show a similar analysis that corresponds to your expected output.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Mar 07, 2012 6:26 am    Post subject:
Reply with quote

rajatbagga,
If I understood your requirement correctly, you are want to add the number presented by M(+01), R(+01), Q(+03), H(+06), A(+12) to the month present in the position 9,10. If the summation is beyond 12, you want to start at 01.

If that is correct see if below 2 methods work for you...YMMV

METHOD1 --> Because you are looking month only, you are safe in this method by adding number of months presented by frequency.
Code:
//STEP0001 EXEC PGM=SORT                                     
//SYMNAMES DD *                                             
MRTYP,+01                                                   
QTYP,+03                                                     
HTYP,+06                                                     
ATYP,+12                                                     
/*                                                           
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
M  020120130 020120228  183750912                           
M  020120130 020120329  183750438                           
Q  020111229 020120329  183745434                           
Q  020111229 020120228  183767431                           
H  020120227 020120827  343750435                           
A  020110929 020120927  183750432                           
//OUT1     DD SYSOUT=*                                       
//OUT2     DD SYSOUT=*                                       
//SYSIN    DD *                                             
 INREC IFTHEN=(WHEN=(1,1,SS,EQ,C'M,R'),                     
             OVERLAY=(81:5,8,Y4T,ADDMONS,MRTYP,TOGREG=Y4T)),
       IFTHEN=(WHEN=(1,1,SS,EQ,C'Q'),                       
             OVERLAY=(81:5,8,Y4T,ADDMONS,QTYP,TOGREG=Y4T)), 
       IFTHEN=(WHEN=(1,1,SS,EQ,C'H'),                       
             OVERLAY=(81:5,8,Y4T,ADDMONS,HTYP,TOGREG=Y4T)), 
       IFTHEN=(WHEN=(1,1,SS,EQ,C'A'),                       
             OVERLAY=(81:5,8,Y4T,ADDMONS,ATYP,TOGREG=Y4T))   
 OPTION COPY                                                 
 OUTFIL FNAMES=OUT1,INCLUDE=(19,2,ZD,EQ,85,2,ZD),BUILD=(1,80)
 OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)                       
/*                                                           


METHOD2 Bad coding but may be more efficient as there is no date conversion.
Code:

//STEP0001 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
M  020120130 020120228  183750912                           
M  020120130 020120329  183750438                           
Q  020111229 020120329  183745434                           
Q  020111229 020120228  183767431                           
H  020120227 020120827  343750435                           
A  020110929 020120927  183750432                           
//OUT1     DD SYSOUT=*                                       
//OUT2     DD SYSOUT=*                                       
//SYSIN    DD *                                             
 INREC IFTHEN=(WHEN=(1,1,SS,EQ,C'M,R'),                     
             OVERLAY=(81:9,2,ZD,ADD,+01,TO=ZD,LENGTH=2)),   
       IFTHEN=(WHEN=(1,1,CH,EQ,C'Q'),                       
             OVERLAY=(81:9,2,ZD,ADD,+03,TO=ZD,LENGTH=2)),   
       IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),                       
             OVERLAY=(81:9,2,ZD,ADD,+06,TO=ZD,LENGTH=2)),   
       IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),                       
             OVERLAY=(81:9,2,ZD,ADD,+12,TO=ZD,LENGTH=2))     
 OPTION COPY                                                 
 OUTREC IFTHEN=(WHEN=(81,2,ZD,GT,+12),                       
             OVERLAY=(81:81,2,ZD,SUB,+12,TO=ZD,LENGTH=2))   
 OUTFIL FNAMES=OUT1,INCLUDE=(19,2,ZD,EQ,81,2,ZD),BUILD=(1,80)
 OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)                       
/*                                                           

OUTPUT

OUT1
Code:
M  020120130 020120228  183750912
Q  020111229 020120329  183745434
H  020120227 020120827  343750435
A  020110929 020120927  183750432


OUT2
Code:
M  020120130 020120329  183750438
Q  020111229 020120228  183767431

Thanks,
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 195
Location: india

PostPosted: Wed Mar 07, 2012 10:38 am    Post subject:
Reply with quote

Thanks a lot sqlcode1 (i wish if i knew your real name to thank you icon_smile.gif) , this is exactly what i wanted (METHOD1)

Regards,
Rajat
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Mar 07, 2012 10:47 pm    Post subject: Reply to: Date comparision using DFSORT
Reply with quote

rajatbagga,

Another alternative of getting the desired results

Code:

//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
                                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,1,X)),                       
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,                           
  INOUT=(C'M',C'01',C'R',C'01',C'Q',C'03',C'H',C'06',C'A',C'12'))), 
  IFTHEN=(WHEN=INIT,OVERLAY=(83:5,8,Y4T,ADDMONS,81,2,ZD,TOGREG=Y4T))
                                                                     
  OUTFIL FNAMES=OUT1,BUILD=(1,80),INCLUDE=(19,2,ZD,EQ,87,2,ZD)       
  OUTFIL FNAMES=OUT2,BUILD=(1,80),SAVE                               
//*
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 195
Location: india

PostPosted: Sat Mar 10, 2012 8:01 am    Post subject:
Reply with quote

Thank You Skolusu
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 Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm
No new posts Validate the Date girishb2 DFSORT/ICETOOL 9 Tue Sep 19, 2017 1:12 am
No new posts Julian Date to CICS ABSTTIME blayek CICS 3 Wed Aug 30, 2017 11:15 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us