# 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fb4KW0g1RpVVzLCds60tr%2F0.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FHB8ykVT5wMk3i32VuMEQ%2F1.png?alt=media" 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FjK2pZpIsIYQRedXgPfl4%2F2.gif?alt=media)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FqXa6yKEo0WLK382rdRag%2F3.png?alt=media)

A configuration window will open, as shown below.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F2adixEUWUPaTXr3nEtf2%2F4.png?alt=media)

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.

{% hint style="info" %}
**Note:** You can create your trade partner profile by navigating to *New > File > EDI Trade Partner Profile*
{% endhint %}

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FWId79PbTgnm0o5eAUtd6%2F5.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FPISIRGUgLt9QUnuujK9Y%2F6.png?alt=media" 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FHiqTywi9vYJeBd19WIgp%2F7.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FRc3RxhMFb46cN14PG7m5%2F8.png?alt=media)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FJT4O607064ueoAZY1CGR%2F9.png?alt=media)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F7DthTc69au7XXYpzGeD8%2F10.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F8QP8jq16IYcdV6RXXxS6%2F11.gif?alt=media)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F0KxRkliFcCNtYEGupn7a%2F12.png?alt=media)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fcmorj5MMmADATFXkib8J%2F13.png?alt=media)

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