Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Moving only unique occurences

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Moving only unique occurences
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: 6968
Location: porcelain throne

PostPosted: Thu Oct 15, 2009 3:12 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Moving a PD to PD spoorni DFSORT/ICETOOL 8 Fri Oct 07, 2016 9:52 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Moving character data to smallint in db2 rikdeb DB2 5 Thu Jul 14, 2016 12:38 am
No new posts Unique sort situation.... dbecker SYNCSORT 6 Wed Apr 27, 2016 8:53 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us