Posted: Tue Feb 24, 2009 1:34 am Post subject: Search using sort
Hi all,
I have a situation here...
I have two input files A and B.
I need to pick up the search string from the input file A for the first record, let us say at pos(30-40) and do a search for that string in the input file B. If i get any match, will write that matching record in to an output file. This search needs to be done for all the records in the input file A one by one irrespective of whther it gets any matching record or not in the input file B.
watever may be the output, it should go to the second record and pick up the search string and do the search in the input file B.
I tried to do this using COBOL. I'm getting some error.
Please Guide me on this. Is it possible using DFSORT or SYNCSORT??
Joined: 14 Jan 2009 Posts: 37 Topics: 0 Location: USA
Posted: Tue Feb 24, 2009 12:03 pm Post subject:
waves: If the 'search string' field in input file B is at a particular location within the input file B record, then this can probably be done using SyncSort's JOIN processing. SyncSort's JOIN processing can be used to essentially function like an INCLUDE, where input file A contains all the values on which you want to search, so that you can match any of these values to any record in input file B. The length of the 'search string' field would have to be the same for both input files, but the location within input file A could be different from the location within input file B.
If you think using SyncSort's JOIN might be able to help, please contact me at zos_tech@syncsort.com and I will email you some simple examples. Here is a simple example of code I wrote recently to select only those records from input File 2 that matched the selection criteria I built into File 1:
Along the same lines as Brian, here is A sort that will write 3 different output files with one pass of the data.
File One -> records with like keys on both input files
File Two -> reocrods that only exist on file 1
File Three -> records that only exist on file 2
Code:
//SRTFIL1 EXEC PGM=SYNCSORT,COND=(0,LT)
//*
//SORTJNF1 DD *
12345I AM ON BOTH FILES
12346I AM ONLY ON FILE ONE
//*
//SORTJNF2 DD *
12345I AM ON BOTH FILES
12347I AM ONLY ON FILE TWO
//*
//SYSIN DD *
JOINKEYS FILE=F1,
FIELDS=(001,05,A) *Input File One
JOINKEYS FILE=F2,
FIELDS=(006,05,A) *Input File Two
JOIN UNPAIRED
REFORMAT FIELDS=(F1:01,05,6,30,F2:06,05,11,30)
SORT FIELDS=COPY
SUM FIELDS=NONE
OUTFIL FNAMES=BOTH,
INCLUDE=(01,05,CH,EQ,36,05,CH)
OUTFIL FNAMES=FIL1O,
INCLUDE=(36,01,CH,EQ,C' ')
OUTFIL FNAMES=FIL2O,
INCLUDE=(01,01,CH,EQ,C' ')
//BOTH DD SYSOUT=*
//FIL1O DD SYSOUT=*
//FIL2O DD SYSOUT=*
File One (BOTH)
Code:
********************************* TOP OF DATA **********************************
12345I AM ON BOTH FILES 12345I AM ON BOTH FILES
******************************** BOTTOM OF DATA ********************************
File Two (FIL1O)
Code:
********************************* TOP OF DATA **********************************
12346I AM ONLY ON FILE ONE
******************************** BOTTOM OF DATA ********************************
File Three (FIL2O)
Code:
********************************* TOP OF DATA **********************************
12347I AM ONLY ON FILE TWO
******************************** BOTTOM OF DATA ********************************
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum