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

Can I pick out the records based on a value from a file


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

New User


Joined: 23 Jul 2005
Posts: 20

PostPosted: Wed Jan 11, 2006 2:26 pm
Reply with quote

I have to store current business date in fileA. I want to pick out the records from fileB whose date equals to that date in fileA.
How to write such sort statement ?

INCLUDE COND=(1,10,CH,EQ,C' I can't give any values here.
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 Jan 11, 2006 9:21 pm
Reply with quote

Please show an example of the records in fileA and fileB and what you want for the output records. What is the RECFM and LRECL of fileA and fileB? What is the starting position, length and format of the date fields?
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Jan 12, 2006 2:42 am
Reply with quote

Just curious abt how can we achieve this.
I have 2 input files:

infile 1
aaaaaaa 2006/01/11
aaaaaaa 2006/01/11
bbbbbbb 2001/01/11
cccccccc 2002/01/11
aabnmbj 2005/01/11
aaasdbg 2006/01/11
aaaaaaa 2006/01/11
ddddddd 2006/01/11
eeeeeee 2005/01/11

infile 2
2005/01/11
2006/01/11

Output file shud have only those records having a matchin date in the second file

outfile
aaaaaaa 2006/01/11
aaaaaaa 2006/01/11
cabnmbj 2005/01/11
aaasdbg 2006/01/11
aaaaaaa 2006/01/11
ddddddd 2006/01/11
eeeeeee 2005/01/11




Frank Yaeger wrote:
Please show an example of the records in fileA and fileB and what you want for the output records. What is the RECFM and LRECL of fileA and fileB? What is the starting position, length and format of the date fields?
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: Thu Jan 12, 2006 3:03 am
Reply with quote

The DFSORT/ICETOOL job below will do what you asked for. Since you want the records in their original order rather than sorted by the date, you need an extra SORT operator. I assumed that your input files have RECFM=FB and LRECL=80 but the jobs can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1
//IN2 DD DSN=...  input file2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file
//SYSUDUMP DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(9,10,CH) WITHALL WITH(1,88)
SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  OUTREC FIELDS=(9:1,10,88:X)
/*
//CTL2CNTL DD *
  OUTREC OVERLAY=(81:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
  SORT FIELDS=(81,8,ZD,A)
  OUTREC FIELDS=(1,80)
/*
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Jan 12, 2006 9:57 pm
Reply with quote

Frank,
I think this is not going to give me right output in some cases. Here my requirement is to check the existence of the dates in file 1 to that in file 2. But incase if I have this record 'bbbbbbb 2001/01/11' whose date is not in file 2 is occuring more than once like this

bbbbbbb 2001/01/11
kkkkkkk 2001/01/11

it's still going to give me an output like:
kkkkkkk 2001/01/11

So for those given set of records it working fine, but incase if i have dplicates dates in the file which are not present in the second file, its gonna give me wrong results.
So my basic requirement is to check the dates in the first file against those in the second file and then if present in the second file, copy them to the final output. Hope the requirement is clear.
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: Thu Jan 12, 2006 10:42 pm
Reply with quote

Quote:
I think this is not going to give me right output in some cases.


The job I showed gives the output you asked for based on the example you showed. I can't read your mind to determine what other cases you might have. Please show a complete example of all of the input cases and what you want for output, and I'll give you a job that satisfies all of the cases you show me.
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Jan 12, 2006 11:01 pm
Reply with quote

infile 1
aaaaaaa 2006/01/11
aaaaaaa 2006/01/11
bbbbbbb 2001/01/11
kkkkkkk 2001/01/11
cccccccc 2002/01/11
hhhhhhh 2002/01/11
aabnmbj 2005/01/11
aaasdbg 2006/01/11
aaaaaaa 2006/01/11
ddddddd 2006/01/11
eeeeeee 2005/01/11

infile 2
2005/01/11
2006/01/11

outfile
aaaaaaa 2006/01/11
aaaaaaa 2006/01/11
cabnmbj 2005/01/11
aaasdbg 2006/01/11
aaaaaaa 2006/01/11
ddddddd 2006/01/11
eeeeeee 2005/01/11

output file can be in any order.
but the records in the output file shud have a matching date in infile 2.
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: Thu Jan 12, 2006 11:32 pm
Reply with quote

This DFSORT/ICETOOL job will give you what you asked for.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1
//IN2 DD DSN=...  input file2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(9,10,CH) WITHALL WITH(1,89) USING(CTL3)
SORT FROM(T2) TO(OUT) USING(CTL4)
/*
//CTL1CNTL DD *
   OUTREC FIELDS=(9:1,10,89:C'11')
/*
//CTL2CNTL DD *
   OUTREC OVERLAY=(81:SEQNUM,8,ZD,89:C'22')
/*
//CTL3CNTL DD *
   OUTFIL FNAMES=T2,INCLUDE=(89,2,CH,EQ,C'21')
/*
//CTL4CNTL DD *
   SORT FIELDS=(81,8,ZD,A)
   OUTREC FIELDS=(1,80)
/*
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top