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

Split the input file to 5 files having trailer


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Venkata Perumala

New User


Joined: 23 May 2008
Posts: 4
Location: 800 Chrysler Drive

PostPosted: Sat Aug 09, 2008 1:28 pm
Reply with quote

Hi,

I Have an input file having one trailer record with count. which is identified by 'TRAILER' FROM positon 1-7 in the input file and it is last record in the input file

Now I am splitting the input file to 5 datasets. while splitting I want the trailer record to be appended at the end of each file split with count.

The count for the trailer record is at 51-59 position in the input file. I want the trailer record with count in each split

I am using the below code to split the file to 5 files.

//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=(OUT1,OUT2,OUT3,OUT4,OUT5),SPLIT
END
/*

I request you to let me know how to achieve this.

Thanks
Venkata Perumala
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Aug 09, 2008 2:16 pm
Reply with quote

when you have determined the criteria that would control the split, you can
then refer to this link:
www.ibm.com/systems/support/storage/software/sort/mvs/tricks/

which is tips and tricks for dfsort. there are several topics about splitting files and one about creating trailer records with counts.

The Sticky's in the DFSORT forum have other links to DFSORT documentation.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Aug 09, 2008 2:17 pm
Reply with quote

Here is a link to the Sticky concerning DFSORT documentation:
ibmmainframes.com/viewtopic.php?t=1348&sid=d05e58903d25c15ce7e6b13ecccc64ed
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: Sat Aug 09, 2008 9:11 pm
Reply with quote

Venkata,

Are 'TRAILER' and the count the only fields in the trailer record?

If not, please show what the trailer record looks like. Are there fields in the original trailer record that cannot be recreated in a new trailer record? That is, could we rebuild the trailer record for each output file from scratch or are there fields that we can only get by copying them from the original trailer record?

What is the RECFM and LRECL of the input file?

Is the count in the trailer record a 9-byte ZD field or something else (what)?
Back to top
View user's profile Send private message
Venkata Perumala

New User


Joined: 23 May 2008
Posts: 4
Location: 800 Chrysler Drive

PostPosted: Sun Aug 10, 2008 1:20 pm
Reply with quote

Hi,

Thanks a lot for quick reply.

Yes the Trailer record has to be taken from the input file and the count position in the trailer reocrd has to be updated for each file splitted.

The count is 9 byte ZD

RECFM=FB
LRECL=700

Kindly let me know if more information is needed

Thanks & Regards
Venkata Perumala
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 Aug 11, 2008 10:22 pm
Reply with quote

Is the count in the trailer record the count of the data records, or the count of the data records + the trailer record?
Back to top
View user's profile Send private message
Venkata Perumala

New User


Joined: 23 May 2008
Posts: 4
Location: 800 Chrysler Drive

PostPosted: Tue Aug 12, 2008 4:03 pm
Reply with quote

The count in the trailer records does not include the trailer record count
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Aug 13, 2008 12:01 am
Reply with quote

Venkata Perumala,

The following DFSORT JCL will give you the desired results. We basically mimic the function of split using INREC. Since we are splitting the input into 5 files we add a 8 byte sequm at the end in pd format with a start number of 5, and then divide that seqnum by 5 and get the remainder. So the first record will have a remainder of 0 and the second record will have a remainder of 1, the third record will have a remainder of 2, the fourth record will have remainder of 3 and the 5th record will have a remainder of 4 and the 6th record once again will have a remainder of zero and the cycle of 5 records continues till the end.

Now using this number we start another seqnum on outrec to count the no: of records written to the output. We start with count of 0 because you dont want the trailer record to be counted as part of the total no:f records.

Using OUTFIL we split the records into different based on the remainder and while writting out we overlay the contents of the trailer records with the seqnum we added using outrec.



Code:

//STEP0100 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=YOUR INPUT DSN TO BE SPLIT,DISP=SHR
//OUT1     DD SYSOUT=*
//OUT2     DD SYSOUT=*     
//OUT3     DD SYSOUT=*     
//OUT4     DD SYSOUT=*     
//OUT5     DD SYSOUT=*
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(701:SEQNUM,8,PD,START=5,INCR=1, 
                                   701,8,PD,MOD,+5,TO=ZD,LENGTH=1))
                                                                   
  OUTREC IFTHEN=(WHEN=(709,1,ZD,EQ,0,OR,1,7,CH,EQ,C'TRAILER'),     
         OVERLAY=(710:SEQNUM,9,ZD,START=0,INCR=1),HIT=NEXT),       
         IFTHEN=(WHEN=(709,1,ZD,EQ,1,OR,1,7,CH,EQ,C'TRAILER'),     
         OVERLAY=(720:SEQNUM,9,ZD,START=0,INCR=1),HIT=NEXT),       
         IFTHEN=(WHEN=(709,1,ZD,EQ,2,OR,1,7,CH,EQ,C'TRAILER'),     
         OVERLAY=(730:SEQNUM,9,ZD,START=0,INCR=1),HIT=NEXT),       
         IFTHEN=(WHEN=(709,1,ZD,EQ,3,OR,1,7,CH,EQ,C'TRAILER'),     
         OVERLAY=(740:SEQNUM,9,ZD,START=0,INCR=1),HIT=NEXT),       
         IFTHEN=(WHEN=(709,1,ZD,EQ,4,OR,1,7,CH,EQ,C'TRAILER'),     
         OVERLAY=(750:SEQNUM,9,ZD,START=0,INCR=1))                 
                                                                   
  OUTFIL FNAMES=OUT1,IFOUTLEN=700,                                 
  INCLUDE=(709,1,ZD,EQ,0,OR,1,7,CH,EQ,C'TRAILER'),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'TRAILER'),OVERLAY=(51:710,9))           
                                                                   
  OUTFIL FNAMES=OUT2,IFOUTLEN=700,                                 
  INCLUDE=(709,1,ZD,EQ,1,OR,1,7,CH,EQ,C'TRAILER'),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'TRAILER'),OVERLAY=(51:720,9))           
                                                                   
  OUTFIL FNAMES=OUT3,IFOUTLEN=700,                                 
  INCLUDE=(709,1,ZD,EQ,2,OR,1,7,CH,EQ,C'TRAILER'),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'TRAILER'),OVERLAY=(51:730,9))           
                                                                   
  OUTFIL FNAMES=OUT4,IFOUTLEN=700,                                 
  INCLUDE=(709,1,ZD,EQ,3,OR,1,7,CH,EQ,C'TRAILER'),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'TRAILER'),OVERLAY=(51:740,9))           
                                                                   
  OUTFIL FNAMES=OUT5,IFOUTLEN=700,                                 
  INCLUDE=(709,1,ZD,EQ,4,OR,1,7,CH,EQ,C'TRAILER'),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'TRAILER'),OVERLAY=(51:750,9))           
                                                                   
/*
Back to top
View user's profile Send private message
Venkata Perumala

New User


Joined: 23 May 2008
Posts: 4
Location: 800 Chrysler Drive

PostPosted: Wed Aug 13, 2008 11:23 am
Reply with quote

Hi,

Thanks a lot for your help.

I will code this and if any issues during testing I will post reply again.


Thanks & Regards
Venkata Perumala
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 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 TRIM everything from input, output co... DFSORT/ICETOOL 1
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