Then there should be two output files created both RECFM=FB LRECL=80
Out 1
abcd efg ijk
12345 fgrtjk doenf
Out 2
iernf jf urinc
uri cnf gj d o
abc
that split one input file into 2 based upon a file who each line is used as a pattern for splitting the File 1 into 2 parts
The pattern string(s) in File 2 can occur anywhere in File 1
Hi vvmanyam,
it can have 'n' records not just two also the position of such records in File 1 would be variable...i.e. anywhere within the line
Thanks
Nimesh
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Nimesh,
You need to do a better job of explaining the "rules". You seem to show a pattern file2 that has 2-character strings that can appear anywhere in file1. Does any match of characters from file2 in file1 mean you want that file1 record for output? We have no way of knowing if file2 can only have a single 2-character string in each record, or different length strings in each record, or multiple strings in each record or what. You need to be very specific about what file2 can look like and what you're trying to match in file1 from file2.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
In addition to posting better "rules", it would be a big help if you posted more realistic sample data rather than alphabet soup. If your real data must not be disclosed, fine, but realistic sample data can still be posted.
If you explain the business requirement, i believe it will be much more understandable to all who read this.
Hi All,
Thanks for the input, please find the details below
Rules
1. pattern file i.e. File2 can have multiple records but one line would only contain one single pattern and would be unique within the file File2, the length of the same could also be varying [even though file is FB hence remaining would be spaces]
Code:
ex file2
9611-1963-7941.........................
9611-1965-7941.........................
961179657951...........................
7611-4876-1342.........................
NV-0150128090..........................
2. the pattern can occur anywhere within a record in File1 and there may be more than one pattern lying in a record
in the above case record 3 of File1 has 2 patterns in it so the intermediate step in JCL may return this record twice but at the end the final file Out1 would be sorted uniquely.
Out2 would be prepared after final Out1 has been sorted then Out2 would be difference between File1 and Out1
3. the search for each pattern has to be an exact search for ex File1 may have records like
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Nimesh.Srivastava,
You haven't defined the rules of the pattern. How did you pick only record 3 from file 1 has a pattern? Unless you come with up clear cut rules of picking the pattern , there is nothing that we can help you with. You are better off writing a program.
Hi Kolusu,
Thanks for the reply...
record 3 of File1 has multiple matching patterns in it [as per Rule 2]
there isn't a fixed position where the pattern may or may not occur in File1.
its like searching on Windows in a particular folder all the files [here records in File] with "A word or phrase in the file [here each record of File2]"
Yes, programming wise its like
Read till end of File2
for each record of File2
Read till end of File1
for each record of File1
if strstr(Rec_File1,Rec_File2) [searches for occurence of string
Rec_File2 in string Rec_File1]
returns FOUND then write Rec_File1 in Out1
for-loop end for File1
for-loop end for File2
sort Out1 and compare Out1 & File1, report records not in Out1 but existing in File1 to Out2
but my concern was if File1 is very big then it could be time consuming to do the same programmatically; hence looking for DFSORT solution.
Please let me know if the rules are ok now
Thanks
Nimesh
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello Nimesh.Srivastava,
Quote:
but my concern was if File1 is very big then it could be time consuming to do the same programmatically
No matter how you do this, it will consume a lot of cpu time.
The good news is that it would not be difficult to code in COBOL It would be better to use multiple steps rather than trying to "do it all" in one bit of code.
COMPMAC( keep this macro in the same rexx lib)
DSN2 = DATASET 2
"ALLOC FI(REPT) DA('"DSN2"') SHR REUSE"
"EXECIO * DISKR REPT (STEM INP2. FINIS)"
ADDRESS TSO ISREDIT MACRO
COUNT = INP2.0
COUNT1 = COUNT - 1
INP = INP2.1
"ISREDIT X ALL"
"ISREDIT F ALL " '"'INP'"'
DO J = 2 TO COUNT1
INP = INP2.J
"ISREDIT F ALL " '"'INP'"'
END
INP = INP2.COUNT
"ISREDIT F ALL " '"'INP'"'
"ISREDIT DELETE ALL X"
"ISREDIT SAVE"
"ISREDIT END"
RETURN
By this u can get all the matching records in first file in second file itself. Please make sure that u parse the strings from the second file when u do a F ALL.
Hi All,
I tried another way of handling this requirement of mine by mix'n'match SUPERC with DFSORT.
I can dynamically create a JCL from my C/C++ program using paramters of File2, which looks like
THE FOLLOWING PROCESS STATEMENTS (USING COLUMNS 1:72) WERE PROCESSED:
SRCHFOR '9611-1963-7941'
SRCHFOR '9611-1965-7941'
SRCHFOR '961179657951'
SRCHFOR '7611-4876-1342'
SRCHFOR 'NV-0150128090'
now the records which are found have the records no's from position 3-8 in the output file; which I tried extracting using DFSORT