Transformation script

Transformation 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:

  1. Run the Transform. Script... command in the Configure XML File Action (datrg1225m000) session. The text editor is started.
  2. Enter the Baan C code for the script.


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)
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 
Postcondition:  o.event is filled and contains an XML structure that    
                either is or is not according to library datrgevent.

        | < Add implementation here > |

        return(0) | OK


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 =
        ERROR_IF(retl <> 0, -3)
case "change":
        | delete old values
        retl = remove.old.values(io.event)
        ERROR_IF(retl <> 0, -4)
        | no action for "create" except setting event type
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.