I’m going to dip back down to another basic mapping concept, only because it’s come up a few times in the past week. I’ll try to do something more complex next time.
When designing a map, there are only a few times when you should create a record without a tag.
Any records that do not have a tag, will read the next line of data into that record, regardless of what it is.
There are some situations with specialty maps, like document extraction maps, where you may want to do this, but in general, it’s not the best of mapping practices.
The biggest offenders of being tagless, are temporary records. It’s easy to forget to add the $$$ in, when you’re testing a quick concept, to see if it works.
If data is not behaving like it should, or you’re seeing data written out in places that you’re not expecting it, chances are you have a tagless record.
Luckily, there are a couple easy ways to determine this, and find the culprit.
Run TXTrace, each product is different as to how to run TXTrace, so I won’t go into the boring details here. If you need help, feel free to comment or googling it should result in a few good results.
The TXTrace log will show which lines of data are read into which records.
Print out the mapping report. If you choose File > Print to file, and select “Print record details”, this will create a text file with… wait for it… the record details (shocking, I know ).
In addition to other information, this shows the record name and the tag:
Record HEADER* Tag HDR at 1 Conditional
You can do a search for the word Tag, and quickly go thru and see if any are blank (in most editors, F3 is your friend, it will just go to the next):
Record HEADER* Tag at 1 Conditional
If you find yourself in a situation where there just isn’t a tag you can add, and you don’t know how many records there are going to be, if any, there’s a way around that.
For simplicity, we’ll assume we have a data file with:
You want to define a Header record, a catch all record (that will have extended rules to do whatever with the data), and then a Summary record.
The problem with leaving off the tag for the 2nd record, is that the Summary line of data will be read into it as well. In this simplified example, it wouldn’t be too bad to add additional rules, to check if it’s a Summary and send the info to temps, but in real scenarios, you could have many records after it.
In this example, we want to tell the translator to read anything into the 2nd record EXECPT if it begins with SUM. If the 2nd record doesn’t have a 3 character field that matches up with the positions of the SUM, you’ll need to add one (remember, multiple fields can overlap, so even if there is already a field with say positions 1-10, you can add another for 1-3, just do NOT auto-position the record).
You’ll then want to go to the properties of the 2nd record and choose the Key Field tab.
Here you can select the field that will match up with the positions for the SUM, and add a constant of SUM (or codelist, if there are multiple tags that could come after). The key thing here is, to make sure you check the box that says “Match record when key does not match”.
This will do exactly what we need it to. It will read any line of data into the record except for when the field you specified matches the constant you specified.
That’s it, pretty simple way around it. This will work for all of the current products…
If you’re using Gentran Director, or Gentran Server, there’s an alternative as well.
In those products, under the “Special” tab, for the record properties, there is an option to choose “Wildcard”. This does basically the same thing as the “Match record when key does not match”.
When Wildcard is selected, whatever is specified as the Tag for the record, will be what does NOT get read into the record. You can also fill out a 2nd tag in the “Alternate Tag” box, right next to the wildcard selection. In our example, you’d just put SUM in as the tag.
The only drawback to that, is anyone (or you looking at the map years from now) usually just check out the tag, most people don’t normally switch to the Special tab, to see if it’s a wildcard.
In either scenario, I like to add a quick note in the “description” of the record, so I remember it’s not a normal record.
The next time you see your data showing up in the wrong spot or disappearing, you’ll know right away to see if you’re missing a tag, and it’ll make your mapping life that much easier.
As always, any and all comments are welcome. Even a quick “thanks”, to let us know that you found this somewhat useful, is appreciated!
Feel free to request any topics or ideas as well.
Thanks for reading!
Pat Frey – IBM Support