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 Block of records

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

New User


Joined: 30 Sep 2006
Posts: 5

PostPosted: Thu Sep 15, 2016 8:58 am    Post subject: SORT Block of records
Reply with quote

Hi Friends.
I got a new requirement where I need to extract the block of records as per the country. The first two records are header and 3rd record contains country name and then detail records (these vary.. May be 6, may be 10, 12) then at the end I have trailer. This whole becomes a block of record for me. This file is FB with 400 LRECL. I need to recognize these block of records as per the country names and write it into separate files. I believe I need to use IFTHEN, GROUP, BEGIN, END Sort cards to do that but not sure how to. I have attached one block of record here. So I need to extract the whole block/bunch with same sequence for different countries. Please help on sort card.
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Sep 15, 2016 11:44 am    Post subject:
Reply with quote

Your query is not clear to me atleast
Is there any other reference file where you need to cross check the names of country present in file place as an image above?

Please do not use image use code tags going forward...
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Sep 15, 2016 1:57 pm    Post subject:
Reply with quote

Quote:
I believe I need to use IFTHEN, GROUP, BEGIN, END Sort cards to do that but not sure how to.


Search the forum using the same key words. You will find lots of example. Rather than attachment, copy paste the data using Code tags. That would be easier to read.
Back to top
View user's profile Send private message
girishb2

New User


Joined: 30 Sep 2006
Posts: 5

PostPosted: Thu Sep 15, 2016 5:35 pm    Post subject: Reply to: SORT Block of records
Reply with quote

Thanks. I will try to find the posts on this forum.

Hi Pandora, Sorry for not making it clear.
Here is a example - I have a file which contains -

HDR01
hdr
Costa Rica
001
DTL
002
005
TRL
HDR02
hdr
Argentina
001
003
DTL
TRL
HDR01
hdr
Costa Rica
001
TYH
090
005
132
TRL


I need to sort the file with hdr, block of detail records & trailer as per the country names. Like for Costa Rica - I have 2 block of records which I need to extract and keep it in separate files. I need a sort card for this.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Sep 15, 2016 6:00 pm    Post subject:
Reply with quote

Argentina is a country name as well why are you not expecting it in the output file?
Back to top
View user's profile Send private message
girishb2

New User


Joined: 30 Sep 2006
Posts: 5

PostPosted: Thu Sep 15, 2016 6:10 pm    Post subject: Reply to: SORT Block of records
Reply with quote

Yes, I need Costa Rica, Argentina, Brazil - block of records in separate files. Like -

file1
HDR01
hdr
Costa Rica
34324
eet
TRL

File2
HDR01
hdr
Argentina
435435
ssafd
dff
TRL
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Sep 15, 2016 6:23 pm    Post subject:
Reply with quote

girishb2,

If you don't know how many country names/blocks are going to be in the input, then you need output files to be dynamically allocated. I would suggest writing some code instead of a sort solution.
Back to top
View user's profile Send private message
sergeyken

New User


Joined: 29 Apr 2008
Posts: 37
Location: Maryland

PostPosted: Thu Sep 15, 2016 11:57 pm    Post subject:
Reply with quote

1) Your "Costa Rica" appers twice in your input. Do you need to create two separate files for two of them?

2) Is that OK to create library members instead of "files"?
Back to top
View user's profile Send private message
girishb2

New User


Joined: 30 Sep 2006
Posts: 5

PostPosted: Fri Sep 16, 2016 12:13 am    Post subject: Reply to: SORT Block of records
Reply with quote

No. I need to club these Costa Rica Records into One PS Dataset. Likewise there may be many records for Argetina & Brazil which I need to keep in another PS Dataset.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Fri Sep 16, 2016 1:16 am    Post subject:
Reply with quote

DFSORT does NOT allocate the output data sets dynamically. You would either have to supply the maximum number of output DD statements or generate them in a job you submit to the internal reader Or learn the approach explained by Frank here Or a Rexx Solution Or Write a program as suggested by Arun.
Back to top
View user's profile Send private message
girishb2

New User


Joined: 30 Sep 2006
Posts: 5

PostPosted: Fri Sep 16, 2016 2:13 am    Post subject: Reply to: SORT Block of records
Reply with quote

I already have datasets created. I just want to do the group sort on the basis of Country name and have these in the datasets - Costa Rica in one & Arg, BR in another.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Sep 16, 2016 2:16 am    Post subject:
Reply with quote

girishb2,

If this is not a one-time task, do you always know how many countries/output datasets you will have? If that is a variable number then dynamic allocation is the way to go.
Back to top
View user's profile Send private message
sergeyken

New User


Joined: 29 Apr 2008
Posts: 37
Location: Maryland

PostPosted: Fri Sep 16, 2016 4:20 am    Post subject:
Reply with quote

Since the tag to determine the required country does appear only after third record of each group, there is no way to guess in advance: where to place the preceeding "header" records.

There are no such things as miracles... icon_exclaim.gif

Some pre-processing is needed to define the required country = group = file before or at the moment the first record of this group is being processed.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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