# EDI Message Serializer

### Overview

An *EDI Message Serializer* is used to build an EDI Message in the required EDI partner profile before the message is written to a destination. The serializer helps ensure that the message follows the required format specified by the partner.

In this document, we will learn how to use an *EDI Message Serializer* in Astera.

### Video

{% embed url="<https://youtu.be/ohiJvm1Jzek?si=PZ1A5hwcr9E5hiSD>" %}

### Use Case

In this case, we will be building an EDI message using data available in an [*XML/JSON File Source*](https://documentation.astera.com/dataflows/sources/xml-json-file-source).

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/xmVDFBdSwlbXfZmcJbP9/0.png)

This XML source represents the beginning segment of an X12 834 transaction set, providing information about a change in enrollment or benefits for an individual sponsored by a company.&#x20;

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/rqClRGzydi5tTTJ3oKzI/1.png" alt=""><figcaption></figcaption></figure>

We want to convert the hierarchical information, contained in multiple segments, into a single text stream.

To perform this task, we will use the *EDI Message Serializer* object in Astera.

### Using EDI Message Serializer

1. To get the *EDI Message Serializer* object, go to *Toolbox > EDI > EDI Message Serializer* and drag-and-drop the object onto the designer.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/A045juJANhurtvZ8EXkl/2.gif)

2. Right-click on the *EDI Message Serializer* object’s header and select *Properties* from the context menu.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/JQmUSx9gMyOzDIhpmfJY/3.png)

A configuration window will open, as shown below.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/DcqFZXW95OF7kDyDKzd7/4.png)

Let’s look at the properties on this window.

* *Partner Profile ­*– Fetches all outbound maps based on the partner profile provided.
* *Version\** – Allows users to specify the version they want to use to build their message.
* *Message\** – Allows users to specify the type of message they want to send.
* *Show Error Collection* – If selected, an error collection node will be added to the object, containing details of any errors in the message.
* *Pretty Print* – If selected, when the output is previewed, it displays the text of the message in a more readable format for users.
* *Include Envelope* – If selected, the object will include input and output nodes of metadata and control information for the message.
* *Test Indicator* – Allows user to specify any testing/debugging/validation indicator that may be used in the header or control segment of the message.

\* Options shown in this dropdown menu are limited to those defined in the partner profile.

Now, let’s configure the properties based on our use case.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/H4hjhna03Oogp1FvO9bD/5.png)

Click *Next*. The *Layout Modifications* screen will open; here, users can choose to show, flatten, hide, sort, or add formulas to each node of the message.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/QheetyRpKx3cmHbCRb7G/6.png" alt=""><figcaption></figcaption></figure>

Let’s keep the default layout and click *Next*. The *Config Parameters* screen will open; here, we can configure and define a parameter for the *Trade Partner Profile* file.

Use of Parameters eliminates the process of inserting hardcoded values and provides simplification in the deployment of flows. If the parameters are left empty, the default values defined at the *Properties* window are assigned for use.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/8QenRfholoEYy65tlBI5/7.png)

Now, click *OK,* to proceed further.

3. Map the fields of the *XML/JSON File Source* object onto the *EDI Message Serializer* object’s fields.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/4yvJDJqfIB2YtbmL3fy6/8.png)

4. Right-click on the object’s header and select *Preview Output*.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/PPNmeji0qf5pRLAmotKZ/9.png)

You can view the data through the *Data Preview* window.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/L1L0gwcikueZj2yWxb4R/10.png)

Hover over the *Text* field and you will see the serialized EDI message.

To validate and store the serialized outpu&#x74;*,* we must write it to an EDI Destination File.

5. Let’s drag-and-drop an *EDI Destination File* object from the Toolbox and auto-map the metadata fields along with the *Text* field onto it.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/Y7VFe7ldNsNJN6VnLtL2/11.gif)

Let’s configure the *Properties* of the destination object and click *OK.*

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/ZBfFg5KN93rrhhvweo4j/12.png)

The Dataflow is now ready. By running this Dataflow, you can now create an EDI destination file containing the serialized EDI message.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/cYxsSqN803hiFvRUg4Hg/13.png)

This is how an *EDI Message Serializer* object can be used to build an EDI message in Astera.
