An easy way to create SQL reports longer than 132 bytes
search cancel

An easy way to create SQL reports longer than 132 bytes

book

Article ID: 29503

calendar_today

Updated On:

Products

Datacom DATACOM - AD

Issue/Introduction

How to create SQL report longer than 132 bytes. 

Resolution

When running the DBSQLPR program to create SQL reports, the default width of the report is 132 bytes (plus one for carriage control). There is an easy way to change the width to a maximum of 1500 bytes by changing the program option PRTWIDTH to the desired value. However, since most default lengths for JES SYSOUT records is 133 bytes, you need to add a parameter to the STDOUT DD Statement to set the LRECL accordingly.

If you use the same JCL for a number of reports, and do not want to always use the maximum value, here are two easy ways to make sure you change both the program option PRTWIDTH and the JCL DD statement parameter LRECL together.

For both of these examples, you will enter the desired record length in the JCL “SET” statement (we are using “RECL” in our examples), and use that symbolic for the LRECL attribute of the STDOUT DD Statement.

In this first example, you will pass a PARM into the DBSQLPR program: PRTWIDTH=&RECL, and that will be added to any other options passed in the OPTIONS DD Statement.

Example #1:

//*                                                                      
// SET RECL=1500                                                         
//* - - - - - -C- - - - - - - - - - - - - - - - - - - - - - - - - - -7-+ 
//SQLEXEC  EXEC PGM=DBSQLPR,PARM='INPUTWIDTH=70,PRTWIDTH=&RECL'
//STEPLIB  DD  DISP=SHR,DSN=CA.DATACOM.CUSLIB               
//         DD  DISP=SHR,DSN=CA.DATACOM.CABDLOAD 
//SYSOUT   DD  SYSOUT=*             
//SYSUDUMP DD  SYSOUT=*                         
//SYSPRINT DD  SYSOUT=*                          
//STDERR   DD  SYSOUT=*                         
//STDOUT   DD  SYSOUT=*,LRECL=&RECL  
//OPTIONS  DD  *
AUTHID=SYSUSR                                                             
ROWLIMIT=9999999                                                         
NOTYPE                                                                   
/*                                                                        
//SYSIN    DD  *                                                         
*$WIDE                                                                   
SELECT * FROM ...;                                           
/*                                                                       

In this second example, you can take advantage of the new capabilities of z/OS 2.1, which allows for symbolics to be contained within instream data (DD *). In this example, we will again use the RECL Symbolic variable, and it can be accessed by instream data after defining the EXPORT list of symbolics. As before, the STDOUT DD Statement has the LRECL attribute. Then, instead of entering the PRTWIDTH option through the PARM= statement, we will add it to the other options in the OPTIONS instream data, and will give it a value of &RECL. Because the OPTIONS DD Statement has “SYMBOLS=(JCLONLY…” coded,  it will use the RECL value defined earlier in the JCL SET statement. Using “SYMBOLS=(…,$SYM) means that the values of each line in the input will be shown before and after any substitution in a DD statement called $SYM.

 Example #2:

//*                                                                      
// EXPORT SYMLIST=(RECL)                                                 
// SET RECL=1500                                                          
//* - - - - - -C- - - - - - - - - - - - - - - - - - - - - - - - - - -7-+ 
//SQLEXEC  EXEC PGM=DBSQLPR
//STEPLIB  DD  DISP=SHR,DSN=CA.DATACOM.CUSLIB               
//         DD  DISP=SHR,DSN=CA.DATACOM.CABDLOAD 
//SYSOUT   DD  SYSOUT=*             
//SYSUDUMP DD  SYSOUT=*                        
//SYSPRINT DD  SYSOUT=*                          
//STDERR   DD  SYSOUT=*                         
//STDOUT   DD  SYSOUT=*,LRECL=&RECL  
//$SYM     DD  SYSOUT=*                                                   
//OPTIONS  DD  *,SYMBOLS=(JCLONLY,$SYM)                                   
PRTWIDTH=&RECL                                                           
AUTHID=SYSUSR                                                             
ROWLIMIT=9999999                                                         
INPUTWIDTH=70                                                           
NOTYPE                                                                    
/*                                                                       
//SYSIN    DD  *                                                         
*$WIDE                                                                   
SELECT * FROM ...;                                          
/*                                                                                                                                             

Here is some of what the $SYM file contains after the job runs – note that the RECL symbolic has changed the instream data:

OPTIONS  : RECORD 1 BEFORE SUBSTITUTION 
OPTIONS  : PRTWIDTH=&RECL               
OPTIONS  : RECORD 1 AFTER SUBSTITUTION  
OPTIONS  : PRTWIDTH=1500                
OPTIONS  : RECORD 2 BEFORE SUBSTITUTION 
. . .
OPTIONS  : RECORD 5 BEFORE SUBSTITUTION 
OPTIONS  : NOTYPE                       
OPTIONS  : RECORD 5 AFTER SUBSTITUTION  
OPTIONS  : NOTYPE