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 a File that has duplicate records. I need only those records that occur more than
thrice.?

Answers were Sorted based on User's Feedback



I have a File that has duplicate records. I need only those records that occur more than thrice.?..

Answer / harsha

1 Sort the file on any key
2 Read file sequentially. While reading, store the record
in a working storage temporary variable and add count
counter variable.
3 Every time you read record, compare it with temporary
variable. if it is same increase counter otherwise reset
counter.
4 When counter become greater than three, write record to
an outfile.

Is This Answer Correct ?    4 Yes 3 No

I have a File that has duplicate records. I need only those records that occur more than thrice.?..

Answer / supreethi

Code:
//*******************************************************
//STEP001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
AAAAAAAAA
VVVVVVVVV
GGGGGGGG
AAAAAAAAA
HHHHHHHHH
AAAAAAAAA
GGGGGGGG
VVVVVVVVV
/*
//TMP1 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OCCUR1 DD SYSOUT=*
//OCCUR2 DD SYSOUT=*
//OCCUR3 DD SYSOUT=*
//TOOLIN DD *
OCCUR FROM(IN1) LIST(OCCUR1) EQUAL(1)-
ON(1,9,CH) ON(VALCNT,N04)
OCCUR FROM(IN1) LIST(OCCUR2) EQUAL(2)-
ON(1,9,CH) ON(VALCNT,N04)
OCCUR FROM(IN1) LIST(OCCUR3) EQUAL(3)-
ON(1,9,CH) ON(VALCNT,N04)
/*


OCCUR1 contains:

Code:
---+----1----+----2----+
(1,9,CH) VALUE COUNT
HHHHHHHHH 1

OCCUR2 contains:

Code:
---+----1----+----2----+
(1,9,CH) VALUE COUNT
GGGGGGGG 2
VVVVVVVVV 2

OCCUR3 conatains:

Code:
---+----1----+----2----+
(1,9,CH) VALUE COUNT
AAAAAAAAA 3

Is This Answer Correct ?    0 Yes 0 No

I have a File that has duplicate records. I need only those records that occur more than thrice.?..

Answer / nsingh

DEFINE A TABLE

01 TABLE.
05 TABLE-A OCCURS 500 TIMES
INDEXED BY IDX
10 TEXT PIC X(100)
10 COUNT PIC9(4).

01 W-REC PIC X(100).
01 W-OUT PIC X(100).
01 SUB S9(4) COMP VALUE 0
PROCEDURE DIVISION.

INITIALIZE TABLE-A

READ-PARA.
READ F1 IN W-REC
AT END
SET IDX TO 1
PERFORM VARING SUB FROM 1 BY 1 UNTIL SUB > 500
IF COUNT(IDX) > 3
WRITE W-OUT FROM TEXT(IDX)
ELSE
SET IDX UP BY 1
END-IF
END-PERFORM
STOPRUN
NOT AT-END
CONTINUE
END-READ

SEARCH TABLE-A
AT END
PERFORM TABLE-ENTRY
WHEN W-REC = TEXT(IDX)
ADD +1 TO COUNT
END-SEARCH

GO TO READ-PARA

TABLE-ENTRY.
SET IDX TO 1
PERFORM VARYING SUB FROM 1 BY 1
UNTIL SUB > 500
IF TEXT (IDX) = SPACES
MOVE 1 TO COUNT (IDX)
MOVE W-REC TO TEXT (IDX)
ELSE
SET IDX UP BY 1
END-IF
END-PERFORM

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More COBOL Interview Questions

The disposition parameter in the jcl is share ( DISP+SHR ) and the program opens file in extend mode what will happen?

6 Answers   Cognizant,


If I want to increase the Limit in GDG. What should I do?

1 Answers   IBM,


How many times the loop runs here 01 a pic 9(2) value 10. perform para1 a times stop run. para1: move 20 to a.

3 Answers  


If i got a job on mainframe technology, will i have a bright future?. Some people are discouraging me. Let me know, is it true? Please bring back me from the confusion.

2 Answers  


What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program ?

3 Answers  


How do u find the programs calling the given module, without having doing 3.13 on loadlib/source library?

2 Answers  


wht do u mean by (*,intrdr) wht is * used for ?

2 Answers  


hi is there any means of deletin a record from a ps usin cobol not using jcl?eg if i am reading a record and if some condition is matched tat particular record must be deletd fom the ps

5 Answers   iNautix,


what is the difference between Normal vaiable and comp variable.

5 Answers   DELL,


What is diff betn PS and ESDS file? What is the diffrent compiler options in cobol and there discription? What is retrive nth maximum salary from salary DB2 table. Can we redefine COM-3 variable with varchar variable?

4 Answers  


I have 100 records in a file.. i want to sort the records from 5 to 5o... give the syntax...

2 Answers   CTS, DSRC,


I have a occurs for 100 times but it has executed 101 time what could be the reason?

4 Answers  


Categories