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
 

 

SORT making groups or sections with limited no. of records

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

New User


Joined: 28 Feb 2007
Posts: 4
Location: chennai

PostPosted: Thu Oct 21, 2010 7:19 pm    Post subject: SORT making groups or sections with limited no. of records
Reply with quote

Hi,

Just a glimpse of my requirement.

I have an input file with say 1000+ records.
Layout:
field-A=10 bytes Char (non-unique-key).
field-B=1 byte (an indicator, either H or D, for header/Detail)
Field-C=5 bytes Numeric
There will be only one H record for particular Field-A value

SAMPLE:
AAAAAAAAAAH99999 ====> Header type record
AAAAAAAAAAD88888 => detail record
AAAAAAAAAAD77777 => detail record
AAAAAAAAAAD66666 => detail record
AAAAAAAAAAD55555 => detail record
...................
BBBBBBBBBBH99999
BBBBBBBBBBD88888
BBBBBBBBBBD77777
...............
CCCCCCCCCCH99999
CCCCCCCCCCD88888
CCCCCCCCCCD77777
................


Need to create one single output file grouped by field-A
In output file,
There can be 'n' no. of groups. 'n' is not known / not fixed.
Each group will have :
- 1 to 40 nos. of 'D' type rows &
- 1 'H' type row.
Additionally these 40 rows are the top 40 rows sorted in descending order of field-C.

I think it could be done in sort, using SECTIONS, reports etc.

In the job, One or multiple steps is fine.

If further information is required, I may be able to provide.
Request your kind help.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Oct 21, 2010 10:28 pm    Post subject:
Reply with quote

I can't figure out what you want from your description.

It would help if you would show a better example of your input records and what you expect for output, and explain the rules for getting from input to output using the example. Also, give the RECFM and LRECL of the input file.

You don't need to use 40 rows for your example - just give enough data to show what you want to do. However, if you need to show a lot of input and output data to illustrate what you want to do, feel free to send it to me offline (yaeger@us.ibm.com) as an attached .txt file.
Back to top
View user's profile Send private message
sajusmail

New User


Joined: 28 Feb 2007
Posts: 4
Location: chennai

PostPosted: Thu Oct 21, 2010 11:26 pm    Post subject: Reply to: SORT making groups or sections with limited no. o
Reply with quote

With due respect to your reply, I would like to stick to the same illustrative example for it exactly represents my need. Please note The above given was a sample sorted 'output' that is required. As u might have noticed it is sorted first on A then B and finally C. The input file is the same but will be in any order also it can contain lot more records. ( not just 41 records having same field-A). 
The sort process does not add or remove any fields. It may remove  rows if there are more than 40 detailed records for any key value in the input.
It is FB & LRECL is 16 here

It is more like control break process, that too with some specific no. of records only required (top 40 values of C here)for one particular set. This is the catch where I am stuck. 
Rather than coding a program for this,( restrictions present) I would look for a sort approach. 
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Oct 21, 2010 11:36 pm    Post subject:
Reply with quote

Quote:
above given was a sample sorted 'output' that is required.


It would have helped if you'd said that in your first post. I thought it was the input.

The approach I would take would be to use GROUP processing to assign sequence numbers for each group (SEQ=n) - then you could use OUTFIL OMIT to remove data records based on the sequence number.

Quote:
The input file is the same but will be in any order


Do you mean in any order of keys by groups with H followed by Ds for a particular key in a group, or something else? It may be clear to you what the input looks like, but it isn't clear to me.

If you need more help with this, show me what the input file might look like for your output example.
Back to top
View user's profile Send private message
sajusmail

New User


Joined: 28 Feb 2007
Posts: 4
Location: chennai

PostPosted: Fri Oct 22, 2010 6:44 am    Post subject:
Reply with quote

Thanks, Frank.
I got your logic by saying that we have to assign seq number for each group, and then removing those rows with seq >41 (in my case).
But, when I thought about it earlier, I was not sure of (still no idea how the code will be) how to assign seq no. to each group .i.e., restarting seq number when we encounter a set with different key.

Could anyone post what the SORT code will look like, if I were to go this way? How to use GROUP processing for assigning seq numbers, with a small example?
Back to top
View user's profile Send private message
sajusmail

New User


Joined: 28 Feb 2007
Posts: 4
Location: chennai

PostPosted: Fri Oct 22, 2010 7:07 pm    Post subject: Reply to: SORT making groups or sections with limited no. o
Reply with quote

Hi,

I used the below code for desirable results.

Code:
//SYSIN     DD   *                                     
  INREC FIELDS=(1,16,17:SEQNUM,8,ZD,RESTART=(1,10))     
  SORT FIELDS=COPY                                     
  OUTFIL INCLUDE(17,8,ZD,LE,40),OUTREC=(1,16)           
/*                                                     


Appending a seq num from pos:17, and restarting the seq num whenever the value at pos:1 with length 10 changes.
Outfil includes only the rows with seq num <= 40
Seq num is then removed from the end.

Thanks for the guidance.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Oct 22, 2010 10:56 pm    Post subject:
Reply with quote

sajusmail,

You can do the sort and omit in the same pass. Just set up the sequence numbers in an OUTREC statement after the records are sorted (rather than in an INREC statement before the records are sorted). Something like this:

Code:

    SORT FIELDS=(...)
    OUTREC OVERLAY=(17:SEQNUM,8,ZD,RESTART=(1,10))
    OUTFIL OMIT=(17,8,ZD,GT,40),BUILD=(1,16)
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


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