Mapping commands perform actions that are used to instruct Data Interchange Services client that a specific action is to occur, while mapping functions perform an action and return a result within an expression or assignment statement.
Mapping commands instruct the translation process on how to move data from one element to another, how to manipulate data, how to process repeating compound elements, when to issue user specified errors, and how to perform conditional processing. Most commands require parameters, such as paths that identify where data is going to or coming from, variables, constants, and expressions.
An expression as a parameter in a command can resolve to any data type as long as the data type can be converted to the data type expected by the parameter. Parameters for a command are never modified by the command. In general, data transformation maps, validation maps, and functional acknowledgment maps support most commands. Exceptions will be documented with the command.
Mapping commands example
CloseOccurence: Use the CloseOccurrence command to close the current occurrence of a repeating element and force the creation of another instance of the element. This command can be used for both source-based and target-based maps. The CloseOccurrence command has the following format:
CloseOccurrence(targetpath)
Where: targetpath specifies a repeating target element that is closed to any new elements in the current occurrence. Any additional mappings to this element or its children result in a new occurrence of the targetpath element. The CloseOccurrence command can be shortened to CloseOccur.
Example
Suppose your source document has the following structure:
Rec1
Field1
Field2
Field3
Field4
Suppose your target document has the following structure:
Seg (repeats)
Seg01
Seg02
Field1 and Field2 are to be mapped to the first occurrence of Seg (Seg01 and Seg02), and Field3 and Field4 to the second occurrence of Seg (again, Seg01 and Seg02).
The following steps describe how to accomplish this.
Mapping functions perform an action and return a result within an expression or assignment statement. All functions take 0 or more parameters as input. The number of parameters and the data type of the return value vary from one function to the next. Appropriate type conversions are done implicitly if needed (and possible). Some functions have optional parameters. If the optional parameters are omitted from the function call, a default value will be used for that parameter.
Most functions can take an expression as a parameter, as long as the result of the expression is (or can be converted to) the correct data type. For example, the Char() function converts a value to a character string. The command:
Var1 = Char ( 1 + 2 )
Is equivalent to:
Var1 = Char ( 3 )
In general, data transformation maps, validation maps, and functional acknowledgment maps support most functions. Exceptions are documented with the function.
Mapping function example
DateCnv: The DateCnv function is used to assist in converting one date format to another. The DateCnv function uses the following format:
char DateCnv(char sourceDate, char frommask, char tomask)
The actual syntax requires quotes.
For example:
Mapping Path = DateCnv('20021216', 'CCYYMMDD', 'CCYY-MM-DD')
Where: sourceDate is the string that contains the source date, frommask is the mask that identifies the format of the date in sourceDate, and tomask is the mask that identifies the format of the date desired in the result string.
Results: The converted date is a character string.
Example: Map the target field PODate in POHeader record from the source field PurchaseOrderDate in OrderRecord record. The following steps describe how to do this.