Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


I have dataset DS1 which has records say
1
2
3
4
5
...
...
etc

And also I have second dataset DS2 whcih has records
1
3
4
5
6
8
..
...

Both the files are sorted and now I want to compare these files and write it into the third files if the records are matching.

Answers were Sorted based on User's Feedback



I have dataset DS1 which has records say 1 2 3 4 5 ... ... etc And also I have second ..

Answer / vivek c

A simple way to take the matching records if there are no duplicates in both the files.

1. Merge both the files and take the duplicates in separate file using XSUM.

//S010 EXEC PGM=SORT
//SORTIN DD DSN=DSN1
// DD DSN=DSN2
//SORTOUT DD DSN=DSNOUT
//XSUM DD DSN=DSN.MATCH
//SYSIN DD *
SORT FIELDS=(1,1,CH,A)
SUM FIELDS=NONE,XSUM

The output DSN.MATCH will have the matched records.

Is This Answer Correct ?    7 Yes 0 No

I have dataset DS1 which has records say 1 2 3 4 5 ... ... etc And also I have second ..

Answer / harsha

Use following JCL
//STEP010 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//FILEIN DD DSN=XXXXXXXXXXXXXX,DISP=SHR
//TOOLIN DD *
SELECT FROM(FILEIN) TO(UNIQFL) -
ON(1,73,CH) NODUPS
SELECT FROM(FILEIN) TO(DUPFL) -
ON(1,73,CH) ALLDUPS
/*
//*
//DUPFL DD SYSOUT=*
//UNIQFL DD SYSOUT=*
//*

Label DUPFL will show all duplicate records
Label UNIQFL will show all unique records

Is This Answer Correct ?    1 Yes 1 No

I have dataset DS1 which has records say 1 2 3 4 5 ... ... etc And also I have second ..

Answer / leo

Using matching logic:

perform following code until either of EOF is found.

EVALUATE TRUE

WHEN KEY1> KEY2
READ FILE2
WHEN KEY2> KEY1
READ FILE1
WHEN KEY1=KEY2
WRITE FILE3 (WHATEVER FORMAT YOU WANT)
READ FILE1
READ FILE 2

END-EVALUATE

You can perform above code until both EOF found, incase you
need to create another file for non matching records. for
matching records only performing until either of EOF will
work.

~LEO

Is This Answer Correct ?    1 Yes 1 No

I have dataset DS1 which has records say 1 2 3 4 5 ... ... etc And also I have second ..

Answer / ganesh

Okay Agree with above solution. Now tell me how to do using COBOL Read statement logic.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More COBOL Interview Questions

what is redefines? where it can be effectively use for the purpose of memory utilization? give an example?

4 Answers   IBM,


file status 00 is checked after opening the file or reading the file

4 Answers   John Deere,


can we use full outer join with cursors declared in cobol program?

2 Answers  


Syntax for JCLLIB & JOBLIB???

1 Answers  


Give some advantages of REDEFINES clause?

2 Answers   Syntel,


how to transfer the file from pc to mainframe??

2 Answers  


write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc

0 Answers  


how to change picture class of copy book variable inside program?

2 Answers  


What is the difference beetween Arrays and Tables in Cobol? please dont give the answer that arrays in cobol terminology is called tables......

3 Answers   BirlaSoft,


maximum of how many screens we can open in emulator

2 Answers  


What is R-mode and A-mode?

3 Answers   TCS,


what happens when a copybook variables are declared using include statement ?

3 Answers   IBM,


Categories