Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
To get 1st two occurance of records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Fri Feb 06, 2009 12:04 pm    Post subject: To get 1st two occurance of records
Reply with quote

Hi,

I have to create a cobol code to get 1st two occurance of same records and to bypass the other occcurances of same record.

e.g we have rec as

rupesh1 abc def
rupesh1 ghi jkl
rupesh1 mno pqr

ram1 stu vwx yza
ram1 bcd efg hij
ram1 klm nop qrs
ram1 tuv wxy zab
------
-----
---

my o/p should be
rupesh1 abc def
rupesh1 ghi jkl
ram1 stu vwx yza
ram1 bcd efg hij

Also let me know how can i do it using sort
Regards,
rupesh gupta
Back to top
View user's profile Send private message

sai_sridar_s

New User


Joined: 14 Nov 2006
Posts: 6

PostPosted: Fri Feb 06, 2009 12:30 pm    Post subject: Reply to: To get 1st two occurance of records
Reply with quote

hi,

u can do using ICETOOL

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,7,CH) FIRST(2)
//*

Refer Smart DFSORT Tricks

other wise you can have a counter for key field and skip if is greater than two and agian initialize the counter to check for other key occurence in your cobol pgm.

Hope this helps..
Back to top
View user's profile Send private message
naveengec

New User


Joined: 24 Mar 2007
Posts: 35
Location: pune

PostPosted: Fri Feb 06, 2009 12:35 pm    Post subject: Perfect sai
Reply with quote

i tried it....its working..... please let me know in case if there is any other way to do it..
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Fri Feb 06, 2009 12:37 pm    Post subject: Reply to: To get 1st two occurance of records
Reply with quote

thanks sai its working for me ...
regards,
rupesh gupta
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Fri Feb 06, 2009 12:38 pm    Post subject: Reply to: To get 1st two occurance of records
Reply with quote

Hi,

You need use a simple logic in cobol code to handle this.
1) Sort your input on the key( all duplicate key should be aligned together)
2) Read the 1st rec and move it into an array of 2 and also maintain a counter of key
3) Read the next rec
4) check if the key is same then again move it into the array , increment the counter, and finally write it into the o/p file.
5) Keep on reading the recs until you get a new key. If you get a new key, reset the counter to '1' again and move it to the array .......( start repeating the previous steps 2 - 5).

Now, If you have dfsort in your system. Things could become much more easier.

//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,10,CH) FIRST(2) USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(1,10,CH,A)

This works very well.
Thanks,
-Kapil.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Fri Feb 06, 2009 1:58 pm    Post subject: Reply to: To get 1st two occurance of records
Reply with quote

thanks kapil .. i will try both ways.

regards.
rupesh gupta
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2361
Location: @my desk

PostPosted: Fri Feb 06, 2009 8:03 pm    Post subject:
Reply with quote

Kapil,

I dont think you need that CTL1 card.
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 MXG - Processing Compressed DB2 SMF r... vasanthz All Other Mainframe Topics 2 Thu May 10, 2018 12:47 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm
No new posts Copy set of records based on condition krish.deepu SYNCSORT 2 Thu Mar 08, 2018 11:39 am
No new posts add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us