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 a file and include header & trailer records with c

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

New User


Joined: 24 Nov 2006
Posts: 2
Location: South Africa

PostPosted: Tue Jun 24, 2008 5:23 pm    Post subject: Split a file and include header & trailer records with c
Reply with quote

Hi,

I need to spilt a file into 3 files and to include the header and trailer records from the input file in all the output files. The output file header record will be exactly the same as the input file header record but the input file trailer record has a count which excludes the header & trailer records. The output file trailer record should have the exact count as the number of detail records in that file i.o.w. if the output file has 202 records, the count in the trailer record should be 200 as the count excludes the header and trailer records.
I have used the following jcl to split the file:
//*
//**--------------------------------------------------------------**
//** Splits the DMRHAK2 file into 3 equal size files viz: **
//** DMRHAAK1, DMRHAAK2 & DMRHAAK3. **
//** Note: This step will run only if there are records in the **
//** DMRHAK2 file. **
//**--------------------------------------------------------------**
//*
//SPLITK2 EXEC PGM=ICETOOL,COND=(0,NE,REPRO1RC)
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=QNGG00.DXPACK.DMRHAK2.D0.SQ356,DISP=SHR
//CNT DD DSN=&&C,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SPLCTL DD DSN=&&S,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT1 DD DSN=QNGG00.DXPACK.DMRHAA1.D0.SQ356,DISP=OLD
//OUT2 DD DSN=QNGG00.DXPACK.DMRHAA2.D0.SQ356,DISP=OLD
//OUT3 DD DSN=QNGG00.DXPACK.DMRHAA3.D0.SQ356,DISP=OLD
//TOOLIN DD *
*
*-----------------------------------------*
* GET COUNT OF RECORDS IN INPUT FILE *
*-----------------------------------------*
*
COPY FROM(SORTIN) USING(CTL1)
*
*-----------------------------------------*
* SET UP CONTROL STATEMENT WITH: *
* SPLIT BY=N *
* WHERE N = (COUNT+2)/3 *
*-----------------------------------------*
*
COPY FROM(CNT) TO(SPLCTL) USING(CTL2)
*
*-----------------------------------------*
* SORT WITH: *
* OUTFIL FNAMES=(OUT1,OUT2,OUT3) *
* SPLITBY=N *
*-----------------------------------------*
*
SORT FROM(SORTIN) USING(CTL3)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=CNT,NODETAIL,REMOVECC,
TRAILER1=(COUNT=(M11,LENGTH=8))
/*
//CTL2CNTL DD *
OUTREC FIELDS=(2X,
C'SPLITBY=',((1,8,ZD,ADD,+2),DIV,+3),M11,LENGTH=8,80:X)
/*
//CTL3CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=(OUT1,OUT2,OUT3),
/*
// DD DSN=*.SPLCTL,VOL=REF=*.SPLCTL,DISP=(OLD,PASS)

The data look something like this:
0020080620 (header record)
0132000000001KFWKVA00000000000
0132000039919KFWKVA00000000000
0132000039954KFWKVA00000000000
0132000039971KFWKVA00000000000
99000000598 (trailer record)

This file has a total of 600 records - the count excludes tha header and trailer records.

Thanks.
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 25, 2008 3:46 am    Post subject:
Reply with quote

Divinebeing,

The following DFSORT JCL will give you the desired results. I assumed that your header is identified by '00' in first 2 positions and the trailer by '99' in the first 2 bytes. We get the total no: of all the detail records and divide by 3 to split them evenly. however just so you know that some times one of the file may have an additional records if the division does not result in remainder zero

For ex: if you have 600 detailed records then all 3 files have 202 records (200 detail + 1 header and 1 trailer)

If you have 598 records then out1 and out2 will have 201 records (199 detail + 1 header and 1 trailer)

Out 3 will have 202 records (200(598- 2* 199) records + 1 header + 1 tailer

Code:

//STEP0100 EXEC PGM=ICEMAN       
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD DSN=your input file,
//            DISP=SHR           
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,1)) 
//T2       DD DSN=&&T2,DISP=(,PASS),SPACE=(TRK,(1,1)) 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC OVERLAY=(81:SEQNUM,8,ZD)                                       
  OUTREC OVERLAY=(81:81,8,ZD,DIV,+3,M11,LENGTH=8,X,                   
                  +1,ADD,81,8,ZD,M11,LENGTH=8,X,                       
                  +2,MUL,81,8,ZD,M11,LENGTH=8,X,                       
                  +1,ADD,(+2,MUL,(81,8,ZD)),M11,LENGTH=8)             
                                                                       
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                                 
  OMIT=(1,2,SS,EQ,C'00,99'),                                           
  TRAILER1=(' SORT FIELDS=COPY',/,                                     
  ' OMIT COND=(1,2,ZD,EQ,0,OR,1,2,ZD,EQ,99)',/,                       
  ' OUTFIL FNAMES=OUT1,STARTREC=1',',ENDREC=',81,8,C',',/,             
  ' REMOVECC,HEADER1=(H1,H2),TRAILER1=(T1,COUNT=(M11,LENGTH=8)) ',/,   
  ' OUTFIL FNAMES=OUT2,STARTREC=',90,8,',ENDREC=',99,8,C',',/,         
  ' REMOVECC,HEADER1=(H1,H2),TRAILER1=(T1,COUNT=(M11,LENGTH=8)) ',/,   
  ' OUTFIL FNAMES=OUT3,STARTREC=',108,8,C','/,                         
  ' REMOVECC,HEADER1=(H1,H2),TRAILER1=(T1,COUNT=(M11,LENGTH=8)) ',80:X)
                                                                       
  OUTFIL FNAMES=T2,SAVE,IFOUTLEN=80,                                   
  IFTHEN=(WHEN=(1,2,CH,EQ,C'00'),                                     
  BUILD=(C'H1,C''',1,40,C'''',/,C'H2,C''',41,40,C'''',80:X)),         
  IFTHEN=(WHEN=(1,2,CH,EQ,C'99'),                                     
  BUILD=(C'T1,C''',1,2,C'''',80:X))                                   
/*                                                                     
//STEP0200 EXEC PGM=ICEMAN       
//SYSOUT   DD SYSOUT=*           
//SYMNAMES DD DSN=&&T2,DISP=SHR 
//SORTIN   DD DSN=your input file,
//            DISP=SHR           
//OUT1     DD SYSOUT=*           
//OUT2     DD SYSOUT=*           
//OUT3     DD SYSOUT=*           
//SYSIN    DD DSN=&&T1,DISP=SHR 
/*


Hope this helps...

Cheers

Kolusu
Back to top
View user's profile Send private message
Divinebeing

New User


Joined: 24 Nov 2006
Posts: 2
Location: South Africa

PostPosted: Mon Jun 30, 2008 8:40 pm    Post subject: Split a file and include header & trailer records with c
Reply with quote

Hi Kolusu,

Thanks for the solution - it has worked. Can you please explain this parameter as I may need to split it into 9 or 10 files.
: OUTREC OVERLAY=(81:81,8,ZD,DIV,+3,M11,LENGTH=8,X,
+1,ADD,81,8,ZD,M11,LENGTH=8,X,
+2,MUL,81,8,ZD,M11,LENGTH=8,X,
+1,ADD,(+2,MUL,(81,8,ZD)),M11,LENGTH=8)
as I may need to split it into 9 or 10 files.
Also please explain the trailer parameter as this will need to be changed.
Thanks for all your help.
Regards
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Jun 30, 2008 10:41 pm    Post subject:
Reply with quote

divinebeing,

Code:

OUTREC OVERLAY=(81:81,8,ZD,DIV,+3,M11,LENGTH=8,X,


We are dividing the seqnum by 3 ( no: of fines we want to split) and the result is stored as 8 byte field with leading zeros . M11 is an edit mask which puts the result in readable format with leading zeroes.

x denotes a space

Code:

+1,ADD,81,8,ZD,M11,LENGTH=8,X,


We are adding +1 to the result we calculated earlier. This will be used to as the STARTREC field for outfil2

Code:

+2,MUL,81,8,ZD,M11,LENGTH=8,X,


We are multiplying the result we got in step1 to use it as ENDREC on file 2
Code:

+1,ADD,(+2,MUL,(81,8,ZD)),M11,LENGTH=8)


We are adding +1 to the step3 calculated result , so that we can use that as STARTREC parm for the last file. Since we want to copy all the records we dont specify the ENDREC parm on the last file.

The trailer parm is created by taking the trailer record and creating a symbol with its contents and we just use them in the next step when spliting the records

Look at the generated Sysin control cards and you will notice the symbol T1
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 Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am


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