|
View previous topic :: View next topic
|
| Author |
Message |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
Hello...
I have to create a file(s) for a user, but their system can only handle 5000 records per file...
How do I breakup one large master file (which can have as little as 15, or as many as 35,000 records) in to smaller files (that contain 5000 records each).
The most records I’ll have in the master file is 35,000.
Thanks
Squeak… |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Squeak6,
Please refer to this post :- ibmmainframes.com/viewtopic.php?t=50525
Are you ok, if DFsort always create 7 output files but some of these can be empty? Is there a way to logically group your input records (for example, records with header and/or trailer)? If yes, please show sample input records.
Thanks, |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Squeak,
If you just want to break up the input file into output files with a maximum of 5000 records, you can use this simple DFSORT job:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//OUT1 DD DSN=... outut file1
//OUT2 DD DSN=... outut file2
...
//OUT7 DD DSN=... outut file2
//SYSIN DD *
OPTION COPY
OUTFIL SPLIT1R=5000,
FNAMES=(OUT1,OUT2,OUT3,OUT4,OUT5,OUT6,OUT7)
/*
|
If you want something more elaborate, you need to describe exactly what you want. |
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
this is exactly what I need... I'll have to and a RC check step ( copy the output file to a new file to see if its empty, before I ftp the file ) I'll have to do that for each file...
thanks.
Squeak... |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Squeak,
you don't need to copy the output file to a new file to see if it's empty
| Code: |
| COUNT FROM(IN) EMPTY RC4 |
Gerry |
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
the code worked great, but I forgot that I have a header record that I need to add to each new output file.. ( if needed ) below is my input master file.
| Code: |
"First Name","Middle Name","Last Name","Employee ID","Address1"
"TIM ","D","SMALL ","e9 ","
|
Record format . . . : FB
Record length . . . : 350 |
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
| gcicchet ~ I'll need to know which one of my 7 ouptut files are empty because I'm sending the data via FTP. ( that's why I was doing an empty check step for each output file ) |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
What Gerry told you is that you do not need to copy the file to see if it is empty. . . |
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
dick scherrer ~ thanks
but how do I add the header that's on my master file to each of the 7 files ( add only if the file(s) have data.. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Squeak6,
Is the header part of the input file? or is it something you can add as part of reporting features? |
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
The header is about of the orgianl master input file.. ( its just a standard header for a CSV file without totals )
| Code: |
"First Name","Middle Name","Last Name","Employee ID","Address1",
|
|
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
" The Header is apart of the orgianal input file.. "
| Code: |
"First Name","Middle Name","Last Name","Employee ID","Address1","Ad
"TIM ","D","SMALL ","e9 "," "
"TODD ","O","MC CARTHY ","e11 "," "
"JIM ","W","LUCIUS ","e16 "," "
|
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Squeak6,
The following JCL will give you the desired results.
1. I assumed that your input is FB recfm and 80 bytes of length.
2. The FTP card is of the format PUT 'USERID.OUT1' 'OUT1.TXT'
3. The max number of records per file is 5000 and you will only process a total max of 35,000 records.
4. The header is the 1st record in the input.
| Code: |
//******************************************************************
//* SPLIT THE INPUT FILE INTO 7 OUT FILES EACH WITH 5000 RECORDS *
//******************************************************************
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your 80 byte FB lrecl file,DISP=SHR
//OUT1 DD DSN=USERID.OUT1,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT2 DD DSN=USERID.OUT2,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT3 DD DSN=USERID.OUT3,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT4 DD DSN=USERID.OUT4,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT5 DD DSN=USERID.OUT5,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT6 DD DSN=USERID.OUT6,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//OUT7 DD DSN=USERID.OUT7,DISP=(,CATLG),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
SORT FIELDS=COPY,STOPAFT=35000
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,START=4998)),
IFTHEN=(WHEN=INIT,OVERLAY=(89:81,8,ZD,DIV,+4999,M11,LENGTH=2))
OUTFIL FNAMES=OUT1,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,1)
OUTFIL FNAMES=OUT2,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,2)
OUTFIL FNAMES=OUT3,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,3)
OUTFIL FNAMES=OUT4,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,4)
OUTFIL FNAMES=OUT5,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,5)
OUTFIL FNAMES=OUT6,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,6)
OUTFIL FNAMES=OUT7,BUILD=(1,80),
INCLUDE=(89,2,ZD,EQ,0,OR,89,2,ZD,EQ,7)
//*
//******************************************************************
//* CHECK IF ANY OF THE FILES ARE EMPTY AND DELETE THEM. *
//* WRITE THE FTP CARD IF THE FILE IS NOT EMPTY(EXLUDING HEADER). *
//* SET MAXCC=8 IF THERE ARE NO RECORDS TO FTP. *
//******************************************************************
//STEP0200 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//FTPI DD *
PUT 'USERID.OUT1' 'OUT1.TXT'
PUT 'USERID.OUT2' 'OUT2.TXT'
PUT 'USERID.OUT3' 'OUT3.TXT'
PUT 'USERID.OUT4' 'OUT4.TXT'
PUT 'USERID.OUT5' 'OUT5.TXT'
PUT 'USERID.OUT6' 'OUT6.TXT'
PUT 'USERID.OUT7' 'OUT7.TXT'
//IN1 DD DISP=SHR,DSN=USERID.OUT1
//IN2 DD DISP=SHR,DSN=USERID.OUT2
//IN3 DD DISP=SHR,DSN=USERID.OUT3
//IN4 DD DISP=SHR,DSN=USERID.OUT4
//IN5 DD DISP=SHR,DSN=USERID.OUT5
//IN6 DD DISP=SHR,DSN=USERID.OUT6
//IN7 DD DISP=SHR,DSN=USERID.OUT7
//*
//FTPO DD DSN=USERID.FTPCARD,
// DISP=(MOD,PASS),SPACE=(TRK,(1,1),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=27920)
//*
//SYSIN DD *
PRINT INFILE(IN1) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1)
ELSE IF LASTCC = 4 THEN DO
DELETE 'USERID.OUT1'
SET MAXCC=8
END
PRINT INFILE(IN2) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1) SKIP(1)
ELSE IF LASTCC = 4 THEN DELETE 'USERID.OUT2'
PRINT INFILE(IN3) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1) SKIP(2)
ELSE IF LASTCC = 4 THEN DELETE 'USERID.OUT3'
PRINT INFILE(IN4) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1) SKIP(3)
ELSE IF LASTCC = 4 THEN DELETE 'USERID.OUT4'
PRINT INFILE(IN5) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1) SKIP(4)
ELSE IF LASTCC = 4 THEN DELETE 'USERID.OUT5'
PRINT INFILE(IN6) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1) SKIP(5)
ELSE IF LASTCC = 4 THEN DELETE 'USERID.OUT6'
PRINT INFILE(IN7) CHARACTER COUNT(2)
IF LASTCC = 0 THEN REPRO IFILE(FTPI) OFILE(FTPO) COUNT(1) SKIP(6)
ELSE IF LASTCC = 4 THEN DELETE 'USERID.OUT7'
//*
//******************************************************************
//* FTP ONLY IF THERE IS ATLEAST 1 FILE TO SEND. *
//******************************************************************
//STEP0300 EXEC PGM=FTP,COND=(8,EQ,STEP0200)
//SYSPRINT DD SYSOUT=*
//INPUT DD *
ip addr
userid
password
// DD DSN=USERID.FTPCARD,DISP=SHR
// DD *
CLOSE
QUIT
//* |
|
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
Skolusu..
thank you for the code... ( I'm going to study it so I can undersand how it works )
will this include the Header in the file(s) being FTP'd? |
|
| Back to top |
|
 |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
| As I need the Header to be apart of the newly created files... |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| As I need the Header to be apart of the newly created files... |
Possibly better understood if you posted some example(s). |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Squeak6 wrote: |
Skolusu..
thank you for the code... ( I'm going to study it so I can undersand how it works )
will this include the Header in the file(s) being FTP'd? |
Yes. You could have run the given job and see how it works. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|