View previous topic :: View next topic
|
Author |
Message |
felixedwingeorge
New User
Joined: 18 Sep 2008 Posts: 2 Location: chennai
|
|
|
|
hi,
I have two sequential files file1 and file2. I have to retrieve the records which are present in File1 but not in File2 & update File2. Layout of File1 & File2 is 950 & 650 respectively. The common field which uniquely identifies the records is STUD-ID-CODE field
In File1
this field is present from record 1-11 [STUD-ID-CODE PIC X(11)]
In File2
this field is present from record 3-13 [05+04+02]
05 STUD-KEY.
10 STUD-QUAL PIC X(02).
10 STUD-NAT-CD-ID.
15 STUD-ID-CODE.
20 STUD-9.
25 STUD-ZONE-CD PIC X(05).
25 STUD-TYPE-CD PIC X(04).
20 STUD-HOST-ZONE-CD PIC X(02).
how I can solve this ? Is it possible to sort both the files & merge them and take the non duplicate records from the merged file (through ICE TOOL Utility) and then update file2 (Using COBOL PGM).
But the problem in merging is the record positions (STUD-ID-CODE) of two files are not the same. |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
HI,
Quote: |
I have to retrieve the records which are present in File1 but not in File2 & update File2.
|
Update File2 means? U want the records from FILE1 to FILE2. If that means which field position from File1 u want in File2. Because files are of different length 950 & 650. Can u explain more...
Regards
R KARTHIK |
|
Back to top |
|
|
felixedwingeorge
New User
Joined: 18 Sep 2008 Posts: 2 Location: chennai
|
|
|
|
Hi Karthik,
I want to add the records to file2. That is those records which is present in file1 but not in file2. eg: file1 contains A,B,C,D. File2 contains A,C.
Here the records b,d are not present in File2. So, I want to add these records in File2.
My Design:
1. Make the file2 to 950 Layout by adding a filename field of size 1 and rest add fillers.
2. Then call a cobol pgm which adds the filename as 'F' to all the records of file2.
3. Then using JCL to merge both the files and retrieve the nonduplicate rows and store it in merged-file.
4. Then using another cobol pgm which updates file2, with all the records in merged-file, whose filename field is not F. (If the 'Filename' field has the value 'F' then it denotes that particular record is from file2.) This helps us to add the records present only in File1 but not in File2.
Please tell me whether this design will work ? Can I get the feedbacks of this design ? or do you suggest any other technique ? |
|
Back to top |
|
|
hchinnam
New User
Joined: 18 Oct 2006 Posts: 73
|
|
|
|
You don't need COBOL to do that. See the ICETOOL example below.
Code: |
//S0001 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//STATA DD *
1
2
//STATB DD *
1 B
3 B
5 B
//T1 DD DISP=(MOD,PASS),DSN=&TEMP,SPACE=(TRK,(1,1))
//DDOUT DD SYSOUT=*
//CTL1CNTL DD *
INREC BUILD=(1:5,1)
//CTL2CNTL DD *
//TOOLIN DD *
COPY FROM(STATB) TO(T1)
COPY FROM(STATA) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(DDOUT) ON(1,1,CH) FIRST
|
This code is under the assumption that your infile1 has only key in it. If it is not the case, and you need to have a record with proper data from infile1 then you can change the CTL1CNTL accordingly. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
felixedwingeorge,
You really don't need a cobol program. Show me a sample of your input data with key information and the contents that you want to update from file 1 on to file2. Will be there be duplicates in any of the files? |
|
Back to top |
|
|
|