Transformation scriptTransformation scripts are used to change the contents or the structure of the event before writing it to the XML file. In some cases, events may have to be transformed to meet the receiver's need. You can for example remove attributes that are used to check a condition but should not be included in the final output. Or you can rename standard events ('create', 'change' or 'delete') to a specific event (such as 'orderedQuantityIncreased'). If required, you can even build a completely new XML structure based on the data from the event. In the transformation script, use the functions from the datrgevent library to read data from the event. To create a transformation script:
TEMPLATE Use the following code as a template for each transformation script: function extern long transform.event(ref long io.event) | IMPORTANT: do not change the interface (function name, parameter, | and return value) { DLLUSAGE Desc This function transforms a trigger event. Input io.event: event Output return value: 0 (OK) or < 0 (an error value) io.event: transformed event Precondition: i.event contains an event that is formatted according to library datrgevent and must be read using that library. Postcondition: o.event is filled and contains an XML structure that either is or is not according to library datrgevent. ENDDLLUSAGE | < Add implementation here > | return(0) | OK } EXAMPLE See the code below for an example of a transformation script: | The following transformation changes the standard events 'create', | 'change' and 'delete to a specific event 'takeAction'. Additionally, | it removes the 'old values', and in case of 'delete' it moves the | contents to the (new) values. #define ERROR_IF(condition, return.value) ^ if condition then ^ return(return.value) ^ endif string event.type(LEN_TYPE) | event type from event long retl | return value to be checked retl = datrgevent.get.event.type(io.event, event.type) ERROR_IF(retl <> 0, -2) on case event.type case "delete": retl = move.old.values.to.new.values(io.event) ERROR_IF(retl <> 0, -3) break case "change": | delete old values retl = remove.old.values(io.event) ERROR_IF(retl <> 0, -4) break default: | no action for "create" except setting event type endcase retl = datrgevent.set.event.type(io.event, "takeAction") ERROR_IF(retl <> 0, -5) Note Details on the implementation of the move/remove functions are not included in this example.
| |||