B2B Integration 10.5 | Administering and Monitoring B2B Transactions | webMethods Module for EDI | Before Creating the Service to Process EDI Documents | Logic to Include in the Service to Process EDI Documents | Processing the Document Iteratively, Segment by Segment | Logic for the Service to Process the Document Iteratively
 
Logic for the Service to Process the Document Iteratively
This section describes the sample code for processing an inbound EDI document iteratively. The steps for processing show how to map information from the line item segments of an ANSI X12 810 document into an internal-format document, and then send the document to an internal application, for example, a back-end system. For more information about all of the built-in services that the sample uses, see webMethods Module for EDI Built-In Services Reference .
Flow operation
Description
1
Repeatedly invoke the wm.b2b.edi:convertToValues service until your service has processed the entire EDI document. When you pass the iterator input parameter as true to the convertToValues service, the output contains the object ediObject,, which is used to keep track of the input data segments. When the entire EDI document has been processed, EDIObject becomes null.
2
In the outer REPEAT loop, invoke the convertToValues service to:
* Convert a segment or group of segments to an IData object
*Validate the EDI structure
The inputs to the convertToValues service include the String or InputStream that represents the EDI document and the customized flat file schema for the EDI document. The convertToValues service uses the flat file schema to determine how many segments to read. It returns the object ediObject, which keeps track of its location in the EDI document. This object is input to subsequent invocations of the convertToValues service to ensure the service continues where it left off at the last invocation.
3
Add BRANCH flow operations for each type of segment you expect the convertToValues service to return.
For example, the first BRANCH under the call to the convertToValues service checks for an ISA element in the returned IData object, EDIValues. If EDIValues/ISA exists and is not null, the flow service executes the logic under the BRANCH on ‘EDIVAlues/ISA' flow operation.
4
Prepare to invoke the convertToValues service against the unparsed sections of the document. An unparsed section is a section for which the EDI flat file schema for the EDI document did not have flat file structure and for which you created a separate flat file schema.
*Save information about where you are in processing the EDI document. The MAP flow operation saves the values of the ediObject and EDIFFSchema that the convertToValues service in the outer REPEAT loop is using.
*Map the fully-qualified name of the flat file schema you created for the repeating section of the document into the EDIFFSchema parameter. Make sure the value of ediObject is null.
5
Repeatedly invoke the convertToValues service in this inner REPEAT loop to process an unparsed section of the document.
6
Invoke the wm.b2b.edi.util:EDIconcat service to prepare the unparsed section for the call to the convertToValues service.
The EDIconcat service automatically gets its input from either the unDefData or _RID_ elements that the first pass of the convertToValues service left in the pipeline for the unparsed sections. You can use the EDIconcat service to add a header, a trailer, or both a header and trailer to the unparsed data, if needed.
7
In the inner REPEAT loop, invoke the convertToValues service to:
* Convert the unparsed section to an IData object
*Validate the EDI structure
Pass the output from the EDIconcat service (output parameter) to the edidata input parameter of the convertToValues service. In a previous flow operation, you set the value of the EDIFFSchema input parameter to the fully-qualified name of the flat file schema to use for this unparsed section of the EDI document.
8
Map data from the unparsed section into the internal-format document. Depending on the complexity of your mapping requirements, you might need to add more logic than a MAP flow operation, or create a separate service to perform the mapping.
9
Invoke the convertToString service to convert the internal-format document from an IData object to String format.
The inputs to the convertToString service include the IData object that contains the data for your internal-format document and the flat file schema for the internal-format document. The convertToString service uses the flat file schema to determine how to form the internal-format document. Alternatively, the convertToString service can accept an IS document type to define the structure of the internal-format document.
10
Add your own logic or invoke a service that you create to send the internal-format document to your internal application, for example, a back-end system.
11
Restore the values of the ediObject and EDIFFSchema parameters, which you saved in a previous flow operation, in preparation for invoking the convertToValues service in the outer REPEAT loop.
Note: If you want to perform the interchange (or transmission) envelope validation and the compliance check, you need to add logic to your service to do so. For more information, see Performing Envelope Validation and Compliance Checks.

Copyright © 2016- 2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.