Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Split a file to two files retaining Header n Trailer on each

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

New User


Joined: 02 Sep 2005
Posts: 26
Location: Hyderabad

PostPosted: Fri Jun 15, 2007 11:16 am    Post subject: Split a file to two files retaining Header n Trailer on each
Reply with quote

Hi all,

I have a file (GDG) containing records like: (The file in real scenario will
have millions of records)

Hfilenamedate
D131434add1
D123434add2
T002

I would want to split this into two files and want the Header and
Trailer records in each of the splitted files. (Trailer needs the count generated)

File1:
Hfilenamedate
D131434add1
T001

File2:
Hfilenamedate
D123434add2
T001

Could anyone help me on this?

Thanks,
Jaya.
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: Fri Jun 15, 2007 11:53 am    Post subject:
Reply with quote

Hello,

Please post your dcb info (dsorg/lrecl/etc) for both the input and output files.

Why is the trailer not the same in the output as the input (T002/T001)?

Will there be only one header and trailer in the input data?

Your sample has only 4 records and no "rules" on how to split them. Please post a bit more data (showing multiple headers/trailers if this may occur or clarifying that it may not) and more than just 2 data records. By chance id it the "add1" and "add2" that determines which output file the record should be placed in? Will all of the milliions of records have "addn" in them?

The more clear you present your requirement, the better/quicker responses you will receive.
Back to top
View user's profile Send private message
Jayalakshmi

New User


Joined: 02 Sep 2005
Posts: 26
Location: Hyderabad

PostPosted: Fri Jun 15, 2007 12:10 pm    Post subject:
Reply with quote

The input file is a GDG like file.G0079V00
dsorg: sequential
rlecl: 336
27888.

I would want the two ouput files to be created as (+1) of input GDG
file.G0080V00
file.G0081V00

The input file will have a single header and trailer record. No multiple header n trailer records.
The Trailer record will have the count/number of detailed records in the file.
Hence, in a file if there are 2 D records then the trailer record will be T002
The Header, detail and trailer identified by H, D and T in the first position of each record.
There is no criteria for the split up. Just want the file to splitted into two (may not be exactly equal if the total number of D records are odd) with H and T records placed at the top and bottom of the splitted files as shown above.
The splitted file's trailer record should reflect the no. of D records in that file.

A input file with 1 H , 400 D, 1T (Trailer will be T400)
2 Output files with (1) -> 1H 200D, 1T (Trailer : T200)
and (2) -> 1H 200D, 1T (Trailer : T200)

Thanks again,
Jaya.
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Fri Jun 15, 2007 12:22 pm    Post subject:
Reply with quote

Here is the link to SORT tricks, go thru it and definitely you can come up with solution.

http://www-304.ibm.com/jct01004c/systems/support/storage/software/sort/mvs/tricks/pdf/sorttrck.pdf
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Jun 15, 2007 1:02 pm    Post subject:
Reply with quote

Jayalakshmi

Is the header copied as it is from the i/p file, or
It is dynamically decided based on the file name of the new version of file created and also clarify about the date filed in the header record.
Back to top
View user's profile Send private message
Jayalakshmi

New User


Joined: 02 Sep 2005
Posts: 26
Location: Hyderabad

PostPosted: Fri Jun 15, 2007 3:18 pm    Post subject:
Reply with quote

The Header record just needs to be copied from the input file.
No significance here on date field

Thanks,
Jaya.
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: Fri Jun 15, 2007 9:08 pm    Post subject:
Reply with quote

Jaya,

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT  DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/336)
//OUT1 DD DSN=...    output file1 (FB/336)
//OUT2 DD DSN=...    output file2 (FB/336)
//SYSIN    DD    *
  OPTION COPY
  OMIT COND=(1,1,CH,EQ,C'T')
  INREC OVERLAY=(337:SEQNUM,8,ZD,START=0,INCR=5)
  OUTFIL FNAMES=OUT1,REMOVECC,
    INCLUDE=(337,8,CH,EQ,C'00000000',OR,344,1,CH,EQ,C'5'),
    BUILD=(1,336),
    TRAILER1=(C'T',COUNT-1=(M11,LENGTH=3))
  OUTFIL FNAMES=OUT2,REMOVECC,
    INCLUDE=(344,1,CH,EQ,C'0'),
    BUILD=(1,336),
    TRAILER1=(C'T',COUNT-1=(M11,LENGTH=3))
/*
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Jun 16, 2007 6:46 pm    Post subject: Re: Split a file to two files retaining Header n Trailer on
Reply with quote

Code:
INREC OVERLAY=(337:SEQNUM,8,ZD,START=0,INCR=5)

This was a brilliant and simple trick frank.
Thanks for sharing with us icon_razz.gif
Back to top
View user's profile Send private message
Jayalakshmi

New User


Joined: 02 Sep 2005
Posts: 26
Location: Hyderabad

PostPosted: Sun Jun 24, 2007 12:12 pm    Post subject: Re: Split a file to two files retaining Header n Trailer on
Reply with quote

hi Frank,

Great Thanks!

I haven't worked much on DFSORT though my rusted brain
couldn't hit on such a trick. Many Thanks!

Jaya.
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Mon Jun 25, 2007 11:31 am    Post subject: Re: Split a file to two files retaining Header n Trailer on
Reply with quote

Hi Jaya,
According to Frank's JCL,
If input file like this
Code:

H1 E1 C 000000011E10800007030000000000219005165371000100001110800
F1 E1 C 000000011E10800007030000000000219005165371000100001110800
F2 E1 C 000000011E10800007030000000000219005165371000100001110800
F3 E1 C 000000011E10800007030000000000219005165371000100001110800
F4 E1 C 000000011E10800007030000000000219005165371000100001110800
F5 E1 C 000000011E10800007030000000000219005165371000100001110800
F6 E1 C 000000011E10800007030000000000219005165371000100001110800
T100000                                                           


O/P file will be
O/P file1
Code:

 H1 E1 C 000000011E10800007030000000000219005165371000100001110800   
 F1 E1 C 000000011E10800007030000000000219005165371000100001110800   
 F3 E1 C 000000011E10800007030000000000219005165371000100001110800   
 F5 E1 C 000000011E10800007030000000000219005165371000100001110800   
 T003                                                               


O/P file2
Code:

H1 E1 C 000000011E10800007030000000000219005165371000100001110800       
F2 E1 C 000000011E10800007030000000000219005165371000100001110800       
F4 E1 C 000000011E10800007030000000000219005165371000100001110800       
F6 E1 C 000000011E10800007030000000000219005165371000100001110800       
T003                                                                   


odd records and even records are splitted into seperate file.

is it Ok?
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: Mon Jun 25, 2007 8:08 pm    Post subject:
Reply with quote

Quote:
is it Ok?


Well, yes, since it's what was asked for:

Quote:
There is no criteria for the split up. Just want the file to splitted into two (may not be exactly equal if the total number of D records are odd) with H and T records placed at the top and bottom of the splitted files as shown above.
The splitted file's trailer record should reflect the no. of D records in that file.


and apparently what was wanted:

Quote:
Great Thanks!

I haven't worked much on DFSORT though my rusted brain
couldn't hit on such a trick. Many Thanks!
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 Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us