Using CA Earl or Earl Service, how can I output the report data in comma-delimited format? Do you have a sample?

Document ID : KB000011346
Last Modified Date : 14/02/2018
Show Technical Document Details
Question:

Using CA Earl or Earl Service, rather than produce a report, how can I output the report data in comma-delimited format?

Answer:

Here is an example of a technique which will create a comma-delimited output file rather than producing a report.

Using the sample AIRPORTS file, a description of which may be found in the SAMPJCL member EARLSAMP, create a new request, using SET statements to assign input values and commas to the output fields of the new comma-delimited data file. Then specify the CA Earl PUT command to write the data to the output flat file.

//EARL     EXEC PGM=EARL                                                     
... your Earl JCL ...                                                                     
//PUTOUT   DD DISP=(NEW,CATLG,DELETE),                                       
//         DSN=your.common.delimited.output.file,                                       
//         SPACE=...,UNIT=...,VOL=SER=vvvvv,                       
//         DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)                                 
//SYSIN    DD * 
AIRPORTS:FILE EARLGET  RECORD=57                                             
    DEF A_NAME      1-18 X 'NAME OF' 'AIRPORT'                               
    DEF A_CITY     20-35 X 'CITY'                                            
    DEF A_COUNTRY  40-43 X 'COUNTRY' 'ABBREVIATION'                          
    DEF A_PASS     50-57 N 'NUMBER OF' 'PASSENGERS'                          
PUTOUT: FILE OUTPUT RECORD=80             
    DEF O_NAME      1-18 X                
    DEF O_C1       19-19 X                
    DEF O_CITY     20-35 X                
    DEF O_C2       36-36 X                
    DEF O_COUNTRY  37-40 X                
    DEF O_C3       41-41 X                
    DEF O_PASS     42-49 N                
    DEF O_REST     50-80 X                
                                            
START:                                                                    
GET AIRPORTS                                                              
IF AIRPORTS = 'E'                                                         
   GOTO EOJ                                                               
ENDIF                                                                     
SET O_NAME     = A_NAME                                                   
SET O_C1       = ','                                                      
SET O_CITY     = A_CITY                                                   
SET O_C2       = ','                                                      
SET O_COUNTRY  = A_COUNTRY                                                
SET O_PASS     = A_PASS                                                   
SET O_C3       = ','                                                      
PUT PUTOUT                                                                
GOTO START                                                                
END                                                                       
/*

The above request will result with the following messages in the Earl SYSPRINT...

FILE NAME                   RECORDS READ    RECORDS WRITTEN               
AIRPORTS                              50                  0               
PUTOUT                                 0                 50               
**** END OF PROCESSING PHASE                                              
**         0 HITFILE RECORDS WRITTEN                                      
                                                                          
CALR802E NO DATA SELECTED FOR ANY REPORT

And, the resulting flat file will contain...

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ATLANTA           ,ATLANTA         ,US  ,47649470                               
BALTIMORE INTL.   ,BALTIMORE       ,US  , 9146286                               
BOSTON            ,BOSTON          ,US  ,23283047                               
CHARLES DE GAULLE ,PARIS           ,FR  ,16040641                               
CHARLOTTE INTL.   ,CHARLOTTE       ,US  ,12978582                               
COPENHAGEN        ,COPENHAGEN      ,DEN ,10622814                               
...etc...

You will need to customize your CA Earl report using the PUT/SET technique as shown above.