Now we need to create the source and target structures – the translator will use them for parsing the input and generating the output documents.
I’ll show you how to describe the source structure and you’ll be able to create the target yourself. Let’s start:
- Select the “Document” element on the left (source) side.
- In the top menu select Model->Insert Item->Below
- On the “DMI Attribute” tab change the following parameters:
- Name = LIN
- Access Type = LineFeedDelimRecord. So, now it’s not a group but a record.
- Min/Max = 1/100. They are the minimum and maximum of repetitions.
- Match Value = LIN. It’s a very important parameter – the translator uses it to recognize the LIN records in the source document.
- Now we need to move the LIN record under the root group “Document”. To do it, select the record and click this icon:
You should get the following:
If you accidentally shifted an incorrect element, you can move it back by clicking on opposite button (“move left”). But be careful – sometimes you cam break your entire structure if you move your elements back and forth.
- So, we’ve created our record LIN. Now it’s time to add the fields to it. Select (activate) the record and select Model->Insert Item->Below in the top menu.
- As you remember (I hope) the first element of the format A (source) is the Record ID (LIN). However we’ve already described this field as the “Match Value” parameter (Match Value = LIN, see above). That’s enough – when the translator meets the string starting with “LIN***” it will proceed to the next field (Line Item ID).
- Thus, the first field of the LIN record will be the Line Item ID. Change the name of the new element you’ve just added to LineItemID (without spaces!)
- Now change:
- Access Type to AlphaNumericFld (element type = field, type = AN)
- Occurence min/max to 1/1
- Size min/max to 12/12. Why 12/12 insted of 1/12 ? Because we use a fixed length format, i.e. fields will always have the same length. If the field’s data has the length of 5 instead of 12, it will be populated with spaces (for AN fields) or “0” (for numeric fields) up to the max length.
- Shift the field under the LIN record with that familiar icon:
- Save the model (it’s not a bad idea to save your model from time to time 🙂 ).
- Add the rest of the fields. Select LineItemID, click Model->Insert Item->Below and so on. For the numeric fields (Quantity and Unit Price) choose the Access Type of AlphaNumericFld, not Numeric. For the source document we won’t check the datatype of these fields. For the Expiration Date field select the Access Type of DateFld and format of YYYYMMDD:
So, we’ve just described our source structure (format A).
Now do the same for the target structure. You’ll see that you cannot use the same names 🙂 Hint: you can change the elements’ names.