Skip to main content

Handling X12 Interchanges

As X12 documents are sent within Interchanges you need to choose how Ensemble should handle incoming documents. Especially if you need to access documents at the Group or Transaction Set level. This chapter describes different scenarios for handling X12 Interchanges

X12 Batch Handling

Batch Handling settings determine how Ensemble sends and receives documents. The choices you make here affect how your Business Processes should be configured.

Receiving Batch Documents

X12 business services have the Batch Handling configuration setting, which determines how to process incoming batch documents. The options are:

  • Whole Batch — Do not process child documents individually; accumulate and send the whole batch as one composite document.

  • Single-Session Batch — Forward all documents in the Interchange as part of a single session, including final parent document objects containing batch and group header and trailer segments.

  • Multi-Session Batch — Forward each document in the Interchange in its own session, followed by final parent document objects containing the batch and group header and trailer segments.

  • Individual — Forward each child document in the batch in its own session; do not forward parent batch document objects.

Note:

If you select Whole Batch any transformations of individual Transaction Sets will have to account for the Interchange and Group levels. See Configuring Business Processes for Whole Batch below.

Sending Batch Documents

On the outgoing side, X12 File and FTP business operations have the Auto Batch Parent Segs configuration setting. When Auto Batch Parent Segs is True (the default), while outputting a message that has a batch parent, the business operation outputs the batch headers first, then the child documents, then follows up with the batch trailers when triggered by the final batch header message or by a file name change. When Auto Batch Parent Segs is False the business operation outputs child documents, but does not output the batch headers and trailers.

Batch Modes

The combination of Batch Handling and Auto Batch Parent Segs enables the following modes of operation for X12 batch documents:

Batch Handling Auto Batch Parent Segs Results
Whole Batch (any) Business service sends only the parent document; all child documents are referenced to it but not sent individually. Operation outputs entire batch at one time when it receives the parent document.

Single-Session

or

Multi-Session

True Service sends each child document as it receives and parses it, followed by the parent document when all children have been sent. The business operation outputs parent headers when it receives the first child document, then finishes up with trailers when it receives the parent document object. Trailer segments automatically contain the correct child count values.

Single-Session

or

Multi-Session

False This results in double output: the business operation sends out each child document individually, followed by the parent document containing each child document (again).
Individual False Business service forwards each child document in the batch in its own session and does not forward objects representing the batch headers and trailers. On the outgoing side, the business operation does the same.

Configuring Business Processes for Whole Batch

If you choose to have the business service process incoming X12 documents in Whole Batch mode you will need to configure the business process accordingly.

For examples of X12 Productions that use the Whole Batch setting please view the Demo.X12.SorterDTL.ByGroup.Production and Demo.X12SorterDTL.ByInterchange.Production demo productions. To view them, ensure that you are within the ENSDEMO namespace and navigate to the Production List page. Select the production you wish to view and click open. These demos incorporate all of the configuration settings listed below.

Routing Rules for Whole Batch

To properly route documents in Whole Batch mode, set the routing rule to accept Interchanges. Send to the relevant data transformation if necessary.

Create a New Routing Rule

  1. Ensure that you are in the proper namespace.

  2. Navigate to the Ensemble Rule Editor page (Ensemble > Build > Business Rules).

  3. Click New.

  4. Follow the instructions in Adding an X12 Routing Rule.

Edit the Constraint

  1. Double click on the constraint rule item.

  2. Set the Source to your business service.

  3. Set the Message Class to EnsLib.EDI.X12.Document.

  4. Set the Schema Category as appropriate for your production.

  5. Choose Interchange from the Document Name selection.

For more information, see Using the Rule Constraint Editor.

Define the Condition

Choose any conditional statement relevant to your production. If you always want the action to be applied, click on the condition rule item and type “1”.

Add a Send Action

  1. Click on the when rule item.

  2. Click Send to add a send action.

  3. Double click on the transform rule item and select the appropriate data transformation.

  4. Double click on the target rule item and select the appropriate business operation from your production.

For more information, see Selecting the Transformation and Target of a Send Action.

Data Transformations for Whole Batch

To transform whole batch documents at the Group or Transaction Set level, you must iterate through each group and each transaction set within each group. To do so, follow the steps below.

Create a New Data Transformation

  1. Ensure that you are in the proper namespace.

  2. Navigate to the Data Transformation Editor page (Ensemble > Build > Data Transformations).

  3. Click New.

  4. Follow the instructions in Adding an X12 Data Transformation.

Create an Array of Groups

  1. Create a new set action by clicking Add Action and selecting set.

  2. Input a variable name into the Property field, such as ArrayOfGroups.

  3. Input ##class(%Library.VariableName).%New() into the Value field, where VariableName is the value you provided in the Property field.

  4. Input "" into the Key field.

Loop Over the Groups in Each Interchange

  1. Create a new for each action by clicking Add Action and selecting for each.

  2. Input source.{GroupDocsRef} into the Property field.

  3. Input Group into the Key field.

Loop Over the Transaction Sets in Each Group

  1. Create a new for each action by clicking Add Action and selecting for each.

  2. Be sure the for each is between the for each and endeach blocks of the previous action.

  3. Input Group.{TransactionSetDocsRef} into the Property field.

  4. Input TSIn into the Key field.

Add any additional actions necessary. For more information, see Developing DTL Transformations.

Configuring Business Processes for Other Batch Settings

If you choose to have the business service process incoming X12 documents in Whole Batch mode you will need to configure the business process accordingly.

For an example of an X12 production that use Single Batch Setting please view the Demo.X12.SorterProcess demo production. To view it, ensure that you are within the ENSDEMO namespace and navigate to the Production List page. Select the production you wish to view and click open. This demo incorporates all of the configuration settings listed below.

Routing Rules for Other Batch Settings

To properly route documents in Single Session, Multi Session, or Individual mode, create a routing rule set with a unique routing rule for each type of X12 document the production will encounter.

To create new rules within the rule set:

  1. Click on ruleSet

  2. Click rule to add a rule

  3. Follow the instructions set in Routing Rules for Whole Batch

  4. When editing the constraint, be sure to set the Document Name to the appropriate X12 document type.

  5. When adding a data transformation, be sure to use a transformation written for the appropriate X12 document type.

Data Transformations for Other Batch Settings

To transform X12 documents within productions with Single Session, Multi Session, or Individual mode you must create a separate data transformation for each type of X12 document the production will encounter. For more information, see Developing DTL Transformations.

FeedbackOpens in a new tab