Trading Networks 10.7 | 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 Entire Document at One Time
 
Processing the Entire Document at One Time
 
Performing Envelope Validation and Compliance Checks
The following diagram shows sample code that includes the basic logic you would apply to process an entire inbound EDI document at one time. This processing shows how to map information from the EDI document to an internal-format document and then send the document to an internal application, for example, a back-end system. For 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
Invoke the wm.b2b.edi:envelopeProcess service to process the envelopes in the inbound EDI document. This service consumes the entire EDI document and converts all of its envelope header segments, including transaction set header segments, into an IData object named Values. That is:
*For an ANSI X12 document, it creates an IData object of the ISA/IEA, GS/GE and ST/SE headers/trailers.
*For a UN/EDIFACT document, it creates an IData object of the UNB/UNZ, UNG/UNE, and UNH/UNT headers/trailers.
After the header segments are converted to the Values IData object, your service can access and act on data elements within the header segments of the EDI document.
The contents of the transaction sets remain unparsed. How the service handles the transaction set contents is based on whether the document is considered large. For more information, see Handling Large Documents When Using Trading Networks .
*For documents not considered large, the service leaves the transaction set contents in String format. The service assigns the transaction set body to the unDefData parameter that is in the Values IData object under the transaction set header. For example, for an ANSI X12 document, the content would be in the elements Values/ISA/GS/ST/unDefData. The parameter name unDefData refers to the fact that the content has not yet been processed.
*For documents considered large, the service writes the transaction set contents to hard disk drive storage. When data is written to the hard disk drive storage, it is assigned a reference ID that is used to access the data. The service assigns the reference ID for the transaction set contents to the element _RID_, which is in the Values IData object under the transaction set header. For example, for a UN/EDIFACT document that contains group envelopes, the reference ID would be in the elements Values/UNB/UNG/UNH/_RID_. For more information about how Module for EDI handles large documents, see Handling Large Documents When Using Trading Networks .
Additionally, the envelopeProcess service can perform an optional check for basic compliance on the interchange envelope. You specify whether to perform the compliance check by setting two optional input parameter for the envelopeProcess service. For more information about the compliance check, see Performing Envelope Validation and Compliance Checks.
2
Add your own logic to handle errors that might result from executing the wm.b2b.edi:envelopeProcess service, for example errors with the compliance check.
3
Loop through the interchange envelope headers. The data for the interchange headers is within the Values IData object. The sample code shows the loop over Values/<InterchangeHeader>. If you are processing:
*ANSI X12 document, the interchange headers are in Values/ISA.
*UN/EDIFACT document, the interchange headers are in Values/UNB.
4
Loop through the group envelope headers. The data for the group headers is within the Values IData object. The sample code shows the loop over Values/<InterchangeHeader>/GroupHeader. If you are processing:
*ANSI X12 document, the group headers are in Values/ISA/GS.
*UN/EDIFACT document and the document has group headers, the group headers are in Values/UNB/UNG.
If you are processing an UN/EDIFACT document that might not contain group headers, your processing will need to be slightly different. For sample code, see the sampleServices:UNEDIFACTToValues in the WmEDIsamples package, which is located under Code Samples in the Technical community area of the Empower Product Support website at https://empower.softwareag.com. The samples in this folder have been certified by Software AG.
5
Loop through the transaction set headers. The data for the transaction set headers is within the Values IData object. The sample code above shows the loop over Values/<InterchangeHeader>/GroupHeader/<Transaction>. If you are processing:
*ANSI X12 document, the transaction set headers are in Values/ISA/GS/ST.
*UN/EDIFACT document, the transaction set headers are in Values/UNB/UNG/UNH.
The remaining steps specify processing to perform for the content of each transaction.
Flow Operation
Description
6
Invoke the wm.b2b.edi.util:getEDIstring service to convert the transaction set header and trailer back to a String and concatenate them with the transaction set contents. The resulting transaction set with header and trailer can be either a String or InputStream.
You need to have an element that contains the entire transaction set, including header and trailer, before you can invoke the wm.b2b.edi:convertToValues service. This is because the convertToValues service uses a flat file schema for the EDI transaction set that includes the transaction set header and trailers. If you input data without the header and trailer, the convertToValues service will return errors.
7
Invoke the wm.b2b.edi:convertToValues service to:
* Convert the EDI transaction set that is in either String or InputStream format to an IData object
*Validate the transaction EDI structure
The inputs to the convertToValues service include the output from the wm.b2b.edi.util:getEDIstring service (the String or InputStream) and the flat file schema for the EDI document. The convertToValues service uses the flat file schema to both determine how to parse the transaction set into an IData object and to validate its structure.
8
Map data from the EDI transaction sets to the internal-format document.
Now that the content of the transaction set is an IData object, you can access the data in the transaction set content to map it to an IData object for 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 wm.b2b.edi: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.