Example for "dt"

Take a closer look at this Java code example previously used in Using MECDataTranslator.


// Instantiate a MECDataTranslator object, used in the whole mapping
String logicalId = "Generic";
String tenantId = null;
String accountingEntityId = null;
String locationId = null;
dt = new MECDataTranslator(MyMapping, logicalId, tenantId, accountingEntityId, locationId, "EDIFACT", "D01B", "ORDERS", 'O');

// Perform the actual translation (from the variable iCustPartyID to the variable e01_3039)
e01_3039 = dt.translate("g002/NAD", "3039", iCustPartyID, "3035", "BY", "Customer party ID");

Instantiate

The first six lines instantiates the global MECDataTranslator variable dt. This code can be placed in its own Java function within the mapping and must be placed before any data translation is performed. You must only instantiate a global MECDataTranslator variable once within a mapping.

ION does not support application context for data translations, you must follow these guidelines:

  • logical ID is hard coded to Generic.

  • tenant ID, accounting entity ID, and location ID are set to null.

If other application context is used, the translation data given in ION Desk will fail. For EC, you can set the full application context in any way appropriate for the message.

In the constructor’s parameter list, you must specify information as hard coded strings, as given by this example:

Field Value
Message type EDIFACT
Message version D01B
Message type or document ORDERS
Message direction is specified by a hard coded character.

In this example, the character O is used for outbound message.

For inbound messages, use the character I.

Translate

After the MECDataTranslator variable dt is instantiated run the actual data translation. Use the translate method for both inbound and outbound messages.

In the translate method's parameter list, you must specify this information as hard coded strings:

Field Value
Parent path g002/NAD
Value path 3039
Conditional path 3035
Conditional value BY
Description Customer party ID

In this example, the customer party ID from the inbound BOD is given by the Java function’s input parameter iCustPartyID. The translated value is assigned to the Java function’s output parameter e01_3039 that should be mapped to the output EDI document.

In a regular mapping, there are numerous data translations in several Java functions. Because the MECDataTranslator variable dt is global and is instantiated first in the mapping you only need to call the translate method to perform the actual data translations.

To check whether a data translation was performed, use the boolean MECDataTranslator method isTranslated() after the call to the translate method.