Basic features of data mapping


Mapping is done in the course of executing a CHANGE command.  


The find string in the CHANGE command (sometimes called string-1) can be any valid string type, such as unquoted strings or C, T, X, P, or R strings.  As noted above, for mapping, you will normally use find strings of type P or R.


Note: Format (F) strings are not allowed as find strings.


The data you find with your find string is called the source string, since it is the original source data you will be processing in your mapping operation.


Once that string is found, the characters of the source string are enumerated from left to right, with the left-most enumerated character position being 1, and the right-most being the length of the found string.


Note:  Strings of length zero are never found by the standard SPFLite search engine when searching for a Picture string, because there is literally no data to find.  However, starting with release 8.3 of SPFLite, a Regular Expression can find strings of length zero, because the Regular Expression engine has changed for 8.3; that did not occur in prior releases.  This should not affect most users, but if you should encounter any issues because of this, be sure to let us know on the SPFLite forum, so we can make sure everything is working properly


Mapping is done by selecting one or more character positions from the source string, and applying a mapping item to it.  A mapping item is either a simple column reference to the source string, or a mapping command which itself can use a column reference as an operand to its processing.


For example, if we want to change a string like ABCD into DCBA, we first have to find strings like ABCD.  Recall from the discussion above, we are not interested in finding an actual value of ABCD, because all that requires is simply a find string of ABCD.  What we are interested in is finding strings like  ABCD – that is,  word values containing 4 letters.


Suppose these strings were found as the result of a  WORD picture of P'@@@@'.  The enumeration of the character positions of a string like ABCD is:


       A = 1,  B = 2,  C = 3,  D = 4


To reorder these character values, we have to select them in the desired new order.  That is, to get a string like DCBA, we have to select the character in position 4 of the source string value, then character 3, then 2, then 1.  That is what a mapping string does.  It defines that new ordering.  So, to get a string like DCBA, it's necessary to select, and then map, these characters into the order of 4, 3, 2, 1.


A complete SPFLite command to do what is described above would look like this:


       CHANGE P'@@@@' WORD M'4-1'


Mapping strings allow for these and many additional operations, including:





Created with the Personal Edition of HelpNDoc: Full-featured multi-format Help generator