To convert a business object to an EDI document, the EDI data
handler loops through the attributes of the top-level business
object definition. It processes the attributes recursively, in the
order in which they appear in the top-level business object,
writing attribute values as the elements of the EDI document.
The EDI data handler processes business objects into an EDI
document as follows:
- The data handler initializes itself by setting the composite, element,
segment, and repeat separators
based on the configuration information in the child meta-object. If
no value is provided for one of these configuration options, the
data handler uses hard-coded defaults, as Table 40 and Table 43 show.
Table 40. Default
values for element and segment separators
Precedence step |
Element
separator |
Segment
separator |
1 |
Obtain the
value of the corresponding meta-object attribute. |
SEPARATOR_ELEMENT
|
SEPARATOR_SEGMENT
|
2 |
If the
associated meta-object attribute is not set, use a hard-coded
default. |
plus sign
(+) |
single quote
(') |
- The data handler examines the application-specific information
in the top-level business object definition to determine if there
are any child meta-objects (those whose names are listed in the
cw_mo_ tag of the business object application-specific
information). The data handler does not include these
attributes in the EDI document.
- The data handler loops through the remaining attributes in the
top-level business object definition. Based on the cardinality of
each attribute, the data handler determines what part of the EDI
document the attribute represents. For more information, see
Determining the EDI data associated with the
attribute.
- Once the data handler identifies the associated EDI data, it
can take the appropriate steps to write the attribute data to the
EDI document:
- If an attribute represents a segment, the data handler checks
whether it is null. If the business object is null, the data
handler skips the attribute. If the business object is not
null, the data handler performs the segment-processing steps. For
more information, see Processing a
segment.
- For each child business object in a segment that represents a
composite, the data handler loops through the attributes (all of
which should be String), and takes the
composite-processing steps For more information, see Processing a composite.
- The data handler writes the total number of segments that it
has written to this document into the "number of segments" field of
the document. The data handler determines the position of this
field from the seg_count tag in the ISA attribute
of the child meta-object. This field is often located in the
SE segment. For information on setting the
seg_count tag, see Obtaining positional
information.
- When the data handler completes the conversion, it returns the
serialized data to the caller. The data handler returns the data as
a string that contains the EDI document.
To convert a business object to an EDI document, the EDI data
handler must correctly insert separators into the EDI document. The
data handler uses the attributes in the child meta-object to
determine the values to assign these separators. If no value is
provided for one of these attributes, the data handler uses
hard-coded defaults for the separator.
Table 41 shows the EDI separators
with their corresponding meta-object attributes and hard-coded
default values.
Table 41. Default
values for EDI separators
EDI
separator |
Separator
attribute in child meta-object |
Hard-coded
default |
Element
separator |
SEPARATOR_ELEMENT
|
plus sign
(+) |
Segment
separator |
SEPARATOR_SEGMENT
|
single quote
(') |
Composite
separator |
SEPARATOR_COMPOSIT
|
colon
(:) |
Repeat
separator (EDIFACT documents only) |
SEPARATOR_REPEAT
|
caret
(^) |
Attention:
EDI documents that follow the X.12 standard: For
the data handler to properly convert business objects to an EDI
document, the values of the separator attributes in the child
meta-object must match those in the ISA segment of
the EDI document. The EDI data handler does not read data in
the ISA segment to determine document separators.
EDI documents that follow the EDIFACT standard: For the
data handler to properly convert business objects to an EDI
document, the values of the separator attributes in the child
meta-object must be set to the default values, as defined in
Table 41. The separator attributes in
the default child meta-object ( MO_DataHandler_DefaultEDIConfig) contain values
valid for the X.12 standard. Make sure you reset these attribute
default values to the values defined in Table 41.
The structure of the business objects that hold EDI is
determined by the EDI document specification. (For information on
how to create this business object structure, see Creating business object definitions
for EDI documents.) The EDI data handler uses the cardinality
of the attribute to determine what part of the EDI document this
attribute represents. Based on this cardinality, the data handler
takes the following actions:
If an attribute represents a segment, the actions that the data
handler takes depend on whether the attribute is null:
- If the attribute value is null, the data handler skips the
attribute; it does not include it in the EDI document.
- If the attribute value is not null, the data handler performs
the following processing steps:
- Parse the business object application-specific information for
the segment name, a tag of the form:
name=segment_name
- Append the segment separator to the EDI document.
- Append the segment name to the EDI document, insert any escape
characters needed.
- For each child business object (either single-cardinality or
multiple cardinality), the data handler appends the element
separator to the EDI document and processes the child business
object as a composite (see Processing a
composite). For a multiple cardinality attribute, the data
handler processes each child business object in the order it
occurs.
- For each String attribute that is not null, the
data handler appends the element separator and the value of the
attribute, inserting any escape
characters as needed.
For each child business object that represents a composite, the
data handler loops through the attributes (all of which should be
String), and takes the following processing steps:
- Parse the attribute data, adding any necessary escape
characters.
- Append the attribute value with any escape characters to the EDI document.
- Append the composite separator to the document.
