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

if i am reading a file with some 50000 records and moving to a DB2 table and suddenly the program abends in between, is there anyway i could restart from the exact record at which the job failed once the program restarts.

2 Answers   UST,


input:- 12233344445555566666... output:- 1=1,2=4,3=9... Here firstno i.e 1 should be displayed and after that the alikeno.s should be added n displayed.i.e 2+2=4 like tat it goeson.

1 Answers  


sample code for read a 2nd record from last in flatfile how can do?

4 Answers   iNautix,


How can you submit a job from COBOL programs?

2 Answers   ITC Infotech,


What care has to be taken to force program to execute above 16 Meg line?

1 Answers  






What is comp-1 and comp-2?

0 Answers  


can any one give good example for cond 88 level number and for renames pls urgent dudes ?

3 Answers   DELL,


How may divisions are there in JCL-COBOL?

5 Answers   IBM,


In which area will you utilize 88 level items in cobol?

0 Answers  


What does the IS NUMERIC clause establish ?

2 Answers  


how we rectify soc4 and soc7 error in project(need real time answer)? please reply

3 Answers   HCL, Wipro,


What is the difference between performing a SECTION and a PARAGRAPH?

5 Answers   Accenture, Patni,


Categories