Creating a global MECDataTranslator variable

  1. Double-click a mapping to open it in the Mapper Editor.
  2. On the Mapping Console tab, click the Variables and Constants tab.
  3. Right-click the table and select Create Variable.
  4. Under the Name column, specify a descriptive name for this variable, for example "dt".
  5. In the drop-down arrow for Data Type, select MECDataTranslator.

    If MECDataTranslator is not already listed, add data types in Type Definitions.

  6. Optionally, select Window > Preferences > Mapper > Type Definitions.

    Click Add and specify a name, for example MECDataTranslator.

    Click OK to close the Type Definitions dialog.

  7. Specify the value, use null.
  8. Specify a brief description.

This variable is accessible within all Java functions in the mapping.

The Java code is scanned when you publish or republish a mapping. MECDataTranslator restrictions apply.

This pattern illustrates how to use MECDataTranslator in Java user functions:

Important

Java code for translations must use this pattern to avoid errors when you generate and publish the mapping. Hard coded strings must be hard coded strings in the parameter list.


// 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");

For ION, where the application context is not used and logical ID is always "Generic", use this example.

For IEC, you can use any application context given the hard coded four levels logical ID, tenant ID, accounting entity ID, and location ID. In IEC you can, for example, get tenant ID and accounting entity ID from an incoming BOD.