Writing CA-Earl Report Requests: Creating Multiple Reports: Sample and instructions
It would be advisable to review other KDs - TEC265260, TEC265262
One of the most powerful features of CA-Earl is the ability to produce multiple reports from a single pass of the input data. In this article, the previous KDs will be referenced and we will see demonstrate how easily multiple reports are created.
Each report section requires at least a REPORT statement and a PRINT statement. SELECT and CONTROL statements are optional, as are Postsort commands (i.e., those that contain the (D) or (T) modifier). The report section statements must appear in the following order:
Using our standard AIRPORTS file, provided in the install package.let's build our multiple reports request by starting with the request from the previous KDs, we will combine that request with a modified version of the request created in the TEC265262. In modifying the original request from that article, we have expanded it to include all of the possible countries and assigned the country and continent names using a DECODE statement rather than the series of IF...THEN...ENDIF statements used originally. Lastly, we will include the request created in the POSTSORT Processing KD.
When combining the source requests, it is only necessary to include the additional GSA, Presort and Postsort statements required for each additional report. Since the file definition for each of these requests is identical, it only needs to be coded once. Notice that the first report consists solely of a REPORT and PRINT statement. This is the simplest report definition. The second report uses a SELECT statement to limit the records included in the report, while the third and final report does not contain any selection at all, but does contain Postsort processing statements. Here then is the final report request:
NOTE ======================================================= NOTE This is the OPTIONS section - used to override the NOTE default options specified at install time NOTE ======================================================= OPTION LIST ON OPTION OMIT ALL BLANK LINES OPTION PRINTER=80 NOTE ======================================================= NOTE This is the File Definitions section - the file and NOTE fields to be used are identified here" NOTE ======================================================= AIRPORTS: FILE DISK RECORD=80 DEF A_NAME 1-18 X 'NAME OF' 'AIRPORT' DEF A_CITY 20-35 X 'CITY' DEF A_COUNTRY 40-43 X 'COUNTRY' 'CODE' DEF A_PASS 50-57 N 'NUMBER OF' 'PASSENGERS' PIC 'ZZ,ZZZ,ZZ9' NOTE ======================================================= NOTE This is the GSA section - comparable to the COBOL NOTE working-storage section NOTE ======================================================= DEF MILLIONS_PASS (N 4.2) = NONE 'PASSENGERS' '(IN MILLIONS)' PIC 'Z,ZZ9.99' DEF COUNTRY (X 24) = NONE DEF CONTINENT (X 13) = NONE ! DEF TOT_PASS (N 15.0) = 0 DEF PCT_PASS (N 3.2) = 0 '% OF TOTAL' 'PASSENGERS' PIC 'ZZ9.99' DEF AVG_PASS (N 10.0) = 0 'AVERAGE PASSENGER' 'VOLUME/AIRPORT' PIC 'Z,ZZZ,ZZZ,ZZ9' DEF COUNT (N 3.0) = 0 DEF TOT_COUNT (N 3.0) = 0 '# ' 'AIRPORTS' ! NOTE ======================================================= NOTE This is the PRESORT section - where you can specify NOTE operations to be carried out before the data is NOTE copied to the hit file and sorted. NOTE ======================================================= SET MILLIONS_PASS = A_PASS / 1000000 ! DECODE A_COUNTRY INTO COUNTRY 'AU ' = 'Australia ' 'DEN ' = 'Denmark ' 'FRG ' = 'Germany ' 'FR ' = 'France ' 'IT ' = 'Italy ' 'UK ' = 'United Kingdom ' 'NE ' = 'Netherlands ' 'SW ' = 'Switzerland ' 'CAN ' = 'Canada ' 'JA ' = 'Japan ' 'ME ' = 'Mexico ' 'SI ' = 'Singapore ' 'US ' = 'United States of America' ELSE '*COUNTRY NOT IN TABLE*' ! DECODE A_COUNTRY INTO CONTINENT 'AU ' = 'Australia ' 'DEN ' = 'Europe ' 'FRG ' = 'Europe ' 'FR ' = 'Europe ' 'IT ' = 'Europe ' 'UK ' = 'Europe ' 'NE ' = 'Europe ' 'SW ' = 'Europe ' 'CAN ' = 'North America' 'JA ' = 'Asia ' 'ME ' = 'North America' 'SI ' = 'Asia ' 'US ' = 'North America' ELSE '*OMIT*' ! SET TOT_PASS = A_PASS + TOT_PASS SET COUNT = 1 ! NOTE ======================================================= NOTE This is the Report section - one or more reports NOTE may be defined here. NOTE ======================================================= ! ! First report... ! REPORT 'World''s 50 Busiest Airports' PRINT A_NAME A_CITY A_COUNTRY A_PASS ! ! Second report... ! REPORT 'World''s 50 Busiest Airports' TITLE 'In Descending Passenger Volume Order for' 1 CONTINENT SELECT CONTINENT NOT = '*OMIT*' CONTROL (CONTINENT) SKIP COUNTRY A_CITY MILLIONS_PASS DOWN PRINT COUNTRY A_CITY A_NAME MILLIONS_PASS ! ! Third report... ! REPORT 'World''s 50 Busiest Airports' TITLE 'In Descending Passenger Volume Order by Country' CONTROL (A_COUNTRY) A_PASS DOWN ! NOTE ======================================================= NOTE This is the POSTSORT section - where you can specify NOTE operations to be carried out for detail or total NOTE processing after the data has been sorted. NOTE ======================================================= ! SET(D) PCT_PASS = A_PASS / &TOT_PASS * 100 ! SET(T) TOT_COUNT = COUNT SET(T) AVG_PASS = A_PASS / COUNT ! PRINT A_COUNTRY TOT_COUNT AVG_PASS A_NAME A_PASS PCT_PASS ! ! ======================================================= ! This is the required END statement ! ======================================================= END ! This is the last statement of the request
For more information about writing Advantage CA-Earl requests, refer to the publications, CA-Earl User Guide and CA-Earl Reference Guide.