Mapping Services is capable of maintaining MDOs according to a number of local form rules. By default it assumes all components are variable length items consisting of a tag (or key), a length, and the data itself. The following Mapping Services directives can be placed in the source to control the local form of data (k and l are integers in the range 0 to 4, where k is the length of the key, and l is the length of the length bytes):
--< KL0(k,l) >--tag, length, then data, length is of data only. --< KL1(k,l) >--tag, length, then data, length is of length bytes + data. --< KL2(k,l) >--tag, length, then data, length is of tag +length + data. --< LK0(l,k) >--length, tag, then data, length is of data only. --< LK1(l,k) >--length, tag, then data, length is of tag bytes + data. --< LK2(l,k) >--length, tag, then data, length is of length + tag + data.
Such rules apply to structured components only. It is important to note that the rule applying to a structured component describes the manner in which its embedded components are managed and not the structure itself. The way in which the structure itself is managed depends upon the rule applying to its parent structure.
These directives can be used before any ASN.1 type assignment statement to set the compiler default for components encountered in the source module after that point, for example:
--< KL0(2,2) >--
CustomerOrder ::= CHOICE {
customer CustomerDetail
order OrderDetail }
In this example the components customer and order carry the KL0(2,2) encoding rule such that their embedded components (if any) are managed according to that rule.
This directive can also be applied to an individual component without changing the compiler default, for example:
--< KL0(2,2) >-
CustomerOrder ::= CHOICE {
customer CustomerDetail
order --< KL0(4,4) >--OrderDetail }
In this example the customer component carries the compiler default KL0(2,2) encoding rule, while the order component carries the KL0(4,4) rule.
Note that in both the above examples, the customer and order components must be managed in the same manner. This is described by the encoding rule carried in the component which is of type CustomerOrder (not shown here).
Mapping Services can be used to map existing data structures and to accommodate this it can also manage components that do not have explicit length and tags in the data. Such data is considered fixed and fixed components can only be specified within a SEQUENCE or SEQUENCE OF type definition, for example:
CreateDetails ::= SEQUENCE {
userid --< FIX(8) >-- GraphicString,
date --< FIX(8) >-- GraphicString,
--YY/MM/DD--
time --< FIX(8) >-- GraphicString}
--HH:MM:SS--
In this example the userid component occupies the first 8 bytes of the data, the date component the next 8 bytes, and the time component the last 8 bytes. Although tags are not used within the data, each component can still be defined with a tag value, or the compiler generates one.
--< FIX(x,y) >--
In this example, the component is of length x, and starts at offset y within its enclosing structure. If y (offset) is not specified, the offset is defaulted to the end of the preceding component, or 0 (zero) if there is no preceding component.
| Copyright © 2008 CA. All rights reserved. |
|