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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Can I pick out the records based on a value from a file
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 11, 2006 9:21 pm    Post subject:
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jan 12, 2006 3:03 am    Post subject:
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jan 12, 2006 10:42 pm    Post subject:
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jan 12, 2006 11:32 pm    Post subject:
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    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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
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 File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


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