GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Mainframe
Next Question 
 Mainframe  |  Question 1 of 55    Print  
I have 3 files . 2 files have millions of records.These 2 files have one ( empnumber) common record field. i want to put those records in 3rd file , such that which records having same number in key field (empnumber)in these two files ?

  
Total Answers and Comments: 9 Last Update: July 16, 2008     Asked by: mark 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 11, 2005 06:21:02   #1  
Rams        

RE: i have 3 files . 2 files have millions of recor...

Hello

Please follow the below steps.

Step 1 : Sort file1 and file2 based on empnumber

Step 2 : Write a program such that the program logic should compare the empnumber of both sorted-files and for matching empnumbers write the corresponding records into third file

Note : This is the one of the ways you can meet the solution. Thanks.


 
Is this answer useful? Yes | No
November 15, 2005 04:56:12   #2  
Abhishek Ule        

RE: i have 3 files . 2 files have millions of recor...
This can be done by IBM utility ICETOOL
 
Is this answer useful? Yes | No
October 19, 2006 22:05:43   #3  
ofcourseman Member Since: October 2006   Contribution: 10    

RE: i have 3 files . 2 files have millions of recor...

I know how to find out which emp numbers are in both files by JCL but how to do next step just by JCL without coding a program.

Is there anybody can help me to solve this problem?

Thanks.


 
Is this answer useful? Yes | No
November 13, 2006 06:44:16   #4  
vishnu kumar gupta        

RE: i have 3 files . 2 files have millions of recor...
I think this can be achieved by include or exclude conditional statement in A JCL itself.
 
Is this answer useful? Yes | No
July 09, 2007 06:33:27   #5  
ajayre Member Since: July 2007   Contribution: 1    

RE: I have 3 files . 2 files have millions of records....
HI This can be done in the same JCL .1.Sort first two files and then merge both the records based on EMPNUMBER ok. For Merging of Two Datasets they should have same Record length as Well as Same Record Format and more over the Records in Both Datasets Should be Sorted prior to Merge.If we take same Record Structure as an Example if Two data sets with above record format are to be MERGED then SORT CARD Should look as MERGE FIELDS ( starting position length A (asending/des) ) FORMAT CH OUTREC FIELDS ( same as above) now all matched records will be written into third file. OR If the format is different etc....Ex 1: record one lokks like name salary accno empnumber ajaykumar 20000 12345 23456 Record 2: name empnumber salary department ..... rajesh 23546 10 000 .........inthese case at the time of sorting both files use the below code and write into onother file sortfields copy . out fileds ( empnumber position and length from the input record and then remaining record .....)In this outrec field you can give any filed first based on the order which you specified record will be written in to the out file.the first record shoud be like : out rec (empnu start length type name ----------------------- salr.................................) here you need to give position and length okIn the same manner write the second recod in to onother file as first filed shound be empnumber .now you can merge both records and then write in to second file .Still if you have any doubts let me know .2.If format and length or different then you need write a program like below .read both files and move to working storage variables and the match it and write in to third record
 
Is this answer useful? Yes | No
September 08, 2007 04:00:03   #6  
harini.suswaram Member Since: September 2007   Contribution: 1    

RE: I have 3 files . 2 files have millions of records....

We can achieve this by using the Sort Join (in a JCL). The following steps in a sort card will move all the records from the two files having the same emp no into the third file:
STEP001 SORT
SORTNJF1 DD DSN INPUT1 DISP SHR

SORTNJF2 DD DSN INPUT2 DISP SHR


SORTOF1 DD DSN OUTPUT1 DISP (NEW CATLG DELETE)

SYSIN DD *
JOINKEYS FILE1 (1 3 CH) --Assuming emp no is of len 3 starting in position 1 of file1

JOINKEYS FILE2 (1 3 CH) --Assuming emp no is of len 3 starting in position 1 of file2


REFORMAT FIELDS (F1:1 100 F2:4 50) -- copies the rcords from both the input files into the output (from pos 1 of i/p file1 and position 4 of i/p file2
SORT FIELDS (1 3 CH A) -- sorts the output file based on the empno

OUTFIL FILES 1
/*


 
Is this answer useful? Yes | No
November 16, 2007 02:19:41   #7  
subrahmanyam.b        

RE: I have 3 files . 2 files have millions of records....
Hi abhishek

As per ur coments this can be solved by ICETOOL
Can you please explain with more details to resolve this problem by ICETOOL.

Thanks
subbu

 
Is this answer useful? Yes | No
December 26, 2007 09:46:35   #8  
kishoremain Member Since: July 2007   Contribution: 3    

RE: I have 3 files . 2 files have millions of records.These 2 files have one ( empnumber) common record field. i want to put those records in 3rd file , such that which records having same number in key field (empnumber)in these two files ?

Try


PROCEDURE DIVISION.
OPEN INPUT FILE1 FILE2.
DISPLAY FS1 FS2.
OPEN OUTPUT FILE3.
DISPLAY FS3.
PERFORM UNTIL EOF 'YES'
READ FILE1 AT END MOVE 'YES' TO EOF
PERFORM CLOSE-PARA
NOT AT END
READ FILE2 AT END MOVE 'YES' TO EOF
PERFORM CLOSE-PARA
NOT AT END
IF EMPNO1 EMPNO2
MOVE
REC1 TO REC3
WRITE REC3
MOVE
REC2 TO REC3
WRITE REC3
END-PERFORM.
CLOSE-PARA.
CLOSE FILE1 FILE2 FILE3.
STOP RUN.


 
Is this answer useful? Yes | No
July 16, 2008 03:44:37   #9  
depak_83 Member Since: July 2008   Contribution: 1    

RE: I have 3 files . 2 files have millions of records.These 2 files have one ( empnumber) common record field. i want to put those records in 3rd file , such that which records having same number in key field (empnumber)in these two files ?
You can use the bleow sort card in your JCL

//SYSIN DD *
MERGE FIELDS (21 11 A) FORMAT BI
SUM FIELDS NONE
/*

21 - Starting position of the EMP field
11- is the length of the field.

This would merge the 2 files based on the EMP number into the 3rd file

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape