Writing CA Earl Report Requests: Correcting Runtime Errors and sample process
search cancel

Writing CA Earl Report Requests: Correcting Runtime Errors and sample process

book

Article ID: 11528

calendar_today

Updated On:

Products

Earl

Issue/Introduction

In other knowledge documents we've explored various techniques used to develop report requests.



Writing CA Earl Report Requests: Correcting Runtime Errors and sample process

Environment

Release: EARL..00200-6.1-Earl
Component:

Resolution

See KDs - TEC291378, TEC323377, TEC265260, TEC265262. TEC274567, TEC291378, TEC323376, TEC345252, TEC372281

In other knowledge documents we've explored various techniques used to develop report requests. If you've had the chance to write your own requests, you already know that it sometimes takes several attempts before your request produces the desired results. Your request may produce the desired results on the first run, or you may find that the results are not at all what you expected. The report may contain only part of the desired data or your calculations may need to be revised. Whatever the situation, runtime errors are some of the most difficult to resolve.

We will begin by modifying the request from "Writing CA Earl Report Requests - Creating Multiple Reports." For this example we are only interested in the third report, so we have removed the unused code from the original request.

Instead of using a DECODE statement for the country name, we are going to access a file which contains the country abbreviations and full names. This file includes only those countries that have more than one airport in the list of the top 50 busiest airports. For demonstration purposes this file is defined as a card input file, but it could just as easily be a tape or disk data set. After reviewing the modified report, we decided that the last column, % OF TOTAL PASSENGERS, is not really useful, so we removed it. We also decided to generate a total number of passengers for each country in the report. Scroll to the bottom of the output and you will see the following messages:

****END OF EARL COMPILATION.    79 LINES READ. NO SYNTAX ERROR(S) 
DETECTED. NO WARNINGS GIVEN.
 ****    HITFILE KEY,DATA = 11,  66 STACK SIZE =   3
 ****   115 TEXT CARDS CREATED -
 FILE NAME                   RECORDS READ    RECORDS WRITTEN
 AIRPORTS                              41                  0
 CARDIN                                 5                  0
 **** END OF PROCESSING PHASE
 **         0 HITFILE RECORDS WRITTEN -     0.01 SECS
 CALR802E NO DATA SELECTED FOR ANY REPORT

Even though there were no syntax errors and we have read records from both the AIRPORTS file and the CARDIN file, none of the records were selected for the report. Let's review the code which was added to process the CARDIN and AIRPORTS files.

CARDIN:    FILE CARD
           DEF CONTINENT         1-14  X       'Continent'
           DEF COUNTRY_CODE     15-18  X
           DEF COUNTRY          19-42  X       'Country'
.
.
.
GOTO LOOPA (PROCESS_SW = 'Y')     ! still processing previous country
!
GET CARDIN                        ! get a new country record
GOTO EOJ (CARDIN = 'E')           ! done when EOF
!
RESET AIRPORTS                    ! start at beginning of AIRPORTS
LOOPA:
  SET PROCESS_SW = ' '
  SET COUNT = 0
  GET AIRPORTS
  GOTO START (AIRPORTS = 'E')     ! check for another country record
  GOTO PROCESS (COUNTRY_CODE = A_COUNTRY)
  GOTO LOOPA
!
PROCESS:
SET COUNT = 1                     ! count record
GOTO START                        ! select record

You can see in the section labeled PROCESS: that we want this record to be selected. After reviewing the list of predefined labels in section 1.6 of the publication Advantage CA-Earl Reference Guide we realize that this section should issue a GOTO TEST statement, not GOTO START.  Better, but still not correct. Since this time we did get some report output, we can add the file indicators CARDIN and AIRPORTS to our PRINT statement to see what their values are for each record. We also add the PROCESS_SW indicator to the PRINT statement, since it is critical to our processing flow. The modified PRINT statement looks like this:

      PRINT CARDIN AIRPORTS PROCESS_SW
            COUNTRY TOT_COUNT AVG_PASS A_NAME (A_PASS)

Review your report output with the diagnostic fields. Notice that the value for PROCESS_SW is always blank. Reviewing our code again, we can see that we neglected to set this flag field to any other value. We need to include the following statement in the PROCESS: section of our request:

      SET PROCESS_SW = 'Y'              ! flag match found

 

 

Additional Information

Please refer to Chapter 7 of the CA Earl User Guide for more information about debugging your CA Earl program. The CA Earl Reference Guide provides specific information on coding an CA Earl program, including information about predefined variables and labels.