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.
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.
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...
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.
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 )
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))
//*
//******************************************************************
//* 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
//*