have in 100 records in a file i want to move only matched
records to one output_file1 and nonmathed records are
moved to another output_file2 ... any one can provide
logic code

Answers were Sorted based on User's Feedback



have in 100 records in a file i want to move only matched records to one output_file1 and nonmathe..

Answer / ananth

Use Syncsort or Dfsort for this.

//S001 EXEC PGM=SORT
//SORTIN DD DSN=inputfile,DISP=SHR
//SORTOF01 DD DSN=dsn.match,DISP=(NEW,CATLG)
//SORTOF02 DD DSN=dsn.unmatch,DISP=(NEW,CATLG)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,5,CH,A)
OUTFIL FNAMES=01,INCLUDE=(1,5,CH,EQ,C'A1000')->for match
OUTFIL FNAMES=02,INCLUDE=(1,5,CH,NE,C'A1000')->for nonmatch
/*

Is This Answer Correct ?    7 Yes 0 No

have in 100 records in a file i want to move only matched records to one output_file1 and nonmathe..

Answer / abhay

WE CAN SOLVE THIS PROBLEM THROUGH 2 METHODS..
1) THROUGH JCL:
By using ICEMAN utility, it cab be done as below:
//S1 EXEC PGM=ICEMAN
//DD1 DD DSN=.....
//DD2 DD DSN=....
.
.
//SYSIN DD *
SELECT FROM INDD(DD1) TO OUTDD(DD2) ON (1, 4 CH, A) ALLDUPS
SELECT FROM INDD(DD1) TO OUTDD(DD2) ON (1, 4 CH, A) NONDUPS
*/
//
2) THROUGH COBOL PROGRAM:
AS BELOW

1)FIRST SORT 2 FILES ON ANY KEY
2)READ 2 FILES FOR MATCHING KEYS.IF KEY OF 2 FILES MATCHED,
THEN PUT RECORDS INTO FILE3 ELSE MOVE IT INTO FILE4
3)REPEAT THE PROCESS UNTIL END-OF-FILE1 AND END-OF-FILE2.

Is This Answer Correct ?    1 Yes 1 No

have in 100 records in a file i want to move only matched records to one output_file1 and nonmathe..

Answer / abhay

BY USING SORT UTILITY, WE CAN DO THE SAME..
1)
//S1 EXEC PGM=SORT
//F1 DD DSN=.....
//F2 DD DSN=.....
.
.
//SYSIN DD *
SORT FIELDS=(1,4,CH,A)--> FIRST SORT ON ANY KEY
OUTFIL FILE 1 INREC FILEDS=(10,5,CH,EQ,C'A')--> CONTAINS
RECORDS WHOSE NAME STARTS FROM LETTER A
OUTFIL FILE 2 INREC FILEDS=(10,5,CH,NE,C'A')--> CONTAINS
RECORDS WHOSE NAME DOES NOT START FROM LETTER A(i.e. letter
other than that 'A')
*/
//

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More COBOL Interview Questions

WHAT IS SOC3?HOW IT CAN BE RESOLVED?

1 Answers  


How would the number +1234 be stored if a PIC clause of PICTUREs9(4) comp-3 were used?

6 Answers  


how to fetch the record before the last record in a cobol file( its a huge file and if the key field is not known)

5 Answers   IBM,


How is sign stored in Packed Decimal fields and Zoned Decimal fields?

6 Answers   ABC, HCL, TCS,


soc-7 is a bad data,invalid data. when ever we are moving the alphabets in the position of numeric then we got this abend. so my question is if o1 ws-data pic 9(1) value passing the alphabet some x. then we got soc-7 or not? i want clarification ?

7 Answers   CitiGroup, IBM,






How does IDMS communicate with CICS?

1 Answers   Covansys, Satyam,


What is an explicit scope terminator?

3 Answers  


consider the following FD FILE-1 01 REC-1 PIC X(80) ...... WORKING-STORAGE SECTION 01 W-REC PIC X(90) ........ PROCEDURE DIVISION FIRST-PARA ....... READ FILE-1 INTO W-REC AT END MOVE 1 TO EOF-FLAG which of the following is true with respect to the above? a.REC-1 will contain nothing and W-REC will contain the contains of the record read b.REC-1 and W-REC contain the same data c.syntex is invalid and error will occur d.REC-1 and W-REC must be of same size

1 Answers   TCS,


What is the difference between binary search and sequential search?

0 Answers  


How many bytes do a s9 (7) comp-3 field occupy?

1 Answers  


What is the difference between a binary search and a sequential search? What are the pertinent cobol commands?

0 Answers  


What are differences between Static Call and Dynamic Call?

10 Answers   IBM, KBC, Keane India Ltd, Verizon,


Categories