Minimum element substatement
Minimal ELEMENT substatements are illustrated next:
02 claim-date.
03 claim-year picture 99.
03 claim-month picture 99.
03 claim-day picture 99.
A valid element description also requires usage information. In the above example, the schema compiler defaults to assign USAGE IS DISPLAY to each element.
Redefining the same element storage area
In the following example, one record type holds data relating to four different types of facilities and, accordingly, requires four definitions of the same storage area:
modify record name is facility.
02 fc-id pic x(4).
02 fc-lunchroom.
03 fc-l1-length pic 99.
03 fc-l1-width pic 99.
03 fc-l1-tables pic 99.
03 fc-l1-seats pic 9(4).
03 fc-l1-pots pic 99.
02 fc-lounge redefines fc-lunchroom.
03 fc-l2-chairs pic 99.
03 fc-l2-ashtrays pic 99.
03 fc-l2-tables pic 99.
03 filler pic 9(6).
02 fc-emp-library redefines fc-lunchroom.
03 fc-l3-desks pic 99.
03 fc-l3-tables pic 99.
03 fc-l3-bookcases pic 99.
03 fc-l3-mag-racks pic 99.
03 filler pic 9(4).
02 fc-hallway redefines fc-lunchroom.
03 fc-h-length pic 99.
03 fc-h-width pic 99.
03 filler pic 9(8).
Base-element-name cannot contain OCCURS clause
In the following example, any element except EXP-SKILL-DATE-N can contain an OCCURS clause:
05 exp-skill-date.
10 exp-skill-date-n.
15 exp-skill-year-n pic 99.
15 exp-skill-month-n pic 99.
15 exp-skill-day-n pic 99.
10 exp-skill-date-x redefines exp-skill-date-n.
15 exp-skill-year-x pic 99.
15 exp-skill-month-x pic 99.
15 exp-skill-day-x pic 99.
Group elements have implied pictures
In this example, group elements, COV-SELECT-DATE and COV-TERMIN-DATE have implied pictures of X(6). Group elements have implied pictures of X(n), where n equals the total number of bytes required by all subordinate elements.
modify record name is coverage.
02 cov-select-date.
02 cov-select-year pic 99.
02 cov-select-month pic 99.
02 cov-select-day pic 99.
02 cov-termin-date.
02 cov-termin-year pic 99.
02 cov-termin-month pic 99.
02 cov-termin-day pic 99.
02 cov-type pic x.
02 cov-insplan-code pic xxx.
Assigning condition values to level-88 elements
These two examples show different ways of assigning condition values for the same record definition:
modify record name is structure.
02 struct-code pic xx.
88 president value 'a1'.
88 sr-vice-president value 'a2'.
88 vice-president value 'a3'.
88 sr-manager value 'b1'.
88 mid-manager value 'b2'.
88 lower-manager value 'b3'.
88 supervisor value 'c1'.
88 senior value 'd1'.
88 regular value 'd2'.
88 trainee value 'd3'.
02 struct-effective-date.
03 struct-effect-year pic 99.
03 struct-effect-month pic 99.
03 struct-effect-day pic 99.
modify record name is structure.
02 struct-code pic xx.
88 president value 'a1'.
88 vice-presidents value ('a2' 'a3').
88 managers value 'b1' thru 'b3'.
88 supervisor value 'c1'.
88 technicians value ('d1' 'd2' 'd3').
02 struct-effective-date.
03 struct-effect-year pic 99.
03 struct-effect-month pic 99.
03 struct-effect-day pic 99.
In a COBOL program using this record description, the following statements have the same meaning:
if president then perform 0500-bigwig. if struct-code = 'a1' then perform 0500-bigwig.
Variable-length record description
The following example describes a variable number of DC-DENTIST-CHARGES elements within the ABRIDGED-DENTAL-CLAIM record type:
modify record name is abridged-dental-claim.
02 dc-dentist-address.
03 dc-dent-street pic x(20).
03 dc-dent-city pic x(15).
03 dc-dent-state pic xx.
03 dc-dent-zip pic x(9).
02 dc-number-of-procedures pic 99 comp.
02 dc-dentist-charges occurs 0 to 10 times
depending on
dc-number-of-procedures.
03 dc-tooth-number pic 99.
03 dc-service-date.
03 dc-serv-year pic 99.
03 dc-serv-month pic 99.
03 dc-serv-day pic 99.
Repeating group items
The following example defines eight occurrences of the DC-CLAIM-DATE element:
02 dc-claim-date occurs 8 times. 03 dc-claim-year pic 99. 03 dc-claim-month pic 99. 03 dc-claim-day pic 99.
The total length of all DC-CLAIM-DATE elements is 8 * (2 + 2 + 2) = 48 bytes. To reference the second DC-CLAIM-DATE element, the programmer can code DC-CLAIM-DATE(2) or DC-CLAIM- DATE(subscript), where subscript is an elementary item that contains the value 2. To reference only the DC-CLAIM-MONTH element of the second DC-CLAIM-DATE element, the programmer can code DC-CLAIM-MONTH(2) or DC-CLAIM-MONTH(subscript).
The previous example can be expanded as follows to include a second level of multiply-occurring elements:
02 dc-claim-date occurs 8 times.
03 dc-claim-year pic 99.
03 dc-claim-month pic 99.
03 dc-claim-day pic 99.
03 dc-claim-time occurs 6 times.
05 dc-claim-hour pic 9.
05 dc-claim-am-or-pm pic xxxx.
The total length of the DC-CLAIM-DATE element now is 8 * ((2 + 2 + 2) + (6 * (1 + 4))) = 288 bytes. To refer to the fourth DC-CLAIM-TIME element subordinate to the second DC-CLAIM-DATE element, the programmer can code DC-CLAIM-TIME(2,4) or DC-CLAIM-TIME(subscript-1, subscript-2), where subscript-1 is an elementary item that contains the value 2 and subscript-2 is an elementary item that contains the value 4.
Indexing a multiply-occurring element
In the following example, the DC-DENTIST-CHARGES element defines an index named DCX:
02 dentist-charges-0405
occurs 0 to 10 times
depending on number-of-procedures-0405
indexed by dcx.
Associating comments with element descriptions
The following example illustrates the use of element comments in the COVERAGE record:
modify record name is coverage.
02 cov-select-date.
02 cov-select-year pic 99.
02 cov-select-month pic 99.
02 cov-select-day pic 99.
02 cov-termin-date.
02 cov-termin-year pic 99.
02 cov-termin-month pic 99.
02 cov-termin-day pic 99.
02 cov-type pic x.
comments 'this is the type assigned to the coverage by
- 'our company''s insurance professionals'.
02 cov-insplan-code pic xxx.
comments 'this is the code assigned to the coverage by
- 'the insurance company'.
|
Copyright © 2014 CA.
All rights reserved.
|
|