MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Copy records before and after

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Sun Oct 14, 2007 1:06 pm    Post subject: Copy records before and after Reply with quote

Hi All,

Here's a brief description of the problem. I have a input file which has a header( group of records) , records and a trailer( group of records).

I need to copy the header , selective records and the trailer.

Ex:

Code:


Input file

1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
.
.
.
.
2007sort1234454545
set of records
.
.
.
.
.
2005sort1234454545
2006sort1234454545
2008sort1234454545
2008sort1234454545
2007sort888999898
set of records
.
.
.
.
.
.
.
.
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
.
.
.
.
End of file.

Output file :

1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
.
.
.
.
2007sort1234454545
set of records
.
.
.
.
.
2007sort888999898
set of records
.
.
.
.
.
.
.
.
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
.
.
.
.
End of file.




Output file should contain:

- All the header records.
- All 2007 records.( Here all the set of records under 2007 should be copied over)
- All the trailer record.

In other words I need to exclude all the records which does not belong to 2007 year.

Any solutions?

-Mt
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Sun Oct 14, 2007 4:10 pm    Post subject: Reply with quote

Have you looked at INCLUDE/OMIT in the sort manual?
This sounds like a very simple task for even a beginner....
Back to top
View user's profile Send private message
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Mon Oct 15, 2007 12:40 am    Post subject: Reply with quote

CICS Guy,

The problem that am facing here is how do I exclude the set of records which come under the 2005,2006,2008 records. There is no unique identifier for these records.

-Mt
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Mon Oct 15, 2007 6:59 am    Post subject: Reply with quote

Well, you either have to have something unique in the headers and trailers or something unique in the details - one or the other.......
Back to top
View user's profile Send private message
krisprems
Beginner


Joined: 13 Dec 2006
Posts: 101
Topics: 4
Location: india

PostPosted: Mon Oct 15, 2007 8:16 am    Post subject: Reply with quote

Martin
Quote:

1xxxxxxxxxxxxxxxx -- > Header record
2xxxxxxxxxxxxxxxx -- > Header record
3xxxxxxxxxxxxxxxx -- > Header record

The headers or the trailers that you have shown, is there any way to identify these records(any uniqueness), and also are these 1st three and last three records of your input file?
_________________
cHEERs
krisprems
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Mon Oct 15, 2007 8:40 am    Post subject: Reply with quote

Martin,

I am assuming that the no of header records and the trailer records = 3 and that there are any only one set of header and trailer records.

Try my below suggestion:

1. Extract the first 3 records to a temporary dataset t1.
2. Extract the last 3 records to a temporary dataset t2.
3. Extract the inbetween records with INCLUDE COND=(1,4,CH,EQ,C'2007') to a temporary dataset t3.
4. Concatenate the datasets T1 + T3 + T2 and place it in the output file.

As I am at home cannot provide u with the JCL now.
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Oct 15, 2007 1:05 pm    Post subject: Reply with quote

Martin,

You haven't given much detail about what your input records actually look like. But I'll make some assumptions so I can show you how to do this kind of thing with DFSORT/ICETOOL. I'll assume that:
- the first header record and the first trailer record have '1' in position 1 and none of the other input records do
- the year records have '20' in positions 1-2 and none of the other input records do
- the input file has RECFM=FB and LRECL=80

Given those assumptions, here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
2007sort1234454545
Record 01 A
Record 02 B
2005sort1234454545
2006sort1234454545
2008sort1234454545
Record 01 X
2008sort1234454545
2007sort888999898
Record 01 C
Record 02 D
Record 03 3
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
/*
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
SPLICE FROM(IN) TO(OUT) ON(85,8,ZD) KEEPNODUPS KEEPBASE -
  WITHALL WITH(1,80) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,4,85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(81,2,CH,EQ,C'20',OR,81,1,CH,EQ,C'1'),
                OVERLAY=(85:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(93:SEQNUM,8,ZD,
                         85:85,8,ZD,SUB,93,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,
    INCLUDE=(81,4,CH,EQ,C'2007',OR,81,1,CH,EQ,C'1'),
    BUILD=(1,80)
/*


OUT would have:

Code:

1xxxxxxxxxxxxxxxx  -- > Header record         
2xxxxxxxxxxxxxxxx  -- > Header record         
3xxxxxxxxxxxxxxxx  -- > Header record         
2007sort1234454545                             
Record 01 A                                   
Record 02 B                                   
2007sort888999898                             
Record 01 C                                   
Record 02 D                                   
Record 03 3                                   
1xxxxxxxxxxxxxxxx  -- > Trailer record         
2xxxxxxxxxxxxxxxx  -- > Trailer record         
3xxxxxxxxxxxxxxxx  -- > Trailer record         

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Jul 29, 2008 4:25 pm    Post subject: Reply with quote

Here's an easier and more efficient way to do this using the new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008):

Code:

//S1  EXEC  PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1xxxxxxxxxxxxxxxx  -- > Header record
2xxxxxxxxxxxxxxxx  -- > Header record
3xxxxxxxxxxxxxxxx  -- > Header record
2007sort1234454545
Record 01 A
Record 02 B
2005sort1234454545
2006sort1234454545
2008sort1234454545
Record 01 X
2008sort1234454545
2007sort888999898
Record 01 C
Record 02 D
Record 03 3
1xxxxxxxxxxxxxxxx  -- > Trailer record
2xxxxxxxxxxxxxxxx  -- > Trailer record
3xxxxxxxxxxxxxxxx  -- > Trailer record
/*
//OUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,
          BEGIN=(1,2,CH,EQ,C'20',OR,1,1,CH,EQ,C'1'),
          PUSH=(81:1,4))
  OUTFIL INCLUDE=(81,4,CH,EQ,C'2007',OR,81,1,CH,EQ,C'1'),
    BUILD=(1,80)
/*


For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group