Page 1 of 1

Create a report from a file only If some records found

PostPosted: Thu Feb 03, 2011 5:47 pm
by javivi
Hi

I have a file with 150 recl and i need to generate a simple report only if in the file we have records with a ASTERIC in the position 125.
Every record with a asterisc must be print. If no one record exist with a asteric in pos 125, I need to create the report only with a text: TODAY WE HAVE NO ERRORS.

It is possible?

Re: Create a report from a file only If some records found

PostPosted: Thu Feb 03, 2011 10:40 pm
by skolusu
javivi,

Use the following DFSORT JCL which will give you the desired results. Step0100 will set a return code of 4 when your input file does not have '*' records. step0200 will ONLY run when you don't have '*' records.

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=Your input file,DISP=SHR
//SORTOUT  DD DSN=Your Output file,
//            DISP=(New,CATLG,DELETE),
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                                 
  OPTION COPY,NULLOUT=RC4                                       
  INCLUDE COND=(125,1,CH,EQ,C'*')                               
//*                                                             
//STEP0200 EXEC PGM=SORT,COND=(0,EQ,STEP0100)                   
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=Your Output file from step0100,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTFIL REMOVECC,BUILD=(80X),                                   
  HEADER1=('ON ',DATE=(4MD-),' WE HAVE NO ERRORS.')             
//*