View previous topic :: View next topic
|
Author |
Message |
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
Hi
I have a requirement as follows. I wrote a cobol program already. But its not efficient enough. I'm looking for an alternative using utilities. Please help. --------->
inputs:
File 1 :RECL=80
File 2 :RECL=81
Output:
File 3 :RECL=80
reqmt:
If record from file1 has match in postions 1-75 with any of the records in file2 AND 81st postion of file2 record is "A", Overlay the 76-80 bytes of file1 with the value from file2 same bytes and put in output
If record from file1 has match in postions 1-75 with any of the records in file2 AND 81st postion of file2 record is "B", eliminate the record.
If a record from file1 has no match in file2, write in file3
Eg:
File1:
1111111111111111.....11111
2222222222222222.....22222
3333333333333333.....33333
4444444444444444......44444
File2:
1111111111111111.....99999A
3333333333333333.....33333B
OUTPUT FILE3
1111111111111111.....99999
2222222222222222.....22222
4444444444444444.....44444 |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Shanu,
By any chance do you get duplicate records (between 1-75 columns which is considered as key) in both the files? If you have unique records -
(1) Extract all the 'A' records from the second file and build first 80 columns only (say this as tempfile).
(2) Concatenate above tempfile with file1 (in the order). Use ICETOOL SELECT FROM(....) TO(....) ON(1,75,CH) FIRST option to get the wanted records. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please clarify this
Quote: |
I wrote a cobol program already. But its not efficient enough |
What measurement is being used to determine efficiency?
How many records are in the 2 files?
Both files are in the same sequence, right?
The COBOL code only reads each record one time? |
|
Back to top |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
There is no seq for the records. The program reads just one from file1 and compares with all in file2. Moreover I am not supposed to sort it. Usual counts are around 30K for file1 and 1K for file2. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
You are not supposed to sort it (like in classroom exercise) or not supposed to change its current sequence (like in sort/match/sort back to original sequence)? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please explain what business function might be supported by comparing 2 files that are not related (i.e. data sorted in the same sequence)?
Even if this is a student problem, it does not sound like it relates to the sort of requirements a student would be given when a programming position was found after graduating. . . .
Maybe there is more info that we are not aware of. . . . |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Sounds a lot like the thread in the PL/1 forum. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Yup, other than record counts if i recall correctly. . . |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
ICETOOL SOLUTION FOR YOR QUESTION IS AS FOLLOWS:
Code: |
//*******************************************************
//STEP001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
1111111111111111.....11111
2222222222222222.....22222
3333333333333333.....33333
4444444444444444.....44444
/*
//IN2 DD *
1111111111111111.....99999A
3333333333333333.....33333B
/*
//TMP1 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//BOTH DD SYSOUT=*
//F1ONLY DD SYSOUT=*
//F2ONLY DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(TMP1) USING(CP01)
COPY FROM(IN2) TO(TMP1) USING(CP02)
SPLICE FROM(TMP1) TO(BOTH) ON(1,16,CH) WITH(17,12) WITH(41,1) -
USING(CP03) KEEPNODUPS
/*
//CP01CNTL DD *
OUTREC BUILD=(1,30,40:C'11')
/*
//CP02CNTL DD *
OUTREC BUILD=(1,30,40:C'22')
/*
//CP03CNTL DD *
OUTFIL FNAMES=BOTH,INCLUDE=(40,2,CH,EQ,C'12'),BUILD=(1,30)
OUTFIL FNAMES=F1ONLY,INCLUDE=(40,2,CH,EQ,C'11'),BUILD=(1,30)
OUTFIL FNAMES=F2ONLY,INCLUDE=(40,2,CH,EQ,C'22'),BUILD=(1,30)
/*
|
Now the o/p BOTH contains:
Code: |
1111111111111111.....99999A
3333333333333333.....33333B
|
and the o/p F1ONLY conatins
Code: |
2222222222222222.....22222
4444444444444444.....44444
|
Now merge both the files -(BOTH & F1ONLY), by omiting the records that contain 'B' in 27th position.
Hope this is wt u required. |
|
Back to top |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
dick scherrer wrote: |
Hello,
Please explain what business function might be supported by comparing 2 files that are not related (i.e. data sorted in the same sequence)?
Even if this is a student problem, it does not sound like it relates to the sort of requirements a student would be given when a programming position was found after graduating. . . .
Maybe there is more info that we are not aware of. . . . |
It is financial level information that comes to my system and ouput goes to another vendor. Both the files come from 2 vendors and it should be in the order of file1. In between it should be processed in the above explained way. So I should not change the sequence. I'm sorry that I cannot brief the business implication here. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The explained way may not always give good/accurate results as well as taking a very large amount of machine resources.
How should duplicates in either file be handled?
Is there some reason the files cannot be sorted into "new" work files and compared? What does the "explained way" provide that working with the same data properly ordered would not? When the work files were built, a "sequence number" could be appended so that there would be a reference back to the original input if that was needed. . . |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Shanu.sukoor
did u try my code? |
|
Back to top |
|
|
|