IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SORT Block of records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
girishb2

New User


Joined: 30 Sep 2006
Posts: 14

PostPosted: Thu Sep 15, 2016 8:58 am
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

Global Moderator


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

PostPosted: Thu Sep 15, 2016 11:44 am
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Sep 15, 2016 1:57 pm
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: 14

PostPosted: Thu Sep 15, 2016 5:35 pm
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

Global Moderator


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

PostPosted: Thu Sep 15, 2016 6:00 pm
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: 14

PostPosted: Thu Sep 15, 2016 6:10 pm
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: 2481
Location: @my desk

PostPosted: Thu Sep 15, 2016 6:23 pm
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

Senior Member


Joined: 29 Apr 2008
Posts: 2022
Location: USA

PostPosted: Thu Sep 15, 2016 11:57 pm
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: 14

PostPosted: Fri Sep 16, 2016 12:13 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Fri Sep 16, 2016 1:16 am
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: 14

PostPosted: Fri Sep 16, 2016 2:13 am
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: 2481
Location: @my desk

PostPosted: Fri Sep 16, 2016 2:16 am
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

Senior Member


Joined: 29 Apr 2008
Posts: 2022
Location: USA

PostPosted: Fri Sep 16, 2016 4:20 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 5
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top