IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How I'll find the duplicates in an array?


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sreddy

New User


Joined: 16 Mar 2005
Posts: 8
Location: Bangalore

PostPosted: Thu Apr 13, 2006 3:33 pm
Reply with quote

Hi

Can any one explain how I'll find the duplicates in an array?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Apr 13, 2006 10:02 pm
Reply with quote

sreddy,

Is this a CICS question, or a COBOL question? If COBOL, this should probable be posted in one of the COBOL forums.

Could you be more specific in your question please. What does the array structure look like, are you looking for 100% duplicates (every field equal) are just some key fields. What do you want to do with the duplicates when found?

The more information you can give, the better we can help.

Please come back

Dave
Back to top
View user's profile Send private message
sreddy

New User


Joined: 16 Mar 2005
Posts: 8
Location: Bangalore

PostPosted: Mon Apr 17, 2006 12:59 pm
Reply with quote

Ex:

Array of 10 elements.

Like A C D B C A S R P D

My requirement is to find the repeated ones, like A C D in the above.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Apr 17, 2006 10:50 pm
Reply with quote

sreddy,

First, send a PM to the Moderator for the CICS forum and have them move this to one of the COBOL forums please.

Does this code suit your porpose?

Code:


 WORKING-STORAGE SECTION.                                       
                                                               
 01  TABLES.                                                   
     05  TABL-ENTRIES            PIC S9(3)    COMP-3           
                                              VALUE 10.         
     05  TABL-VALUES.                                           
         10  FILLER              PIC X(8)     VALUE 'A'.       
         10  FILLER              PIC X(8)     VALUE 'C'.       
         10  FILLER              PIC X(8)     VALUE 'D'.       
         10  FILLER              PIC X(8)     VALUE 'B'.       
         10  FILLER              PIC X(8)     VALUE 'C'.       
         10  FILLER              PIC X(8)     VALUE 'A'.       
         10  FILLER              PIC X(8)     VALUE 'S'.       
         10  FILLER              PIC X(8)     VALUE 'R'.       
         10  FILLER              PIC X(8)     VALUE 'P'.       
         10  FILLER              PIC X(8)     VALUE 'D'.       
     05  TABL REDEFINES TABL-VALUES                             
                                 PIC X(8)     OCCURS 10 TIMES. 
     05  SUB-1                   PIC S9(3)    COMP-3 
                                              VALUE 1.       
     05  SUB-2                   PIC S9(3)    COMP-3         
                                              VALUE 1.       
                                                             
 LINKAGE SECTION.                                           
                                                             
                                                             
 PROCEDURE DIVISION.                                         
                                                             
     DISPLAY 'TABLE VALUES'                                 
     DISPLAY ' '.                                           
                                                             
     PERFORM                                                 
       VARYING SUB-1 FROM 1 BY 1                             
       UNTIL SUB-1 > TABL-ENTRIES                           
           DISPLAY TABL(SUB-1)                               
     END-PERFORM.
                                           
     DISPLAY ' '                                                 
     DISPLAY 'DUP LIST'                                           
     DISPLAY ' '                                                 
                                                                 
     PERFORM                                                     
       VARYING SUB-1 FROM 1 BY 1                                 
       UNTIL SUB-1 > TABL-ENTRIES                                 
         PERFORM                                                 
           VARYING SUB-2 FROM 1 BY 1                             
           UNTIL SUB-2 > SUB-1 - 1                               
             IF TABL(SUB-1) = TABL(SUB-2)                         
             THEN                                                 
                 PERFORM DUP-FOUND                               
                 MOVE SUB-1 TO SUB-2                             
             END-IF                                               
         END-PERFORM                                             
     END-PERFORM.                                                 
                                                                 
     GOBACK.       
                                                         
 DUP-FOUND.                                               
                                                         
     DISPLAY 'DUP VALUE ''' TABL(SUB-1)                   
             ''' AT TABLE LOC ''' SUB-1                   
             ''' WAS FOUND AT TABLE LOC ''' SUB-2 ''''.   
                                                         


Results

Code:


                                                                       
TABLE VALUES                                                           
                                                                       
A                                                                       
C                                                                       
D                                                                       
B                                                                       
C                                                                       
A                                                                       
S                                                                       
R                                                                       
P                                                                       
D                                                                       
                                                                       
DUP LIST                                                               
                                                                       
DUP VALUE 'C       ' AT TABLE LOC '005' WAS FOUND AT TABLE LOC '002'   
DUP VALUE 'A       ' AT TABLE LOC '006' WAS FOUND AT TABLE LOC '001'   
DUP VALUE 'D       ' AT TABLE LOC '010' WAS FOUND AT TABLE LOC '003'   




Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
No new posts Find a record count/numeric is multip... COBOL Programming 1
Search our Forums:

Back to Top