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
 
Need all records with high key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Fri Feb 09, 2018 10:38 pm    Post subject: Need all records with high key
Reply with quote

In my file I have following records:

AAA10
AAA10
AAA10
AAA12
AAA12
AAA11
AAA11
BBB20
BBB20
BBB21
BBB21
BBB22
BBB22

I need the output as follows:

AAA12
AAA12
BBB22
BBB22

What SORT parameters I can use to get the desired output?
Back to top
View user's profile Send private message

Rohit Umarjikar

Senior Member


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

PostPosted: Fri Feb 09, 2018 11:13 pm    Post subject:
Reply with quote

lol. just use INCLUDE COND = ( "whatever you want")
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Sat Feb 10, 2018 12:09 am    Post subject:
Reply with quote

But I have about 70,000 records in my input file. AAA and BBB are 12 digit numbers.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Sat Feb 10, 2018 1:06 am    Post subject:
Reply with quote

Quote:
But I have about 70,000 records in my input file. AAA and BBB are 12 digit numbers.

Please you need to understand the rules first about what you want exactly.
You need to present the real scenario examples not AAA and BBB or give us piece meal information.

whatever you want as output- tell us how to identify them
or whatever you don't want as output- tell us how to identify them
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Sat Feb 10, 2018 2:03 am    Post subject:
Reply with quote

My file has total of 70000 records and record length is about 1000 bytes. Document number is a key field which is 14 digits. The last two digits are usually 00 (two zeros). Each document number could have multiple records. In some situations, there could be an adjustment to the document. In this case the last two digits could be 01, 02 and so on.

So if a document has two adjustments, the document numbers could be as below. I'm showing space preceding the last two digits for display purpose only.

128365290305 00
128365290305 00
128365290305 01
128365290305 01
128365290305 02
128365290305 02

When I use the below Sort, I only get one record for '128365290305 02'. But I need both.

SORT FIELDS=(1,12,CH,D)
SUM FIELDS=NONE

Hope I provided enough details.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 309
Location: Maryland

PostPosted: Sat Feb 10, 2018 6:08 am    Post subject:
Reply with quote

The first step (as usually!) - you need to understand the logic, or algorithm, or method, or whatever: WHAT AND HOW YOU NEED TO DO TO GET THE DESIRED RESULT.

The second step is, coding the already known algorithm for any desired tool - either SORT utilities, or whatever else.

The computer experts graduated approx. after year 2000 have never heard about the first step. They need some "buttons to click" just to get the result without thinking about it.

* * * * * * * *

Two SORT-related operations are required.

1) Get the list of MAX(adjustment_number) for each unique document_ID
2) Select (via JOIN operation) only those records from the original file with both matching fields of the list created above, e.g. document_ID, and max_adjustment_number

So, step #1 is done.
I suggest the author to complete at least step #2 by himself.
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Sat Feb 10, 2018 8:37 am    Post subject: Reply to: Need all records with high key
Reply with quote

Well I started my career with Mainframe in mid-90s but not everyone gets to explore further into some subjects. Thanks for the suggestion to do a join to get the result but I wanted to know if it's achievable through Syncsort. Thanks again.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2020
Location: UK

PostPosted: Sat Feb 10, 2018 3:18 pm    Post subject:
Reply with quote

'Join' is a process within Syncsort.
And if you wanted a Syncsort answer why post in DFsort? (Moving topic).
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 309
Location: Maryland

PostPosted: Sat Feb 10, 2018 10:22 pm    Post subject: Re: Reply to: Need all records with high key
Reply with quote

kalidasvs wrote:
Well I started my career with Mainframe in mid-90s but not everyone gets to explore further into some subjects. Thanks for the suggestion to do a join to get the result but I wanted to know if it's achievable through Syncsort. Thanks again.

Main point is: designing an algorithm is not related neither to computer platform, nor to specific programming language, nor to particular utility, etc.

It must be a part of design (in simple cases maybe in one's mind only) before any coding begins.
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Sat Feb 10, 2018 11:33 pm    Post subject:
Reply with quote

Nic Clouston wrote:
'Join' is a process within Syncsort.
And if you wanted a Syncsort answer why post in DFsort? (Moving topic).


Sure, this topic need to be moved to Syncsort.
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Sat Feb 10, 2018 11:38 pm    Post subject: Re: Reply to: Need all records with high key
Reply with quote

sergeyken wrote:
kalidasvs wrote:
Well I started my career with Mainframe in mid-90s but not everyone gets to explore further into some subjects. Thanks for the suggestion to do a join to get the result but I wanted to know if it's achievable through Syncsort. Thanks again.

Main point is: designing an algorithm is not related neither to computer platform, nor to specific programming language, nor to particular utility, etc.

It must be a part of design (in simple cases maybe in one's mind only) before any coding begins.


I have other approach, where I create a VSAM file with document number of highest adjustments. Then a COBOL program extracts the records. This is not for production, but for off side data extract.
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Sat Feb 10, 2018 11:39 pm    Post subject:
Reply with quote

I want to thank everyone for your time, I would like to close this thread.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Mon Feb 12, 2018 10:01 pm    Post subject:
Reply with quote

kalidasvs wrote:
have other approach, where I create a VSAM file with document number of highest adjustments. Then a COBOL program extracts the records. This is not for production, but for off side data extract.
I don't have Syncsort. But if you're not concerned about the output order, you could consider something like this (assumed your original sample input data provided in the SORTIN DD).
Code:
//SYSIN     DD *                                             
  SORT FIELDS=(1,5,CH,D)                                     
  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(81:SEQ=8)),
         IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(89:SEQ=8)) 
  OUTFIL INCLUDE=(81,8,ZD,EQ,89,8,ZD),BUILD=(1,80)
Back to top
View user's profile Send private message
kalidasvs

New User


Joined: 08 Feb 2018
Posts: 11
Location: US

PostPosted: Mon Feb 12, 2018 10:13 pm    Post subject:
Reply with quote

Arun Raj wrote:
kalidasvs wrote:
have other approach, where I create a VSAM file with document number of highest adjustments. Then a COBOL program extracts the records. This is not for production, but for off side data extract.
I don't have Syncsort. But if you're not concerned about the output order, you could consider something like this (assumed your original sample input).
Code:
//SYSIN     DD *                                             
  SORT FIELDS=(1,5,CH,D)                                     
  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(81:SEQ=8)),
         IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(89:SEQ=8)) 
  OUTFIL INCLUDE=(81,8,ZD,EQ,89,8,ZD),BUILD=(1,80)


Thanks, I'll review your solution! I did try one method (suggested in this thread by user sergeyken) which worked on a set of small data. I'm yet to try on full data. Here File-1 is file of unique keys of Document number with highest adjustment. File-2 is the actual file.

//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,8,A)
JOINKEYS FILE=F2,FIELDS=(1,8,A)
REFORMAT FIELDS=(F2:1,20)
SORT FIELDS=COPY
END
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 7
Location: Germany

PostPosted: Tue Feb 20, 2018 12:46 am    Post subject:
Reply with quote

You could just sort by the ID ascending, adjustment descending. When the key ID changes PUSH the record and compare all the other records against the pushed value. Include only equal ones, simple as that.

Using JOIN is more than overkill and with your solution needs an extra step to separate the highest adjustments for each key.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 309
Location: Maryland

PostPosted: Thu Feb 22, 2018 10:53 pm    Post subject:
Reply with quote

Joerg.Findeisen wrote:
You could just sort by the ID ascending, adjustment descending. When the key ID changes PUSH the record and compare all the other records against the pushed value. Include only equal ones, simple as that.

Using JOIN is more than overkill and with your solution needs an extra step to separate the highest adjustments for each key.

Yes, both solutions (either with PUSH, or with JOIN) use the same logical algorithm implemented in two different ways (and there are more of them). Both types of code have been presented in previous postings.
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 -> SYNCSORT 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