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
 

 

Extracting header and detail records off one file.

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

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Thu Sep 13, 2007 1:40 am    Post subject: Extracting header and detail records off one file.
Reply with quote

I need to sort some records off of an input file that is in the following format,

00001 header info
00001 detail info
00001 detail info
00001 detail info
00002 header info
00002 detail info
00003 header info
00003 detail info
00004 header info
00004 detail info
00004 detail info

As you can see, there will always be one header record, followed by at least one detail record, but there could be as many as 50 details following each header. What I want to create is a file for testing that will stop after the detail records. I'd like to get at least 100 logical records in the output, but I need all the details that go with each header, so I can't just stop at a fixed point each time. Any ideas besides writing a quick and dirty to do it?
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 Sep 13, 2007 2:24 am    Post subject:
Reply with quote

It's not clear to me what you want. Do you want the header and detail records in the output file, or just the detail records? Say you wanted a minimum of 5 records for output - what would the output records be? Would they be:

00001 header info
00001 detail info
00001 detail info
00001 detail info
00002 header info
00002 detail info

or

00001 detail info
00001 detail info
00001 detail info
00002 detail info
00003 detail info

or something else (what and why)?
Back to top
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Thu Sep 13, 2007 2:45 am    Post subject:
Reply with quote

I need the logical records, to me that means that I would need to have the header, as well as all details that have the same key (0001, 0002, etc) on the output file.
So, going back to my original input file,
00001 header info
00001 detail info
00001 detail info
00001 detail info
00002 header info
00002 detail info
00003 header info
00003 detail info
00004 header info
00004 detail info
00004 detail info

Say I want three logical records, I would expect to have this in my output file.
00001 header info
00001 detail info
00001 detail info
00001 detail info
00002 header info
00002 detail info
00003 header info
00003 detail info


Does that make sense?
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 Sep 13, 2007 3:26 am    Post subject:
Reply with quote

Quote:
Does that make sense?


I'm not sure. If by "three logical records", you mean the first three groups (with keys 00001, 00002 and 00003), you can use these DFSORT control statements:

Code:

   OPTION COPY
   INCLUDE COND=(1,5,ZD,LE,+3)


I thought you were asking for something more complicated. If you are, then you need to explain what you want more clearly. If not, then that should do it. Change +3 to whatever number of groups you want.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Sep 13, 2007 3:28 am    Post subject:
Reply with quote

Hello,

Might we call what you need "groups" or "sets" of records?

One header and n details make up a group/set (logical record).

You want the first 100 headers and all of their associated details in the output file?
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Sep 13, 2007 7:53 am    Post subject:
Reply with quote

calspach

Quote:
Say I want three logical records, I would expect to have this in my output file.

look at my post, at http://ibmmainframes.com/viewtopic.php?t=24137&highlight=
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Sep 13, 2007 7:59 am    Post subject:
Reply with quote

My previous post was based on the questions/comments from dick,
Else if you needed the logical consideration of the records as 00001,00002 and 0003 as 1 set of records, then Frank's solution would be the right one.
Back to top
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Thu Sep 13, 2007 5:47 pm    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Might we call what you need "groups" or "sets" of records?

One header and n details make up a group/set (logical record).

You want the first 100 headers and all of their associated details in the output file?
Yes, that is correct, I tried the sort that Frank posted and it didn't work. I can't show the real data, as it is private stuff, but perhaps I should explain a little better. The key is in the first five bytes, the record I'm working on is a variable length record, so I added the 4 bytes for the RDW, so my sort was (5,5,ZD,LE,+3) It gets a zero, but doesn't put any records in the output.

I also want to make it clear that I do not know if a record will have one detail or 20 details associated with each header, it will change with each 'logical record' but I need all details that are associated with each header. This will be running twice a week to pull a sample of our prod records into a systems test run.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Sep 13, 2007 6:26 pm    Post subject:
Reply with quote

Hello,

Quote:
I tried the sort that Frank posted and it didn't work
Did you use the exact same data you posted?

If you tried with your "real" data and the first 3 "keys" were not less than 00004, you would get no records selected.
Back to top
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Thu Sep 13, 2007 6:36 pm    Post subject:
Reply with quote

Ok, I guess I was thinking there would be some grouping action that you could do, but that's just including all records where the key is less than or equal to 3. Duh. So I will still need to know the max key that I want to include, is there not a way to just get the first x number of 'logical records', regardless of what the key is?
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 Sep 13, 2007 9:02 pm    Post subject:
Reply with quote

calspach,

Quote:
there not a way to just get the first x number of 'logical records', regardless of what the key is?


I suspect you can probably use the IFTHEN group trick to do what you want, but I still don't know enough about what your data looks like to show you how.

I don't need to see the real data but I do need to see something that gives me the idea. As an example, the data might look like this:

RDWBBBBBH
RDWBBBBBDXYZ
RDWBBBBBDQRS
RDWAAAAAH
RDWAAAAADRST
RDWAAAAADLMN
RDWAAAAAAPOV
....

You need to provide something like that to give me the idea.

Is there something that identifies a header record vs a detail record? What?

Are the keys actually numeric in order or are they something else?
Back to top
View user's profile Send private message
calspach

New User


Joined: 05 May 2006
Posts: 32
Location: USA

PostPosted: Thu Sep 13, 2007 10:46 pm    Post subject:
Reply with quote

The key is numeric, but the keys are not always just a sequential key.

Here is a de-identified sample of the actual data...
H0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
H0725519050773000001
D0725519050773000001
H0725519061838000001
D0725519061838000001
H0725519061838000002
D0725519061838000002
H0725519061838000003
D0725519061838000003
D0725519061838000003
H0725519062219000001
D0725519062219000001
H0725519062273000001
D0725519062273000001

The Key is in positions 2 thru 20. There is an indicator that says if it's a header or detail in position 1, H=Header, D=Detail.... Sorry, guess I should have done this in the beginning, but they're pretty sensitive about this data, being healthcare related.
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 Sep 13, 2007 11:51 pm    Post subject:
Reply with quote

Ok, that's what I needed. Here's a DFSORT job that will do what you asked for. I assumed your input file was VB since you mentioned that in one of your posts. I used 3 groups but you can change it to n groups by changing GRPS,+3 to GRPS,+n.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD *
GRPS,+3
/*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5:SEQNUM,8,ZD,21:5)),
        IFTHEN=(WHEN=(21,1,CH,EQ,C'H'),
                OVERLAY=(5:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(13:SEQNUM,8,ZD,
                         5:5,8,ZD,SUB,13,8,ZD,M11,LENGTH=8))
  OUTFIL INCLUDE=(5,8,ZD,LE,GRPS),BUILD=(1,4,5:21)
/*


For your input example and 3 groups, the output would be the first three groups:

Code:

H0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
D0725519045433000010
H0725519050773000001
D0725519050773000001
H0725519061838000001
D0725519061838000001


Is that what you want?
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
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 Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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