Page 1 of 1

Remove empty files from input file

PostPosted: Wed Jun 05, 2013 12:52 am
by kavita5152003
Hi,

I have a input file which inturn has around 2000 file names. My requirement is to skip all the empty files and copy the file names which ahs data into another file.

e.g
My input file xxx.yyy.xxx, the content is

aaa.bbb.ccc
ddd.eee.fff
ggg.hhh.iii

If the first file is empty and the last two files has some data, my output file should have

ddd.eee.fff
ggg.hhh.iii

Please help.

Thanks,
Kavita

Re: Remove empty files from input file

PostPosted: Wed Jun 05, 2013 1:03 am
by dick scherrer
Hello and welcome to the forum,

First you need to understand that what you want cannot be done "by JCL".

One way to proceed would be to have some code (REXX?) that would read your "control file" and then determine if each of the files named is empty or has data.

Why does someone believe this is a good use of a developer's time?

Re: Remove empty files from input file

PostPosted: Thu Jun 06, 2013 5:25 pm
by c62ap90
Doing this task if fairly easy but explaining how to do it is not so easy in a forum.

What I have done for these kinds of tasks is create an Easytrieve to read in the 2000 file names and create output similar to JCL code below to determine if file is empty. In the Easytrieve you would need to increment the step name for each record read (STEP001, STEP002, etc.) so that you could examine the Return Code, and of course replace FILEA DSN for each record read.

//**********************************************************
//* PRINT 1-RECORD TO DETERMINE IF FILE IS EMPTY           
//* - RETURN CODE = 00 WHEN DSN HAS AT LEAST 1 RECORD       
//*   RETURN CODE = 04 WHEN DSN HAS 0 RECORD {EMPTY}       
//**********************************************************
//STEP001  EXEC PGM=IDCAMS                                 
//SYSPRINT DD SYSOUT=*                                     
//SYSUDUMP DD SYSOUT=*                                     
//SYSOUD   DD SYSOUT=*                                     
//SYSOUT   DD SYSOUT=*                                     
//FILEA    DD DISP=SHR,DSN=aaa.bbb.ccc  <=== verify if empty
//SYSIN    DD *
    PRINT INFILE(FILEA) CHAR COUNT(1)
/*
// IF (STEP001.RC EQ 0) THEN   
   < add aaa.bbb.ccc file to output dataset file.has.data [mod,catlg,delete] >
// ENDIF


//STEP002  EXEC PGM=IDCAMS     
…                           
//FILEA    DD DISP=SHR,DSN=ddd.eee.fff  <=== verify if empty

// IF (STEP002.RC EQ 0) THEN   
   < add ddd.eee.fff  file to output dataset file.has.data [mod,catlg,delete] >
// ENDIF

Etc.

Re: Remove empty files from input file

PostPosted: Thu Jun 06, 2013 7:19 pm
by Akatsukami
c62ap90 wrote:Doing this task if fairly easy but explaining how to do it is not so easy in a forum.

What I have done for these kinds of tasks is create an Easytrieve to read in the 2000 file names and create output similar to JCL code below to determine if file is empty. In the Easytrieve you would need to increment the step name for each record read (STEP001, STEP002, etc.) so that you could examine the Return Code, and of course replace FILEA DSN for each record read.

Creating 2,000 jobs, or one job with 2,000 steps? (Which of course will not run.)

As Mr. Scherrer suggests, some Rexx that tailors a skeleton, creating one job with two steps (one that runs, e.g., IDCAMS to determine if the target data set is empty or not, and one to parse the IDCAMS output and assemble the output data set), would be more appropriate.

Re: Remove empty files from input file

PostPosted: Thu Jun 06, 2013 9:56 pm
by c62ap90
Akatsukami wrote:
c62ap90 wrote:Doing this task if fairly easy but explaining how to do it is not so easy in a forum.

What I have done for these kinds of tasks is create an Easytrieve to read in the 2000 file names and create output similar to JCL code below to determine if file is empty. In the Easytrieve you would need to increment the step name for each record read (STEP001, STEP002, etc.) so that you could examine the Return Code, and of course replace FILEA DSN for each record read.

Creating 2,000 jobs, or one job with 2,000 steps? (Which of course will not run.)

In the Easytrieve output JCL creation, add a JOB statement after x-amount of steps.