View previous topic :: View next topic
Author
Message
techslam New User Joined: 03 Dec 2010Posts: 87 Location: India
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
Naish New User Joined: 07 Dec 2006Posts: 82 Location: UK
Create SYMNAME for the first file (field). This is recently discussed. Suggest you search the forum.
Back to top
techslam New User Joined: 03 Dec 2010Posts: 87 Location: India
Any other option without going for SYMNAME ??
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
What if FILE2 also contains ??
Should it be considered or not??
Back to top
techslam New User Joined: 03 Dec 2010Posts: 87 Location: India
@Pandora-Box
Yes That must be considered too ... Thanks for pointing that out.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
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
Naish New User Joined: 07 Dec 2006Posts: 82 Location: UK
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
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Pandora-Box, maybe generate three literals, year, month and day. Then no need to OVERLAY or loose the OVERLAY later.
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
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
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
Please enable JavaScript!