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
 

 

Split files into multiple files and copy header from input

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

New User


Joined: 07 Jun 2011
Posts: 9
Location: india

PostPosted: Wed Jun 08, 2011 12:01 am    Post subject: Split files into multiple files and copy header from input
Reply with quote

I have a requirement to split the detail records from input files into multiple output files. All the output files should contain the same header and same footer from input. The input can be split into any no of outputs.

Input file Format: VB 1074

01... == Header
02..... == Detail
02..... == Detail
02..... == Detail
02..... == Detail
02..... == Detail
03... == Trailer

After Spliting

File 1

01... == Header
02..... == Detail
02..... == Detail
03... == Trailer

File 2

01... == Header
02..... == Detail
02..... == Detail
03... == Trailer

File 3

01... == Header
02..... == Detail
03... == Trailer

Kindly pls help on this.

thanks

Jumana
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 08, 2011 12:07 am    Post subject:
Reply with quote

jumana haseen,

You want split your input file with 2 detail records in output file along with header and trailer?

jumana haseen wrote:
The input can be split into any no of outputs.


What happens if your input file has a million records ? Are you going to split them into 499,999 files?

Unless you issue SVC99 via a program there is no way a batch version can handle that many DD's
Back to top
View user's profile Send private message
jumana haseen

New User


Joined: 07 Jun 2011
Posts: 9
Location: india

PostPosted: Wed Jun 08, 2011 8:15 am    Post subject:
Reply with quote

Sorry .. Might be my statement was not clear.

Thr no of records in the input file is not fixed.. I can create as much as outputs..

For eg ,if there are 101 records in a file, i need to split the file in such a way that there are 20 records in each file..

File 1 - 20
File 2 - 20
File 3 - 20
File 4 - 20
File 5 - 21

As per ur ex. if there are 499,999 records in the input, then i can split the file as below.


File 1 - 100000
File 2 - 100000
File 3 - 100000
File 4 - 100000
File 5 - Remaining 99999


In all the output files there should be a header and footer which should be copied from the header and footer of input file.

Hope iam clear.. I have refererd ths sites and i coudl see a lot of anwers.. but that doesnt exacty fit my requirement,..

Would be great if some one can help me out in this.
Back to top
View user's profile Send private message
sandhyaimmadi

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 08, 2011 8:53 am    Post subject: Split files into multiple files and copy header from input
Reply with quote

Jumaan,

Using OUTFIL statement in SORT you can split header,detail and trailer into seperate files.

Again using OUTFIL,STARTREC and ENDREC you can split detail recs as many as u require into seperate files.

At the end using IEBGENER, u can combine header,detail and trailer files.

Regards,
Sandhya
Back to top
View user's profile Send private message
jumana haseen

New User


Joined: 07 Jun 2011
Posts: 9
Location: india

PostPosted: Wed Jun 08, 2011 9:10 am    Post subject:
Reply with quote

Hi ,

Is it possible to achieve all these in same step..

My input files has huge no of records(around 10 million).. i wanted to split the files having 1 million each and FTP that .

So it would be taking a lot of time to complete if i put 3 different steps as mentioned.

Is it possible to ahiveve splitting, copying header and footer from input in a single step.

Please advice..
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed Jun 08, 2011 9:40 am    Post subject:
Reply with quote

jumana haseen wrote:
Hi ,

Is it possible to achieve all these in same step..

My input files has huge no of records(around 10 million).. i wanted to split the files having 1 million each and FTP that .

So it would be taking a lot of time to complete if i put 3 different steps as mentioned.

Is it possible to ahiveve splitting, copying header and footer from input in a single step.

Please advice..


Instead of splitting the file into 'n' output files, couldn't you use a sort sequence number such that the file is logically divided into subfiles(or batches inside the same file).
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed Jun 08, 2011 9:55 am    Post subject:
Reply with quote

I surely have seen such a job in past which sends a big file over a network in pieces.

Could you check you inbox(private messages) please?

Have a look at this thread http://ibmmainframes.com/about2988.html. This will give a clue about a possible solution.
Back to top
View user's profile Send private message
jumana haseen

New User


Joined: 07 Jun 2011
Posts: 9
Location: india

PostPosted: Wed Jun 08, 2011 10:04 am    Post subject:
Reply with quote

Yes.. Definetely hav seen a lot of posts.. But cud not arrive at this solution..

Any way of splitting and any no of records in the splitted file is fine .. just wanted to heve the same header and footer from the input in the splitted files...
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed Jun 08, 2011 10:09 am    Post subject:
Reply with quote

jumana haseen wrote:
just wanted to heve the same header and footer from the input in the splitted files...


Headers and trailers have details such as : batch number, count of the number of records, accumulated totals etc. Are you sure your subfiles should have the SAME header and trailer records as in the main file?
Back to top
View user's profile Send private message
jumana haseen

New User


Joined: 07 Jun 2011
Posts: 9
Location: india

PostPosted: Wed Jun 08, 2011 10:18 am    Post subject:
Reply with quote

My input looks like this. We dont have any count or totals here.

Input:

01|XXX|20110602|OO| -------------------------- Header
02|XXX|20110602|POL|aaaa1|bbbb1 -------------------------- Detail
02|XXX|20110602|POL|aaaa2|bbbb2 -------------------------- Detail
02|XXX|20110602|POL|aaaa3|bbbb3 -------------------------- Detail
02|XXX|20110602|POL|aaaa4|bbbb4 -------------------------- Detail
02|XXX|20110602|POL|aaaa4|bbbb4 -------------------------- Detail
03| -------------------------- Footer

Need to Split the files into any no of output files.. and add header and footer to all split file..

In this eg, since there are 5 '02' records, I can split the files containg 2 record in file1 , 2 in file 2 and 1 in file 1 as below.

Output file1

01|XXX|20110602|OO| -------------------------- Header
02|XXX|20110602|POL|aaaa1|bbbb1 -------------------------- Detail
02|XXX|20110602|POL|aaaa2|bbbb2 -------------------------- Detail
03| -------------------------- Footer

Output file2

01|XXX|20110602|OO| -------------------------- Header
02|XXX|20110602|POL|aaaa3|bbbb3 -------------------------- Detail
02|XXX|20110602|POL|aaaa4|bbbb4 -------------------------- Detail
03| -------------------------- Footer

Output file3

01|XXX|20110602|OO| -------------------------- Header
02|XXX|20110602|POL|aaaa5|bbbb5 -------------------------- Detail
03| -------------------------- Footer

No of output files and no of records doesnt matter.


Hope iam clear..
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: Wed Jun 08, 2011 9:51 pm    Post subject:
Reply with quote

I'm not sure if you're clear or not.

If you want to split an input file to 3 output files by specifying the number of records in each file, you can use a DFSORT job like the following:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (VB/1074)
//OUT1 DD DISP=MOD,DSN=...  output file1 (VB/1074)
//OUT2 DD DISP=MOD,DSN=...  output file2 (VB/1074)
//OUT3 DD DISP=MOD,DSN=...  output file3 (VB/1074)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(IN) USING(CTL2)
COPY FROM(IN) USING(CTL3)
/*
//CTL1CNTL DD *
  OPTION STOPAFT=1
  OUTFIL FNAMES=(OUT1,OUT2,OUT3)
/*
//CTL2CNTL DD *
  INCLUDE COND=(5,2,CH,EQ,C'02')
  OUTFIL FNAMES=(OUT1,OUT2,OUT3),
     SPLIT1R=2       <---- change as needed
/*
//CTL3CNTL DD *
  INCLUDE COND=(5,2,CH,EQ,C'03')
  OUTFIL FNAMES=(OUT1,OUT2,OUT3)
/*


For different numbers of records, just change the SPLIT1R=n value (e.g. SPLIT1R=20 if you want 20 records in each file).

If you want something more dynamic that calculates the value for SPLIT1R, you combine the job above with the technique shown in the "Split a file to n output files dynamically" Smart DFSORT Trick at:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
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 syncsort: copy lines after the keyword shreya19 SYNCSORT 3 Fri Dec 02, 2016 9:47 am
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


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