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

Date comparision using DFSORT


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

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Wed Mar 07, 2012 5:00 am
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: 199
Location: india

PostPosted: Wed Mar 07, 2012 5:08 am
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 Developer


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

PostPosted: Wed Mar 07, 2012 5:09 am
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: 577
Location: USA

PostPosted: Wed Mar 07, 2012 6:26 am
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: 199
Location: india

PostPosted: Wed Mar 07, 2012 10:38 am
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
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: 199
Location: india

PostPosted: Sat Mar 10, 2012 8:01 am
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 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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top