Remove empty files from input file



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Remove empty files from input file

Postby kavita5152003 » Wed Jun 05, 2013 12:52 am

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
kavita5152003
 
Posts: 1
Joined: Wed Jun 05, 2013 12:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: Remove empty files from input file

 

Re: Remove empty files from input file

Postby dick scherrer » Wed Jun 05, 2013 1:03 am

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?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Remove empty files from input file

Postby c62ap90 » Thu Jun 06, 2013 5:25 pm

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.
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Remove empty files from input file

Postby Akatsukami » Thu Jun 06, 2013 7:19 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Remove empty files from input file

Postby c62ap90 » Thu Jun 06, 2013 9:56 pm

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.
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post