View previous topic :: View next topic
Author
Message
Bharath RajaramSridharan New User Joined: 10 Dec 2012Posts: 20 Location: Australia
Hi,
I have two files with the date format as mentioned below.
File 1
DD/MM/YY
File 2
DD/MM/YY
I need to calculate the difference between the two dates and create a output record in the following layout. Could some one guide me pls.
$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(XXXXX)')
In the above record, XXXXX represents the number of days difference computed above.
Thanks
Bharath
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
That's not DFSORT code.
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Or Do you wanted to convert that into DFSORT?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Thanks Pandora-box. It is the "expected output", not the command to achieve something :-)
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Hi Does both the files have one record or more than 1?
Anytime Bill ... I did read it wrong the first time
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
Bharath RajaramSridharan,
Use the following DFSORT JCL which will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
21/01/13
//INB DD *
21/01/12
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,Y2PAST=1980
JOINKEYS F1=INA,FIELDS=(8,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(8,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,8,F2:1,8)
INREC BUILD=(C'$$DD01 COPY REPL=(55,EQ,C''',C'DAY( )''',C',C''',
C'DAY(',1,6,Y2T,DATEDIFF,9,6,Y2T,C')''',C')',80:X)
//*
//JNF1CNTL DD *
OPTION STOPAFT=1
INREC BUILD=(7,2,4,2,1,2,2X)
//*
//JNF2CNTL DD *
OPTION STOPAFT=1
INREC BUILD=(7,2,4,2,1,2,2X)
//*
The output from this is
Code:
$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(+0000366)')
Back to top
Bharath RajaramSridharan New User Joined: 10 Dec 2012Posts: 20 Location: Australia
Thanks Skolusu for helping me with the solution.
As I stated in my post, my requirement was to create the following card which would be used in a fileaid step after the sort, the XXXXX value can hold only 5 Chars.
$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(XXXXX)')
So after executing the sort card you have provided, I wrote another sort card to remove the sign bit and the leading two zeroes which the DATEDIFF command would return.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(+0000366)')
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC BUILD=(1,44,48,8,28X)
/*
The above job step would give me a reformatted card like the one below mentioned
$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(00366)')
Is there a way to incorporate the same functionality (To use only the last 5 bytes of the DATEDIFF) in the original sysin card itself which you have provided.
Thanks
Bharath
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
here is one way
Code:
OPTION COPY,Y2PAST=1980
JOINKEYS F1=INA,FIELDS=(8,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(8,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,8,F2:1,8)
INREC BUILD=(1,6,Y2T,DATEDIFF,9,6,Y2T)
OUTREC BUILD=(C'$$DD01 COPY REPL=(55,EQ,C''',C'DAY( )''',C',C''',
C'DAY(',4,5,C')''',C')',80:X)
Gerry
Back to top
Please enable JavaScript!