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

Merge and copy files based on Conditions


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

New User


Joined: 04 Sep 2007
Posts: 4
Location: USA

PostPosted: Tue Sep 04, 2007 10:18 pm
Reply with quote

I have a file with Header Records (type 1C) followed by the Detail Records (Type 7C) and then the Trailer records (Type 8C). Within the Header and Trailer records, there is no limitation to the number of detail records.
The Header, Detail and Trailer records are linked to each other with a key. They location of the key is as follows:
Header: 187-200
Detail: 184-197
Trailer: 165-178

My requirement is to get an output record, in which each record is combination of a header and detail records.

For example,
INPUT:
Header1 - HC11 HC12 HC13 HC14 HC15
Detail11 - DC111 DC112 DC113 DC114 DC115 DC116
Detail12 - DC121 DC122 DC123 DC124 DC125 DC126
Detail13 - DC131 DC132 DC133 DC134 DC135 DC136
Detail14 - DC141 DC142 DC143 DC144 DC145 DC146
Trailer1- TC11 TC12 TC13 TC14
Header2 - HC21 HC22 HC23 HC24 HC25
Detail21 - DC211 DC212 DC213 DC214 DC215 DC216
Detail22 - DC221 DC222 DC223 DC224 DC225 DC226
Detail23 - DC231 DC232 DC233 DC234 DC235 DC236
Detail24 - DC241 DC242 DC243 DC244 DC245 DC246
Detail25 - DC251 DC252 DC253 DC254 DC255 DC256
Trailer2 - TC21 TC22 TC23 TC24
OUTPUT:
HC12 DC112 DC113 DC115
HC12 DC122 DC123 DC125
HC12 DC132 DC133 DC135
HC12 DC142 DC143 DC145
HC21 DC212 DC213 DC215
HC21 DC222 DC223 DC225
HC21 DC232 DC233 DC235
HC21 DC242 DC243 DC245
HC21 DC252 DC253 DC255

Please let me know how to accomplish this only using the SORT program.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 04, 2007 10:34 pm
Reply with quote

Hello,

You need to elaborate on your "rules" that cause your posted input to become your posted output.

The requirement is completely clear to you, but it is not to others.

Also, please post the recfm and lrecl of your input and output files.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Sep 04, 2007 11:58 pm
Reply with quote

As Dick says, your requirement is completely unclear. We can't read your mind, so you have to explain what you want in detail.

You say
Quote:
The Header, Detail and Trailer records are linked to each other with a key.


But it's not clear which value in each example input record represents the key if any of them do. Please clarify that as well.

Are the HCxx and DCyyy values actual values in the record or do they represent something else (what?).

Also, give the starting position, length and format of the other relevant fields such as the Type field.
Back to top
View user's profile Send private message
srivatsantk

New User


Joined: 04 Sep 2007
Posts: 4
Location: USA

PostPosted: Wed Sep 05, 2007 1:00 am
Reply with quote

Sorry for the confusion.

The files used are PS files with LRECL 80

Let me explain my requirement with this example:

Header1 - H1C1 H1C2 H1C3 H1C4 H1C5
Detail11 - D11C1 D11C2 D11C3 D11C4 D11C5 D11C6
Detail12 - D12C1 D12C2 D12C3 D12C4 D12C5 D12C6
Detail13 - D13C1 D13C2 D13C3 D13C4 D13C5 D13C6
Detail14 - D14C1 D14C2 D14C3 D14C4 D14C5 D14C6
Trailer1- T1C1 T1C2 T1C3 T1C4
Header2 - H2C1 H2C2 H2C3 H2C4 H2C5
Detail21 - D21C1 D21C2 D21C3 D21C4 D21C5 D21C6
Detail22 - D22C1 D22C2 D22C3 D22C4 D22C5 D22C6
Detail23 - D23C1 D23C2 D23C3 D23C4 D23C5 D23C6
Detail24 - D24C1 D24C2 D24C3 D24C4 D24C5 D24C6
Detail25 - D25C1 D25C2 D25C3 D25C4 D25C5 D25C6
Trailer2 - T2C1 T2C2 T2C3 T2C4
OUTPUT:
H1C2 D11C2 D11C3 D11C5
H1C2 D12C2 D12C3 D12C5
H1C2 D13C2 D13C3 D13C5
H1C2 D14C2 D14C3 D14C5
H2C2 D21C2 D21C3 D21C5
H2C2 D22C2 D22C3 D22C5
H2C2 D23C2 D23C3 D23C5
H2C2 D24C2 D24C3 D24C5
H2C2 D25C2 D25C3 D25C5


As you can see from the above examples, I am considering 2 groups of records in the input file:
a: First Group starts from Header1 and ends at Trailer1 with 4 Detail Records
b: Second Group starts from Header2 and ends at trailer2 with 5 Detail records.

Please interpret H1C2 as follows:
H - Header Record
1 - First Header Record
C - Column in Header
2 - Second Column
So H1C2 points to the second column in the First Header Record.

Similarly D25C3 points to the third column in the Fifth Detail Record under the Second Header record.

The output file should be a combination of selective Header and Detail columns and the total number of rows in the output file should be equal to the number of Detail Rows. I have highlighted the colums in Dark Blue that need to be written to the output file. The starting positions and size of the hightlighted colums in the input file are as follows:

a. H*C2 --> 20 (Column Start Position)-->8 (Size in Bytes)
b. D**C2 --> 15 (Column Start Position)-->10 (Size in Bytes)
c. D**C3 --> 25 (Column Start Position)--> 5 (Size in Bytes)
d. D**C5 --> 36 (Column Start Position)--> 14 (Size in Bytes)

Please ignore the key values as I mentioned in my initial requirement.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 05, 2007 1:21 am
Reply with quote

Hello,

What identifies a header record, a detail record, or a trailer record? (My guess is that the records do not contain "Header" or "Detail" or "Trailer".

It may help if you use values like the "real" data will contain rather than just the rec/col reference.
Back to top
View user's profile Send private message
srivatsantk

New User


Joined: 04 Sep 2007
Posts: 4
Location: USA

PostPosted: Wed Sep 05, 2007 1:48 am
Reply with quote

The H*C5 column identifies the header and its value is "1C"
The D**C6 column identifies the detail records and its value is "7C".
The T*C4 column identifies the trailer record and its value is "8C"

The Header and Detail records are connected by the Keys present in:
1. H*C3 --> 28 (Column Start Position)-->6 (Size in Bytes)
2. D**C4 --> 30 (Column Start Position)--> 6 (Size in Bytes)
3. T*C2 --> 10 (Column Start Position)-->6 (Size in Bytes)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 05, 2007 2:17 am
Reply with quote

Ok.

Now, might you show some "real-like" data rather than the alphabet soup?
Back to top
View user's profile Send private message
srivatsantk

New User


Joined: 04 Sep 2007
Posts: 4
Location: USA

PostPosted: Wed Sep 05, 2007 2:44 am
Reply with quote

Hi, We are in the design phase and I dont have the actual data as of now..We wanted to see if it is feasible to accomplish the requirement just by using the sort pgm rather than writing a cobol program.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 05, 2007 2:55 am
Reply with quote

Hello,

It probably is possible, but not until the requirement is completely defined and understood.

Quote:
I dont have the actual data as of now
Might some just be "contrived"? At this late stage, i would hope that the layouts are nearly finalized.

Until the actual format/content is known, it will be difficult (if even possible) implement in any manner (i.e. sort, cobol, etc.).
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Sep 05, 2007 5:30 am
Reply with quote

Quote:
The output file should be a combination of selective Header and Detail columns and the total number of rows in the output file should be equal to the number of Detail Rows. I have highlighted the colums in Dark Blue that need to be written to the output file.


How are the header and detail columns to be used selected? Are there rules you'll follow to select them? If so, what are they? Or are the columns to be selected indicated by another file or by parameters of some kind or what?

Quote:
Hi, We are in the design phase and I dont have the actual data as of now..We wanted to see if it is feasible to accomplish the requirement just by using the sort pgm rather than writing a cobol program.


Your description so far is too abstract and unclear for me to determine that.
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts How to load to DB2 with column level ... DB2 6
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top