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
 

 

Date Field Compare using DFSORT

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

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Tue Jun 26, 2012 5:32 pm    Post subject: Date Field Compare using DFSORT
Reply with quote

I have two input files -

FILE-1 :-
Code:

----+----1
2012-01-01


And FILE-2 :-
Code:

----+----1----+----2----+----3----+----4----+----5
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD31 FIELD32 2011-06-01 FIELD34
FIELD41 FIELD42            FIELD44
FIELD51 FIELD52 2011-05-01 FIELD54


My requirement is, the date in FILE-2 at position (17,10) must be compared with the single date in FILE-1 at position (1,10) and only those records from FILE-2 will go to output file whose date is greater than the date in FILE-1 OR is SPACES.

So the output file will have :-
Code:

----+----1----+----2----+----3----+----4----+----5
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD41 FIELD42            FIELD44
Back to top
View user's profile Send private message

Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Tue Jun 26, 2012 5:50 pm    Post subject:
Reply with quote

Create SYMNAME for the first file (field). This is recently discussed. Suggest you search the forum.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Tue Jun 26, 2012 6:16 pm    Post subject:
Reply with quote

Any other option without going for SYMNAME ??
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Jun 26, 2012 6:16 pm    Post subject:
Reply with quote

What if FILE2 also contains ??

Should it be considered or not??

Code:
2012-01-01
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Tue Jun 26, 2012 6:21 pm    Post subject:
Reply with quote

@Pandora-Box

Yes That must be considered too ... Thanks for pointing that out.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jun 26, 2012 6:38 pm    Post subject: Reply to: Date Field Compare using DFSORT
Reply with quote

The SYMNAME is by far the easiest and most maintainable way to do it. You want to pick another way, have a search through the forum and see if there is anything you can apply. Try some stuff out. Google a bit. Read the manuals. Talk to colleagues. You might end up with the SYMNAME anyway (why don't you want to use it?), but could pick up some stuff in the time you spend looking for an alternative.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Jun 26, 2012 7:23 pm    Post subject:
Reply with quote

Option using SYMNAMES But As Bill suggested Symnames option is better

Code:
//STEP0001 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
2012-01-01
/*
//DATEFL   DD DSN=&&DT,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD *
  OPTION COPY
  OUTFIL FNAMES=DATEFL,REMOVECC,NODETAIL,
                       TRAILER1=('DT,C''',01,10,C'''')
/*
//STEP0002 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SYMNAMES DD DSN=&&DT,DISP=(OLD,PASS)
//SORTIN   DD *
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD31 FIELD32 2011-06-01 FIELD34
FIELD41 FIELD42            FIELD44
FIELD51 FIELD52 2011-05-01 FIELD54
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC OVERLAY=(81:DT)
  OUTFIL FNAMES=SORTOUT,
    INCLUDE=((17,4,CH,GE,81,4,CH,
                  AND,20,2,CH,GE,86,2,CH,
                  AND,23,2,CH,GE,89,2,CH),OR,17,10,CH,EQ,C' '),
  BUILD=(1,80)
/*


You can use this Option using JOINKEYS if you insisted on other option than SYMNAMES
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//INA      DD *
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD31 FIELD32 2011-06-01 FIELD34
FIELD41 FIELD42            FIELD44
FIELD51 FIELD52 2011-05-01 FIELD54
//INB      DD *
2012-01-01
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK
  JOINKEYS F2=INB,FIELDS=(11,1,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,81,F2:1,11)
  INCLUDE COND=((17,4,CH,GE,82,4,CH,
                AND,20,2,CH,GE,87,2,CH,
                AND,23,2,CH,GE,90,2,CH),OR,17,10,CH,EQ,C' ')
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,80)
//*
Back to top
View user's profile Send private message
Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Tue Jun 26, 2012 7:27 pm    Post subject:
Reply with quote

try this. although it gives the desired o/p, experts can you correct me if I am wrong. I still feel SYMNAME is a better option.

Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//INA      DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
2012-01-01
//INB      DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD31 FIELD32 2011-06-01 FIELD34
FIELD41 FIELD42            FIELD44
FIELD51 FIELD52 2011-05-01 FIELD54
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  JOINKEYS F1=INA,FIELDS=(11,1,A)
  JOINKEYS F2=INB,FIELDS=(35,1,A)
  JOIN UNPAIRED,F1,F2
  REFORMAT FIELDS=(F1:1,10,F2:1,34)
  INCLUDE COND=((1,10,PD,GT,27,10,PD),OR,27,10,CH,EQ,C' ')
  OUTREC FIELDS=(11,34)
//JNF1CNTL DD *
     INREC BUILD=(1,10,C'D')
//JNF2CNTL DD *
     INREC BUILD=(1,34,C'D')
//*


O/P:

Code:
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD41 FIELD42            FIELD44
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jun 26, 2012 7:42 pm    Post subject: Reply to: Date Field Compare using DFSORT
Reply with quote

Pandora-Box, maybe generate three literals, year, month and day. Then no need to OVERLAY or loose the OVERLAY later.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Jun 26, 2012 7:58 pm    Post subject:
Reply with quote

Thanks Bill for suggesting a better option

Code:
//STEP0001 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
2012-01-01
/*
//DATEFL   DD DSN=&&DT,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD *
  OPTION COPY
  OUTFIL FNAMES=DATEFL,REMOVECC,NODETAIL,
                       TRAILER1=('YY,C''',01,4,C'''',/,
                                'MM,C''',06,2,C'''',/,
                                'DD,C''',09,2,C'''')
/*
//STEP0002 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SYMNAMES DD DSN=&&DT,DISP=(OLD,PASS)
//SORTIN   DD *
FIELD11 FIELD12 2012-03-01 FIELD14
FIELD21 FIELD22 2012-04-01 FIELD24
FIELD31 FIELD32 2011-06-01 FIELD34
FIELD41 FIELD42            FIELD44
FIELD51 FIELD52 2011-05-01 FIELD54
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  OUTFIL FNAMES=SORTOUT,
    INCLUDE=((17,4,CH,GE,YY,
                  AND,20,2,CH,GE,MM,
                  AND,23,2,CH,GE,DD),OR,17,10,CH,EQ,C' '),
  BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jun 26, 2012 9:22 pm    Post subject: Reply to: Date Field Compare using DFSORT
Reply with quote

No problem. I wasn't clear about the "loose it later" - meant no need for the BUILD as nothing was extended, so nothing to be lost to just leave the original.

EDIT: Not sure that way any clearer :-)
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jun 26, 2012 9:50 pm    Post subject: Reply to: Date Field Compare using DFSORT
Reply with quote

techslam,

Please do NOT complicate a simple problem. SYMNAMES is the opitmal solution. Use the following DFSORT JCL which will give you the desired results. I assumed that both dates are of the format CCYY-MM-DD format.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
2012-01-01                                                           
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)           
//SYSIN    DD *                                                     
  OPTION COPY,STOPAFT=1                                             
----+----1----+----2----+----3----+----4----+----5----+----6----+----
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),HEADER1=('DT,C''',1,10,C'''')
//*                                                                 
//STEP0200 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SYMNAMES DD DSN=&&S,DISP=(OLD,PASS)                               
//SORTIN   DD *                                                     
FIELD11 FIELD12 2012-03-01 FIELD14                                   
FIELD21 FIELD22 2012-04-01 FIELD24                                   
FIELD31 FIELD32 2011-06-01 FIELD34                                   
FIELD41 FIELD42            FIELD44                                   
FIELD51 FIELD52 2011-05-01 FIELD54                                   
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INCLUDE COND=(17,10,CH,EQ,C' ',OR,17,10,CH,GT,DT)                 
//*


Pandora-Box,

You missed the JNF1CNTL and JNF2CNTL on your JOINKEYS job where you overlaying Space in position 81 and 11.

You don't have to split the date to to compare. If the both dates are of the form CCYY-MM-DD you can use CH format to compare
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
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
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am


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