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

Moving only unique occurences


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
RockyS

New User


Joined: 16 Apr 2009
Posts: 10
Location: India

PostPosted: Thu Oct 15, 2009 2:44 pm
Reply with quote

I want to move a field of occurence 10 to a similar field but without duplicates.

Eg. if source variable has below values stored in it-
SOUR-VAR
Code:
aaa
bbb
aaa
ddd
bbb
aaa
aaa

then destination should hold these-
DEST-VAR
Code:
aaa
bbb
ddd

Please let me know the most efficient way to do this.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Oct 15, 2009 3:12 pm
Reply with quote

either
  • when first table is sorted
    • as you loop thru your first table
      • check if the destination is the same
        • if unequal increment the index on the second table and make a move, then increment the index on the first table
        • if equal increment the first index
  • when first table is unsorted
    • loop thru first table with an inner loop on your second looking for equals (or SEARCH)
      • if equal increment first index
      • if unequal and end of second table
        • increment second index
        • make move
        • increment first index
        • start inner loop again


obviously the sorted first table would make the population of the second more effecient.

but, it takes resources to insure the first table is sorted.

If you have less than a few hundred I would not bother to have a sorted first table. other than that, I have no idea where the break-even point is concerning sorted/unsorted.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Any JCL or VSAM Utility to get number... JCL & VSAM 1
No new posts Can we Insert duplicates in Primary U... DB2 2
No new posts SEPARATE UNIQUE and NON-UNIQUE in SEP... SYNCSORT 6
No new posts Get next 5 numeric from a string of '... COBOL Programming 4
Search our Forums:

Back to Top