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 ?    6 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

Have you used comp and comp-3 in your project? And how?

0 Answers   IBM,


When is inspect verb is used in cobol?

0 Answers  


What is rmode(any) ?

0 Answers  


What are 77 levels used for?

0 Answers  


example for sub strings ? and refernce modifications whit output pls

0 Answers   IBM, College School Exams Tests,






whats the disadvantage of search all over search?

4 Answers   TCS, Patni,


Determine the total no of bytes in the following. 01 rec1. 02 a pic x(6) 02 b redefines a. 03 c occus 6 times pic 9. 02 d occurs 6 times pic 9. 03 e pic x(5) 03 f pic 999.

12 Answers  


whats the difference between search and search all?

4 Answers   Patni,


What are ISOLATION LEVELS? Where do we need to specify them in compiling JCL (Exactly which statement and what is syntax for it)?

2 Answers   T systems,


Without using move verb how to move one variable to another.

5 Answers  


in real time what is the suitable exp where in-stream procedure is better then catalog procedure.

1 Answers  


consider the following piece of code 01 GROUP-ITEM 05 AMOUNT-1 PIC 99V9 USAGE COMP VALUE 50 05 AMOUNT-2 PIC 9(4)V99 USAGE COMP MOVE ZERO TO GROUP-ITEM ADD 50 TO AMOUNT-1 what will be the content of AMOUNT-1? a.50 b.100 c.0 d.unpredictable

10 Answers   TCS,






Categories