Code the Data Area DEFINE statements after the Communications Area DEFINE statements when working with a CA Datacom/DB table. Otherwise, code the Data Area DEFINE statements after the INPUT statement.
The primary function of the DEFINE statements in the Data Area is to provide space for the accessed data associated with the element, but column headings can also be assigned to the data. The accessed data is moved to the Data Area beginning with position 301.
Code the five DEFINE statements that make up the Data Area in the sample program as follows:
DEFINE PERSONEL-NUMBER 301-305 X ' ID ' 'NUMBER' DEFINE PERSONEL-NAME 306-329 X 'EMPLOYEE NAME' DEFINE PERSONEL-CITY 354-368 X 'CITY' DEFINE PERSONEL-STATE 369-370 X DEFINE PERSONEL-ZIP-CODE 371-375 X 'ZIP' 'CODE'
In these statements, five fields of the element ADEMP have names assigned to them. The fields are the PERSONEL-NUMBER field, PERSONEL-NAME field, PERSONEL-CITY field, PERSONEL-STATE field and PERSONEL-ZIP-CODE field. Space has been allocated for the data in each field. The space allocated for the fields reflects their relative starting and ending positions in the element.
Each line of coding also specifies the type of data the named fields are to contain, and some lines specify column headings for the named fields. The following is the general DEFINE command format for coding the Data Area:
►►─ DEFINE ─ fieldname ─ start-end ─ X ─┬─────────────┬───────────────────────►◄ └─ 'heading' ─┘
In the first DEFINE statement in the Data Area, PERSONEL-NUMBER is the user-supplied name of the field where the five-character employee identification number is to be moved.
DEFINE PERSONEL-NUMBER 301-305 X ' ID ' 'NUMBER' DEFINE PERSONEL-NAME 306-329 X 'EMPLOYEE NAME' DEFINE PERSONEL-CITY 354-368 X 'CITY' DEFINE PERSONEL-STATE 369-370 X DEFINE PERSONEL-ZIP-CODE 371-375 X 'ZIP' 'CODE'
Since the employee ID number occupies the first five positions of the element, the start-end parameter is 301—305, followed by X, indicating the field is to contain alphanumeric data.
Beginning with this DEFINE statement, an optional heading is coded for some element fields. In the previous (highlighted) line of coding, the field named PERSONEL-NUMBER has been given the column heading ID NUMBER.
Notice in this statement how the placement of the blanks and apostrophes around ID resulted in the centering of ID over NUMBER in the printed report. Remember to place apostrophes correctly if the command format specifies them.
The first DEFINE statement in the Data Area of the sample tells the Reporting Facility that the employee ID numbers are in the field named PERSONEL-NUMBER. PERSONEL-NUMBER is five characters long, contains alphanumeric data and has the column heading ID NUMBER.
In the second DEFINE statement, PERSONEL-NAME is the user-supplied name of the field where you move the 24-character employee name.
DEFINE PERSONEL-NUMBER 301-305 X ' ID ' 'NUMBER' DEFINE PERSONEL-NAME 306-329 X 'EMPLOYEE NAME' DEFINE PERSONEL-CITY 354-368 X 'CITY' DEFINE PERSONEL-STATE 369-370 X DEFINE PERSONEL-ZIP-CODE 371-375 X 'ZIP' 'CODE'
Since the employee name field is 24 characters long and occupies positions 6—29 of the element, the start-end parameter is 306-329, followed by X, indicating the field contains alphanumeric data. The field PERSONEL-NAME field has the heading EMPLOYEE NAME.
In the third DEFINE statement, PERSONEL-CITY is the user-supplied name of the field indicating the employee's city of residence. CITY is the designated heading name.
DEFINE PERSONEL-NUMBER 301-305 X ' ID ' 'NUMBER' DEFINE PERSONEL-NAME 306-329 X 'EMPLOYEE NAME' DEFINE PERSONEL-CITY 354-368 X 'CITY' DEFINE PERSONEL-STATE 369-370 X DEFINE PERSONEL-ZIP-CODE 371-375 X 'ZIP' 'CODE'
Since the city field is 15 characters long and occupies positions 54—68 of the element, the start-end parameter is 354-368, followed by X, indicating the field is to contain alphanumeric data.
Positions 30—53 of the element are not defined. You must assume these positions contain data that is not relevant to processing this report. However, these positions must be included in the RECORD EQ xxx parameter when calculating the total length of the element. In the fourth DEFINE statement, PERSONEL-STATE is the user-supplied name of the field indicating employee's state of residence.
DEFINE PERSONEL-NUMBER 301-305 X ' ID ' 'NUMBER' DEFINE PERSONEL-NAME 306-329 X 'EMPLOYEE NAME' DEFINE PERSONEL-CITY 354-368 X 'CITY' DEFINE PERSONEL-STATE 369-370 X DEFINE PERSONEL-ZIP-CODE 371-375 X 'ZIP' 'CODE'
Since the state field is two characters long, the start-end parameter is 369-370, followed by X, indicating that the field contains alphanumeric data.
For this field, no column heading was designated in the DEFINE statement and it will not be printed in the report. It is used only to control which records appear in the report. For more information, see PRINT Command.
In the fifth DEFINE statement, PERSONEL-ZIP-CODE is the user-supplied name of the field indicating the employee's zip code.
DEFINE PERSONEL-NUMBER 301-305 X ' ID ' 'NUMBER' DEFINE PERSONEL-NAME 306-329 X 'EMPLOYEE NAME' DEFINE PERSONEL-CITY 354-368 X 'CITY' DEFINE PERSONEL-STATE 369-370 X DEFINE PERSONEL-ZIP-CODE 371-375 X 'ZIP' 'CODE'
Since the zip code field is five characters long, the start-end parameter is 371—375, followed by X, indicating the field is to contain alphanumeric data. The field named PERSONEL-ZIP-CODE has been given the heading ZIP CODE.
With the previous explanation of the Communications and Data Areas, it is now possible to code the RECORD EQ xxx parameter in the input statement. Recall that the RECORD EQ xxx parameter is used to determine the total length (in characters) of all the elements to be read from this database table, plus 300 characters for the Communications Area. Since the fields that make up the element ADEMP occupy a total of 75 positions, RECORD EQ 375.
The total length of the element includes positions 30—53 of the element even though the data in those positions is not included in the processing.
|
Copyright © 2014 CA.
All rights reserved.
|
|