Page 1 of 1

Empty Report Line

PostPosted: Sat Jul 14, 2012 12:09 am
by Dean
Hi.

I have produced a report that I expect will return no results from time to time.
What I am currently doing is this :
TRAILER1=(25:'NUMBER OF RECORDS SELECTED: ',COUNT=(M11,LENGTH=3),2/,

However, this will appear at the bottom of every report. What I would like is the following output line only when the sort returns no results
No results for this report


I saw a post on the forum where I could do it by adding a second job step to conditionally execute using NULLOUT in the first step.
Is there a way to accomplish this all in one sort step?

Thanks

Re: Empty Report Line

PostPosted: Sat Jul 14, 2012 1:11 am
by dick scherrer
Hello and welcome to the forum,

Is there some reaslon the trailer with a COUNT of zero would not work?

Re: Empty Report Line

PostPosted: Sat Jul 14, 2012 1:31 am
by Dean
No. It works just fine. It's just that the shop "standard" is different and I am trying to mimic those standards to develop a DFSort "template" for simple reporting where creating a new COBOL program is overkill. I am very new to DFsort but have been very impressed with it's capabilities. So far I have been able to get it to do exactly what I want in every case....except this one.

Re: Empty Report Line

PostPosted: Sat Jul 14, 2012 4:44 am
by skolusu
Dean wrote:However, this will appear at the bottom of every report. What I would like is the following output line only when the sort returns no results


DFSORT does not have any built-in features to dynamically adjust the Headerx/trailerx. Your best bet would be

Dean wrote:I saw a post on the forum where I could do it by adding a second job step to conditionally execute using NULLOUT in the first step.

Re: Empty Report Line

PostPosted: Mon Jul 16, 2012 10:59 pm
by Dean
Thanks Guys,

One last idea. is there a way to test for the Return code in the OUTREC uisng an IFTHEN to build a custom line like

OUTREC IFTHEN=(WHEN=(RC4, BUILD=('NO RECORDS SELECTED')

Re: Empty Report Line

PostPosted: Mon Jul 16, 2012 11:46 pm
by skolusu
Dean wrote:Thanks Guys,

One last idea. is there a way to test for the Return code in the OUTREC uisng an IFTHEN to build a custom line like

OUTREC IFTHEN=(WHEN=(RC4, BUILD=('NO RECORDS SELECTED')


Dean,

You canNOT check the RC using IFTHEN. INREC/OUTREC all work on data records. So if your file is empty, the inrec/outrec statements will not be executed.

You can create a file with the text "$$$$ NO RESULTS FOR THIS REPORT " and concatenate it to the input file. And now we can control what text we want to write out based on the input.

ex: Assuming you have 3 records you run the job as shown below
//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
----+----1----+----2----+----3----+----4----+----5----+----
RECORD - 1                                                 
RECORD - 2                                                 
RECORD - 3                                                 
//         DD *                                           
$$$$                    NO RESULTS FOR THIS REPORT         
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFOUTLEN=80,                                       
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,3,ZD,START=0)),     
  IFTHEN=(WHEN=(1,4,CH,EQ,C'$$$$',AND,81,3,ZD,GT,0),       
  OVERLAY=(24X,C'NUMBER OF RECORDS SELECTED: ',81,3)),     
  IFTHEN=(WHEN=(1,4,CH,EQ,C'$$$$',AND,81,3,ZD,EQ,0),       
  OVERLAY=(24X))                                           
//*


The output of this is :
RECORD - 1                                               
RECORD - 2                                               
RECORD - 3                                               
                        NUMBER OF RECORDS SELECTED: 003   


Now lets say your input file is empty , then run the same jcl and the output would be
                        NO RESULTS FOR THIS REPORT 


This is the job that produces that output (check how SORTIN DD * does not have any records.
//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
//         DD *                                         
$$$$                    NO RESULTS FOR THIS REPORT     
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INREC IFOUTLEN=80,                                   
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,3,ZD,START=0)), 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'$$$$',AND,81,3,ZD,GT,0),   
  OVERLAY=(24X,C'NUMBER OF RECORDS SELECTED: ',81,3)), 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'$$$$',AND,81,3,ZD,EQ,0),   
  OVERLAY=(24X))                                       
//*

Re: Empty Report Line

PostPosted: Fri Jul 20, 2012 9:04 pm
by Dean
Thanks for the great solution!! I have been adapting it to my shop's standards.

I am having one last issue I hope you can help me with.

I an getting
ICE043A 3 INVALID DATA SET ATTRIBUTES: SORTIN   LRECL   - REASON CODE IS 05
The reason being that my input data LRECL is 155 and I am using the technique you demonstrated
//        DD *                             
$$$$           NO RESULTS FOR THIS REPORT
which I beleieve is defaulting to a length of 80. I like the inline code technique for clarity. Is there any way to resolve this besides alocatting a dataset with an LRECL of 155 an putting the "no results" record in that??

Thanks Again

Re: Empty Report Line

PostPosted: Fri Jul 20, 2012 10:08 pm
by skolusu
Dean wrote:Thanks for the great solution!! I have been adapting it to my shop's standards.

I am having one last issue I hope you can help me with.

I an getting
ICE043A 3 INVALID DATA SET ATTRIBUTES: SORTIN   LRECL   - REASON CODE IS 05
The reason being that my input data LRECL is 155 and I am using the technique you demonstrated
//        DD *                             
$$$$           NO RESULTS FOR THIS REPORT
which I beleieve is defaulting to a length of 80. I like the inline code technique for clarity. Is there any way to resolve this besides alocatting a dataset with an LRECL of 155 an putting the "no results" record in that??

Thanks Again


Dean,

If you had looked up the ICE043A message and the reason code you would have found the problem. Here is the explanation of the error.

http://publibz.boulder.ibm.com/cgi-bin/ ... m60/2.2.42?

I showed you an example using LRECL=80 , but looks like your input is off different length. You canNOT concatenate different LRECL FB files. So you need to create the trailer record file similar to your input file.

Re: Empty Report Line

PostPosted: Fri Jul 20, 2012 10:47 pm
by Dean
Thanks.

Maybe my my question wasn't clear and I guess it is more of a JCl question than a DFSORT question. I did look up the error code and I understand that the unequal lengths is the issue. My question is, is there a way to keep the inline DD* for the trailer message and still force it to be LRECL 155 rather than allocating a file just to hold that one line.
I guess the answer is no.

I'm not a real JCL pro either. My experience has been in VSAM/CICS

Re: Empty Report Line

PostPosted: Fri Jul 20, 2012 11:06 pm
by skolusu
Dean wrote:Thanks.

Maybe my my question wasn't clear and I guess it is more of a JCl question than a DFSORT question. I did look up the error code and I understand that the unequal lengths is the issue. My question is, is there a way to keep the inline DD* for the trailer message and still force it to be LRECL 155 rather than allocating a file just to hold that one line.
I guess the answer is no.

I'm not a real JCL pro either. My experience has been in VSAM/CICS


Dean,

Unfortunately you cannot use instream data to force a large lrecl. however you can use the following step to write the trailer record.
//STEP0100 EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                                 
//INP      DD DISP=SHR,DSN=Your input file in question
//EMT      DD *                                         
$$$$                    NO RESULTS FOR THIS REPORT     
//SYSIN    DD *                                         
  PRINT INFILE(INP) CHARACTER COUNT(1)                 
  IF LASTCC = 4 THEN DO                                 
     REPRO INFILE(EMT) OUTFILE(INP)                     
//*