View previous topic :: View next topic
|
Author |
Message |
girishb2
New User
Joined: 30 Sep 2006 Posts: 14
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
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 |
|
|
girishb2
New User
Joined: 30 Sep 2006 Posts: 14
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Argentina is a country name as well why are you not expecting it in the output file? |
|
Back to top |
|
|
girishb2
New User
Joined: 30 Sep 2006 Posts: 14
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2022 Location: USA
|
|
|
|
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 |
|
|
girishb2
New User
Joined: 30 Sep 2006 Posts: 14
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
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 |
|
|
girishb2
New User
Joined: 30 Sep 2006 Posts: 14
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2022 Location: USA
|
|
|
|
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...
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 |
|
|
|