Converting business objects to EDI documents

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:

  1. 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 44 and Table 47 show.

    Table 44. 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 (')
  2. 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. For more information about the cw_mo_ tag, see Implementing conversion from a business object.
  3. 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.
  4. Once the data handler identifies the associated EDI data, it can take the appropriate steps to write the attribute data to the EDI document:
  5. 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.
  6. 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.

Determining document separators to insert

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 45 shows the EDI separators with their corresponding meta-object attributes and hard-coded default values.

Table 45. 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 45. 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 45.

Determining the EDI data associated with the attribute

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:

Processing a segment

If an attribute represents a segment, the actions that the data handler takes depend on whether the attribute is null:

Processing a composite

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:

Copyright IBM Corp. 1997, 2003