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
 

 

Updating the counters after eliminating duplicates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
PANDU1

New User


Joined: 16 Nov 2016
Posts: 4
Location: india

PostPosted: Mon Nov 21, 2016 9:47 am    Post subject: Updating the counters after eliminating duplicates
Reply with quote

Hi Everyone,

Can any one suggest me in solving this query,

If my input file is

Code:
01 HEADER1
05 RAMU      85870         
05 RAJESH    85871       
05 RAMU      85870         
05 SOMU      85878       
05 RAJU      85890       
05 RAMU      85870         
05 AKIL      85889     
99 COUNT1 - 7
01 HEADER2
05 RAMU      85850         
05 RAJESH    85851       
05 RAMU      85852         
05 SOMU      85858       
05 RAJU      85850       
05 RAMU      85851         
05 AKIL      85850     
99 COUNT2 - 7

And my output with - updated the counts of individual header after eliminating duplicates in employee number. i.e.
output file:

Code:
01 HEADER1
05 RAMU      85870         
05 RAJESH    85871       
05 SOMU      85878       
05 RAJU      85890       
05 AKIL      85889     
99 COUNT1 - 5
01 HEADER2
05 RAMU      85850         
05 RAJESH    85851       
05 RAMU      85852         
05 SOMU      85858       
99 COUNT2 - 4


Which sort utility can be used for this and how?

code' d
Back to top
View user's profile Send private message

Arun Raj

Moderator


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

PostPosted: Mon Nov 21, 2016 11:15 am    Post subject:
Reply with quote

PANDU1,

Welcome to the forums! You should probably be able to achieve this with whichever sort product is available at your site (DFSORT, Syncsort,..).

Search the DFSORT forum here for examples on how to "remove duplicate"s or creating "trailer count"s.
Try something and get back if you face any issues. Someone would be here to help. Good luck!

Also make sure you include all the relevant information, RECFM, LRECL, field positions of your actual data, sort order of the input data (if any), sort order of the output (if it matters). Post code/sample data using "Code" tags.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Nov 21, 2016 12:17 pm    Post subject: Reply to: Updating the counters after eliminating duplicates
Reply with quote

tell us what sort product You will be using.

look at the messages

WER... ==> SYNCSORT
ICE... ==> IBM DFSORT

and the topic will be moved to the proper section
Back to top
View user's profile Send private message
PANDU1

New User


Joined: 16 Nov 2016
Posts: 4
Location: india

PostPosted: Mon Nov 21, 2016 5:27 pm    Post subject:
Reply with quote

Thanks Arun Raj and enrico-sorichetti

Field positions are as follows

01-2 - Sequence number
04-10 - Employee name
12-5 - Employee number(sort field)

Let the RECFM and LRECL valued be FB & 30 respectively.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Mon Nov 21, 2016 9:23 pm    Post subject:
Reply with quote

Code:
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(4,6,CH,EQ,C'HEADER',OR,4,4,CH,EQ,   
                                            C'COUNT'),PUSH=(81:ID=8)),
  IFTHEN=(WHEN=(4,6,CH,NE,C'HEADER'),OVERLAY=(89:1,10)),             
  IFTHEN=(WHEN=(4,5,CH,NE,C'COUNT'),OVERLAY=(89:1,10))               
  SORT FIELDS=(81,18,CH,A),EQUALS                                     
  SUM FIELDS=NONE                                                     
  OUTREC BUILD=(1,30)     

Though, you will find a way to update COUNT by doing little research.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Mon Nov 21, 2016 10:54 pm    Post subject: Reply to: Updating the counters after eliminating duplicates
Reply with quote

No, Rohit.

Even accepting the 4.4 comparison for C'COUNT' as a typo, you don't want to use HEADER and COUNT, for your tests, as there is absolutely nothing to stop these giving you a "false hit" if they happen to occur in at that position in a name.

There are clearly indicators for the header and trailer which give no possibility of a false hit. There is also, clearly, a "reference number" which should be used for the sort/deduplication, even if that is not sufficient (no indication) there is no reason to includ the "05" or the blank following it or only a selected part of the name field.

WHEN=GROUP with BEGIN for "01", END for "99". Sort field after the ID to contain X'00' for header, X'FF' for trailer.

To suggest using COUNT, you can't chop off the extension in OUTREC.

A sequence, with RESTART for the ID extension and an IFTHEN=(WHEN=(logcicalespression) on OUTREC would allow a JFY with SHIFT=LEFT for the format of count shown.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 22, 2016 11:09 am    Post subject:
Reply with quote

I think we are good without an END for the group.
This is UNTESTED, this has the essence of Bill's suggestion above.
Code:
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'01'),   
                           PUSH=(81:ID=8)),
  IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),OVERLAY=(89:5X'00')),             
  IFTHEN=(WHEN=(1,2,CH,EQ,C'99'),OVERLAY=(89:5X'FF')),             
  IFTHEN=(WHEN=NONE,OVERLAY=(89:14,5))
             
  SORT FIELDS=(81,13,CH,A)
  SUM FIELDS=NONE                                                   
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(89:SEQNUM,5,ZD,RESTART=(81,8))),
         IFTHEN=(WHEN=(1,2,CH,EQ,C'99'),
         OVERLAY=(89:89,5,ZD,SUB,+2,ZD,M10,LENGTH=5,
                  13:89,5,JFY=(SHIFT=LEFT))),
  IFOUTLEN=30

EDIT: Added a closing brace to correct the syntax.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Nov 22, 2016 2:43 pm    Post subject: Reply to: Updating the counters after eliminating duplicates
Reply with quote

Yes, Arun, that looks good. I got confused with the END because the trailer was being treated as a separate group by Rohit :-)

I'd rearrange the order of the IFTHENs, so that the data-one is treated first, it'll avoid a lot of tests for when the header/trailer when most of the records will be data. Multiple IFTHEN=(WHEN=(logicalexpression) are like an EVALUATE in COBOL, so cease the processing of that construct as soon as there is a "hit". That behaviour can be modified, when needed (for two entirely independent operations on the same record) by using HIT=NEXT.
Back to top
View user's profile Send private message
PANDU1

New User


Joined: 16 Nov 2016
Posts: 4
Location: india

PostPosted: Tue Nov 22, 2016 3:39 pm    Post subject:
Reply with quote

Thank you Arun,

I could able to solve the duplicates but trying to update the counters.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Nov 22, 2016 3:41 pm    Post subject: Reply to: Updating the counters after eliminating duplicates
Reply with quote

PANDU1,

Arun's code drops duplicates and produces correct counts. Even if you've already dropped the duplicates without telling us (wasting time) the code will still work even if there are no duplicates to drop. Note: I've not tested it either, but it looks good.
Back to top
View user's profile Send private message
PANDU1

New User


Joined: 16 Nov 2016
Posts: 4
Location: india

PostPosted: Tue Nov 22, 2016 4:42 pm    Post subject:
Reply with quote

Hi Bill,

I have no idea in solving this, so posted in the group. After trying with Arun's code I got the relevant output.

Thanks. icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Nov 22, 2016 4:49 pm    Post subject: Reply to: Updating the counters after eliminating duplicates
Reply with quote

Great, thanks for letting us know. Make sure you understand it.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 22, 2016 8:15 pm    Post subject:
Reply with quote

Quote:
I'd rearrange the order of the IFTHENs, so that the data-one is treated first, it'll avoid a lot of tests for when the header/trailer when most of the records will be data
I thought about this while posting to OVERLAY the 'key' in the INIT for all the records since we have more detail records and then to check for header and trailer in the subsequent IFTHENs, but was too lazy especially when I cant test anything now (and for the next 2 weeks icon_sad.gif).

Or even better as you pointed out, is to make it 3 mutually exclusive IFTHEN conditions in the order of data>>header>>trailer to avoid 'rework' on header and trailer records.
Code:
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP.......
......
......
  IFTHEN=(WHEN=(1,2,SS,NE,C'01,99'),OVERLAY=(89:14,5)),             
  IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),OVERLAY=(89:5X'00')),             
  IFTHEN=(WHEN=(1,2,CH,EQ,C'99'),OVERLAY=(89:5X'FF'))             
......
......
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 1 Fri Dec 09, 2016 4:40 am
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am
No new posts Obtaining a signed value when updatin... Shrikant Kumar DFSORT/ICETOOL 2 Wed Dec 24, 2014 11:04 pm


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