How to write CA Earl Report Requests: Using TAG and SELECT to Control Printing of Entire Lines
See KDs - TEC291378, TEC323377, TEC265260, TEC265262. TEC274567, TEC291378, TEC323376, TEC345252, TEC372281, TEC360551
In a previous KD "Writing Advantage CA-Earl Report Requests - Using TAG and SELECT to Produce an Array of Values", we learned how to use TAG and SELECT to control printing at the field level. In this KD we will discuss Writing CA Earl Report Requests. We will demonstrate the use of SELECT statements and TAG values to control printing of entire lines. This technique is useful for creating reports where some elements of the report page need to be varied based on the input data or processing flow.
Please review KD TEC34252 as a base to begin with on reporting on passenger volume, we will create a set of invoices for each airport in North America. The invoices are to include an assessment amount based on passenger volume and country. The assessment rate is $50.00 per million passengers for the United States of America, $45.00 per million passengers for Canada and $40.00 per million passengers for Mexico. The Presort section of our request has been expanded to include a DECODE and several IF tests to assign the correct state and/or province for each city on file and to calculate the correct assessment value for each country.
Since we will be building the report output using a series of PRINT statements, the REPORT statement specifies the EXCLUDE option to suppress the automatic generation of headings and column titles. In the SELECT statements below, we assign the TAG value of 'A' to represent those airports in the United States of America, the TAG value of 'B' to those airports in Canada and the TAG value of 'C' to airports in Mexico.
SELECT 'A' CTRLBREAK = 0 AND A_COUNTRY = 'US ' SELECT 'B' CTRLBREAK = 0 AND A_COUNTRY = 'CAN ' SELECT 'C' CTRLBREAK = 0 AND A_COUNTRY = 'ME ' |
This will result in a TAG value of A, B or C being assigned to each record in the file. The inclusion of the condition CTRLBREAK = 0 ensures that only detail records are used. Lines in the invoice that are to be printed for each country are defined by the IFTAG ABC;PRINT statements. Lines that are unique for a country will specify only the single value in the IFTAG parameter.
IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @28 ' North American Airport Authority' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @28 'Annual Passenger Volume Assessment' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @28 ' Statement for 2004' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @14 'Airport Name: ' 0 A_NAME IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @14 ' City: ' 0 A_CITY IFTAG ABC;PRINT @1 ' ' IFTAG AC;PRINT @14 ' State: ' 0 STATE IFTAG B;PRINT @14 ' Province: ' 0 STATE IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @14 ' Country: ' 0 COUNTRY IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @14 'Total Number of Passengers in 2004: ' 7 A_PASS IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG A;PRINT @14 ' Rate per million passengers: $50.00' IFTAG B;PRINT @14 ' Rate per million passengers: $45.00' IFTAG C;PRINT @14 ' Rate per million passengers: $40.00' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG A;PRINT @14 ' Annual Assessment: ' 0 ASSESS_USA IFTAG B;PRINT @14 ' Annual Assessment: ' 0 ASSESS_CAN IFTAG C;PRINT @14 ' Annual Assessment: ' 0 ASSESS_MEX IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @1 ' ' IFTAG ABC;PRINT @14 'Note - This is not a bill. You will receive a separate invoice.' |
Please refer to the CA Earl User Guide section 5.1 Format and Contents for more information about placing fields at specific locations within the print line and section 5.5 Grouping Data for a detailed explanation of SELECT and TAG processing. Please refer to the CA Earl Reference Guide for specific information on coding an CA Earl program.