This example illustrates a Value-Map that replaces integer values with weekday names (1 = Sunday, 2 = Monday, and so on). This example is accompanied by a mapping which is available at the following path: <Documents>\Altova\MapForce2020\MapForceExamples\Tutorial\Expense-valmap.mfd.
This mapping extracts the day of the week from the Date item in the source file, converts the numerical value into text, and writes it to the Weekday item of the target component. More specifically, the following happens:
•The weekday function extracts the weekday number from the Date item in the source file. The result of this function are integers ranging from 1 to 7.
•The first Value-Map component transforms the integers into weekdays (1 = Sunday, 2 = Monday, and so on). If the component encounters an invalid integer outside of the 1-7 range, then it will return the text "incorrect date".
•If the weekday contains "Tuesday", then the text "Prepare Financial Reports" is written to the Notes item in the target component. This is achieved with the help of the contains function, which passes a Boolean true or false value to a second Value-Map component. The second Value-Map has the following configuration:
The Value-Map illustrated above should be understood as follows:
•Whenever a Boolean true is encountered, convert it to the text "-- Prepare financial reports -- ! ". For all other cases, return the text "--".
Notice that the data type of the first column is set to "boolean". This ensures that the input Boolean value true is recognized as such.