Definition Translation [ HP SYSTEM DICTIONARY XL COBOL DEFINITION EXTRACTOR Reference Manual ] MPE/iX 5.0 Documentation
HP SYSTEM DICTIONARY XL COBOL DEFINITION EXTRACTOR Reference Manual
Chapter 5 Definition Translation
Record Layout
In order to generate COBOL definitions from complex System Dictionary
definitions, SDCDE performs some extensive analysis using the SDCDE
options, entity attributes, and associated relationships. These
procedures are described below.
Determination of the Primary Record
If you request COBOL source to be generated from an IMAGE-DATASET,
KSAMFILE, or FILE, SDCDE must determine which record is the primary one
among all records related to the file. The determination of the primary
record affects the source generation process in the following manner:
* If you set the SECONDARY-REC parameter of the OPTIONS command to ON,
SDCDE generates the primary record first, and then generates all
non-primary records with the REDEFINES clause.
* If you set the SECONDARY-REC parameter of the OPTIONS command to OFF,
SDCDE generates only the primary record's definition. SDCDE ignores
all other record definitions.
Although the Core Set contains the primary-record attribute, which
documents whether a record contained in a file is primary or not, SDCDE
cannot always assume that one and only one record is documented as
primary. Therefore, SDCDE uses the following procedure to select the
primary record:
First, all records related to the file through the
contains relationship are collected. Then, their
primary-record attribute value is examined. If only one
record has the attribute set to true, then that record
is chosen as the primary record. If more that one
record has the primary-record attribute set
to true, then the first one (according to the
relationship-position sorting) is treated as the primary
record. If no record has the primary-record attribute
set to true, then the first one (according to the
relationship position sorting) among them is treated as
the primary record.
Determination of Other Primary Entities
Other than the RECORD contains ELEMENT relationship, SDCDE needs to
determine the primary entity in two more occasions:
1. When the ASSIGN clause is generated for a KSAMFILE, the primary
key element must be determined using the KSAMFILE key ELEMENT
relationship.
2. When the source for a FORMFILE is generated, the headform must be
selected using the FORMSFILE contains FORM relationship.
In these occasions, SDCDE uses the same logic as when determining the
primary record, except for the attribute used to determine the primary
entity. For the first case, SDCDE uses the primary-flag attribute, and
for the second, the head-form attribute is examined.
REDEFINES on the Record Level
Once the primary record is determined, SDCDE uses the primary record
definition to generate COBOL source. Then, SDCDE uses secondary record
layouts to generate COBOL source with the REDEFINES clause.
If the primary record is related to other records through the redefines
relationship, i.e., if the primary record is redefined by other records,
then SDCDE uses the related record definition to generate COBOL source
with the REDEFINES clause. This generation takes place regardless of the
value of the SECONDARY-REC parameter of the OPTIONS command.
If SECONDARY-REC = ON, SDCDE uses all non-primary records that are
contained in the file to generate COBOL definitions with the REDEFINES
clause. If a redefining record also has records redefining it, their
definitions are generated in the same way as generation for a primary
record.
If a recursive loop is detected (a record that is directly or indirectly
redefined by itself), then the record generation stops as soon as the
recursion is detected.
RECORD Contains ELEMENT
When generating COBOL source for a record, SDCDE looks for elements that
are related to the record through the contains relationship. All such
elements have the 05 level number associated with them.
The relationship-position attribute of an element determines the order of
elements within a record. The byte-offset attribute determines the
actual byte position within a record. For a further description of the
byte-offset attribute and its effects, see the Forced REDEFINES
discussion in this chapter.
ELEMENT Contains ELEMENT
SDCDE makes a distinction between elements that contain other elements
and elements that do not contain any element. The elements of the first
kind are called compound elements, while the elements of the second kind
are called elementary elements.
When generating COBOL source for an element, SDCDE first searches System
Dictionary for all ELEMENT contains ELEMENT relationships to see if the
element is a compound or elementary element. Since SDCDE does not
generate a PICTURE clause for compound elements, the following attributes
are ignored: display-length, decimal, sign, blank, justify, and
edit-mask. However, the byte-length attribute must be examined because
the total length of all the elements contained in the compound element
must match the length of the compound element. If the sum of all the
elements contained in the compound element is smaller than the compound
element, SDCDE generates a filler. If the sum is greater than the
compound element's byte length, SDCDE issues a warning.
ELEMENT Contains HP-CONDITION-NAME
When generating COBOL definitions for elements, each HP-CONDITION-NAME
that is contained by the current element causes a level-88 definition to
be generated. The value of the hp-condition-value variable attribute,
which is attached to the ELEMENT contains HP-CONDITION-NAME relationship,
determines the VALUE clause for the level-88 definition.
01 EMPLOYEE-STATUS PIC 9.
88 CN-FULL-TIME VALUE 1.
88 CN-PART-TIME VALUE 2.
88 CN-TEMPORARY VALUE 3.
SDCDE does not add quotes to the hp-condition-value attribute when
creating a level 88 definition. If the value the hp-condition-value
attribute contains is a character string, you must store the value in
System Dictionary within quotes.
To specify a character string using SDMAIN, you must specify the
character string within three sets of double quotes. For example, the
SDMAIN command to assign the character string "SECRET" to an attribute
is: PASSWORD = """SECRET""".
NOTE Due to COBOL restrictions, SDCDE issues a warning for any element
whose description includes JUSTIFY, SYNCHRONIZE, or USAGE other
than DISPLAY, when that element's parent contains a level-88
definition. A warning is also issued if no hp-condition-value
attribute is associated with the relationship.
ELEMENT References ELEMENT
If the element type of an element is "*" (back reference), this signifies
that an ELEMENT references ELEMENT relationship should exist and that the
element currently being defined is a compound element containing the
referenced element.
Explicit Redefines
System Dictionary allows the ELEMENT redefines ELEMENTS relationship
between elements. Just as in the record case, the element that redefines
another element produces COBOL source with the REDEFINES clause. This
generation of the REDEFINES clause is referred to as "explicit redefines"
as the relationship is documented explicitly in the dictionary.
Since any redefining element may in turn be redefined, record generation
stops as soon as recursion is detected.
Forced REDEFINES
With records and compound elements, you have the option to use the
byte-offset attribute (of the RECORD contains ELEMENT and ELEMENT
contains ELEMENT relationship types) to specify the byte in the record at
which the element is to start. If the byte offset is set to zero, then
each element starts at the next available byte. If the offset is greater
than the next available byte, then SDCDE generates a filler. If,
however, the offset is smaller than the next available byte, then SDCDE
generates a REDEFINES clause. (This is known as a "forced REDEFINES
clause." ) For example, suppose that a compound element E is made up of
E1 and E2. Then, the byte-offset attribute on the ELEMENT contains
ELEMENT relationship can be used to generate fillers or REDEFINES
clauses. The rules governing the processing of the byte offset are shown
below:
1. If the byte-offset attribute is too big, a filler is created to
occupy the gap. For example, if E1 and E2 have associated PICTURE
clauses X(10) and X(16) respectively, and if the byte-offset on
the E contains E2 relationship is 13, then SDCDE generates the
following source:
01 E
05 E1 PIC X(10).
05 FILLER PIC X(2).
05 E2 PIC X(16).
2. If the byte-offset attribute is too small, SDCDE creates a
REDEFINES clause (called "forced REDEFINES clause" ), so that the
elements are aligned at the correct byte offsets. For example, if
E1 and E2 have associated PICTURE clauses X(20) and X(16)
respectively, and if the byte offset on the E contains E2
relationship is 5, SDCDE generates the following source:
01 E
05 E1 PIC X(20).
05 FILLER REDEFINES E1.
10 FILLER PIC X(4).
10 E2 PIC X(16).
Note that all COBOL records that redefine another record through
the forced REDEFINES clause are named "FILLER" .
3. If there is a conflict between the byte-offset attribute (on the
ELEMENT contains ELEMENT relationship) and the synchronize
attribute on the ELEMENT entity contained in the compound
element), the byte-offset attribute takes precedence. For
example, if E contains E1, and if E1's byte offset is 14 (odd
boundary), no slack byte is created even though the synchronize
attribute of E1 is true.
4. If the byte-offset attribute = 0, the element's byte-offset is
considered the next available word or byte, depending on whether
the synchronize attribute is true or false. For example, if E1
and E2 have PICTURE clauses X(11) and X(10), then SDCDE generates
the following provided the synchronize attribute of E2 is false:
01 E
05 E1 PIC X(11).
05 E2 PIC X(10).
If the synchronize attribute of E2 is true, SDCDE uses a slack
byte to align the synchronized element on a word boundary. SDCDE
generates the following source:
01 E
05 E1 PIC X(11).
05 FILLER PIC X.
05 E2 PIC X(10).
Recursion Handling
When generating COBOL definitions, SDCDE detects two types of recursion
in relationships: direct and indirect. Direct recursion results from an
entity that defines itself with itself, as in the following examples:
1) RECORD1 redefines RECORD1
2) ELEMENT1 redefines ELEMENT1
3) ELEMENT2 contains ELEMENT2
4) ELEMENT3 references ELEMENT3
Indirect recursion results from an entity that defines itself with a
second entity; the second entity uses the first entity as a part of its
definition. See the following examples:
1) RECORD2 redefines RECORD1
RECORD1 redefines RECORD2
2) ELEMENT1 contains ELEMENT2
ELEMENT2 contains ELEMENT3
ELEMENT1 redefines ELEMENT3
If either form of recursion is found, source generation halts before the
second occurrence of the recursive entity, and SDCDE issues a warning
message.
MPE/iX 5.0 Documentation