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

Split a file to two files retaining Header n Trailer on each


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Fri Jun 15, 2007 11:53 am
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
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
Reply with quote

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

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
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
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 Developer


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

PostPosted: Fri Jun 15, 2007 9:08 pm
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
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
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
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 Developer


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

PostPosted: Mon Jun 25, 2007 8:08 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top