View previous topic :: View next topic
|
Author |
Message |
rally
New User
Joined: 28 Jul 2005 Posts: 37
|
|
|
|
Hi,
I have 2 files (file one and two).
File One
Filed A (date)
20030101xxxx
20050401xxxx
20090501xxxx
20080401xxxx
20090101xxxx
File B
File B (date)
20080101aaaaaaaaaaaaaaaa
What I want to compare date from File one against date B from file two.
Below is the expeted output:
20090501xxxx
20080401xxxx
20090101xxxx
That is to say, the records in file one with date A > date B in file two
need write to output file.
I think DFSORT should can do this, but I cannot think over the solution...
Please help advise. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
this might help
Code: |
//STEP010 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SORTIN DD *
20080101AAAAAAAAAAAAAAAA
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
* CREATE DFSORT SYMBOL AS:
* YYMMDD,20080101
OUTFIL FNAMES=SORTOUT,
BUILD=(C'YYYYMMDD,''',1,8,C'''',80:X)
/*
//STEP020 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=SHR
//SORTIN DD *
20030101XXXX
20050401XXXX
20090501XXXX
20080401XXXX
20090101XXXX
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(01,8,BI,GT,YYYYMMDD)
/* |
Gerry |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
A slightly streamlined version:
Code: |
//STEP010 EXEC PGM=SORT
//SORTIN DD *
20080101aaaaaaaaaaaaaaaa
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
* CREATE DFSORT SYMBOL AS:
* MYDATE,20080101
INREC BUILD=(C'MYDATE,''',1,8,C'''',80:X)
/*
//STEP020 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD *
20030101xxxx
20050401xxxx
20090501xxxx
20080401xxxx
20090101xxxx
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,8,CH,GT,MYDATE)
/*
|
|
|
Back to top |
|
|
rally
New User
Joined: 28 Jul 2005 Posts: 37
|
|
|
|
Thanks, this is very helpful for my job. |
|
Back to top |
|
|
rally
New User
Joined: 28 Jul 2005 Posts: 37
|
|
|
|
Frank,
Can we pass 2 fields from file one and compared in file two?
200801019999bbbb
INREC BUILD=(C'MYDATE,''',1,8,C'''',80:X)
We pass 2008080101 into MYDATE,
can we pass 9999 also in the same step to next step? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Sure. You just need to use OUTFIL with / instead of INREC like this:
Code: |
//STEP010 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SORTIN DD *
200801019999bbbb
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(C'MYDATE,''',1,8,C'''',80:X,/,
C'SYM2,''',9,4,C'''')
/*
|
&&S1 will have:
Code: |
MYDATE,'20080101'
SYM2,'9999'
|
Include &&S1 for SYMNAMES in the next step and you can use the MYDATE and SYM2 symbols there. |
|
Back to top |
|
|
rally
New User
Joined: 28 Jul 2005 Posts: 37
|
|
|
|
Let's say MYDATE is '20080101' and SYM2 is 0012.
How can we use these two sysnames to get new date.
for example, how to compute MYDATE + sym2?
By the way, is there any possible to convert CCYYMMDD to julian date use DFSORT only? Thanks. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rally wrote: |
Let's say MYDATE is '20080101' and SYM2 is 0012.
How can we use these two sysnames to get new date.
for example, how to compute MYDATE + sym2?
By the way, is there any possible to convert CCYYMMDD to julian date use DFSORT only? Thanks. |
DFSORT has the ability to add days to the current date but not any other date.
Check this link which shows you a way to convert the gregorian date to julian date
ibmmainframes.com/viewtopic.php?p=113841#113841 |
|
Back to top |
|
|
|
|