Subscribe to keep this site alive! Under new management but as always, still 100% FREE. Anyone with the IBM i is a friend of ours.
Our first map will come from this page. This is how the transmission file looks when it is dumped into an 80-byte file. When we separate the segments (letters in bold) in each line by looking for the segment separator (~ in red), it would look like the one in the lower portion:
Now, to create your first map: from the Mapper>File>New>New Format>
give the translation format a name.
the specifications say this is a Purchase (850), use the drop down to pick.
for now, let us pick X12 4010, we will explain later.
We are creating the document, hence pick "Sending outbound data to a trading partner".
We do not have any UFD - "Create new definition".
The New User File Definition (UFD) dialogue box will appear, give the UFD a name.
There was a time in the past that Trusted Link needs to use IBMi;s user spaces for faster processinh. Since we have better CPU's now, we will be using "Expanded Files". The difference between Files and Expanded Files is that Files has a 1024 record length limit.
We are using the Direct by Key Access Method.
Once [OK] is clicked on the New User File Definition dialogue box, a blank map will appear with ST and BEG segments CHECKED by default.
There will be check boxes on the left of all segments and loop headers. To pick them, click on the check [ ] box to signify that you are selecting them. For this particular document, ST, BEG, PO1 and SE will be pre-checked because these are the minimum required segments of the standard. Loop headers will automatically be checked if you pick a segment within the loop header and loop end. The first segment of a loop is called the loop starter and it can only occur once.
It is recommended that you pick the segments on the onset of the creation of the map to avoid confusion later if you add them as you map. Starting from the top (ST), going down to SE. Seen here, there is another set of N1.....N9. Picking the wrong one may achieve a different result.
When this is done, to view only the "selected, ones, from the menu bar: 1) View> 2) Document> 3) Selected. As early as this point, we would like to introduce Mapping Sequence, Loop/Segment Attributes, Element Attributes and Field Attributes. To show these, from the menu bar: 4) Tools> 5) User Preferences> 6) check all display options.
The letter on the left of the Element/Segment/Loop Name is the optionality of the element, segment or loop: M=mandatory; O=optional; C=conditional. For segments, the number beside it represents the mapping sequence number. This is vital for debugging. While the one beside the element is the element id. This is needed when you setup internal conversion tables and element code lists.
The third check box is for the UFD field attributes: field type, length of the field and decimal positions.
When mapping from the source field or work field will have an extra step/prompt. Unlike the "Show Mapping - Insert" method as described in the previous section, we will need to tell the mapper when to execute the mapping instruction.
For this module, we were given three files by the guys from our ERP system:
The mapping instructions are pretty obvious or constants except for the Purchase Order Number (BEG 3.0) which is the concatenation of Document Type (DOCTYP) and the last 4 digits of Serial (SERIAL). And the BY address on the N1 Loop is a record fetched using the CUSTID from the @@ADDRESS file with ATYPE=BY.
Mapping constants is easy, 1) right click on the element you want to map> 2) Define Mapping> 3)enter the constant in Source 1> 4) click [Apply]. When you click [Apply] instead of [OK], you will be brought to the next dialog box. This is best if you are mapping within the same segment. To take advantage of the drop down for valid constants, 5 & 6) pick the target first because this dictates what will be the valid values in the drop down in 7 & 8.
When attempting to substring a value from a Zoned Decimal field from the UFD. the starting position from the source is disabled. I just need to map the last 4 digits of this field. Is there a way to do this without involving a work field?
Yes, you could simply change the data type of the field:> 1) right click on the UFD field you want to change,> 2) Properties> 3) click on the Data Type drop down and pick "Alphanumeric"> 4> click OK and proceed with the mapping. To backout what you just did, you can always> 5) click on [Restore Defaults].
Warning: This change is in the UFD which will affect other maps connected to it.
To mitigate the risk, we just need to create a new User File Field: 6) right click on the record format where the source field is located> 7) "Add User File Field", give it a name and description> 8) set "Start position" and "Length in bytes", based on the relative position of the length of the original field and your chosen substring strategy (If you plan to do a straight map without substring-ing the source, then start position will be 9+3=12 and length in bytes 7-3=4).
Before we talk about conditioning and mapping for this exercise, we need to bring in the source record format. The source file (record format) will contain several records for a given document number (the primary key).
There is a field called ATYPE (Address Type) that would indication the relation of the address record to the document. "BY" is one of the values of which we can grab the record details and map to the document.
Now we have the file/record format in, let us start by Defining the Condition of the ATYPE field. Conditions can only be defined on work fields and the source field (for outgoing) or the element (for incoming). 1) right click on the field> 2) "Define Conditions"> 3) when the "Define Conditions" dialog box appears,> 4) when you click on the [Add] button, a condition is created/added in the "Condition Set" box. Continue until all of the conditions are done/added> 5) depending on how you want to handle errors, but it is advisable to check the "Include OTHER in the condition set" box to avoid the error when an undefined condition is found.
Once the condition set is established, this will be available in the "You are mapping for condition" drop down.> 6) select the appropriate condition> 7) by clicking on-line from the dropdown. From this time, any mapping will be for this condition until a new condition is picked from the dropdown or a new Tools>Select Conditions for Mapping or Tools>Clear Conditions for mapping is selected - as shown in the next section.
An equivalent of picking from the "you are mapping for conditions" drop down is by> 1) Tools> 2) "Select conditions for mapping"> 3) pick the conditions> 4> [Add]. This is handy for compound conditions too.
Adjacent elements/fields
Same pattern relative positioning
From one to many
AMT 2.0 is the accumulation of the extended amount of quantity and price. We have quantity and price, hence we need two work fields. The extended amount (EXTAMT):> 1) [double click] on "Work Fields" which will open up the "Define Work Field" dialogue box.> 2) fill in the details of the extended amount work field.> 3) Click on [Apply] - this will open up a new "Define Work Field" for the accumulation of the extended amount (TOTAMT)> 4) fill in the details of the accumulation of the extended amount work field.> 5) Click [OK].
Now we have the work fields setup, let us start mapping these two variables. On detail time:> 1) right click on the PO1 Loop Header,> 2) click on "Show Mapping", the Show Mapping - PO1 Loop dialogue box pop ups> 3) position the cursor on the mapping instruction where you want to insert the next instruction> 4) click [Insert], the Define Mapping dialog box pop ups.> by default "Map to" is pre-selected, 5) use drop down to change to "Multiply" (this is done to open up Source 2, otherwise its drop down will not be enabled)> 7) pick QTY field> 8) use the drop down to pick the OPRICE field> 9) click on the Target drop down.