|
View previous topic :: View next topic
|
| Author |
Message |
PANDU1
New User
Joined: 16 Nov 2016 Posts: 7 Location: india
|
|
|
|
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 |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
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 |
|
 |
PANDU1
New User
Joined: 16 Nov 2016 Posts: 7 Location: india
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
PANDU1
New User
Joined: 16 Nov 2016 Posts: 7 Location: india
|
|
|
|
Thank you Arun,
I could able to solve the duplicates but trying to update the counters. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
PANDU1
New User
Joined: 16 Nov 2016 Posts: 7 Location: india
|
|
|
|
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.  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Great, thanks for letting us know. Make sure you understand it. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| 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 ).
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|