TRANSFORM Structure

resulttype funcname ( parameterlist ) := TRANSFORM [, SKIP( condition )]

[ locals ]

SELF.outfield := transformation;

END;

TRANSFORM( resulttype, assignments )

TRANSFORM( datarow )

resulttypeThe name of a RECORD structure Attribute that specifies the output format of the function. You may use TYPEOF here to specify a dataset. Any implicit relationality of the input dataset is not inherited.
funcnameThe name of the function the TRANSFORM structure defines.
parameterlistA comma separated list of the value types and labels of the parameters that will be passed to the TRANSFORM function. These are usually the dataset records or COUNTER parameters but are not limited to those.
SKIPOptional. Specifies the condition under which the TRANSFORM function operation is skipped.
conditionA logical expression defining under what circumstances the TRANSFORM operation does not occur. This may use data from the parameterlist in the same manner as a transformation expression.
localsOptional. Definitions of local Attributes useful within the TRANSFORM function. These may be defined to receive parameters and may use any parameters passed to the TRANSFORM.
SELFSpecifies the resulting output recordset from the TRANSFORM.
outfieldThe name of a field in the resulttype structure.
transformationAn expression specifying how to produce the value for the outfield. This may include other TRANSFORM function operations (nested transforms).
assignmentsA semi-colon delimited list of SELF.outfield:= transformation definitions.
datarowA single record to transform, typically the keyword LEFT.

The TRANSFORM structure makes operations that must be performed on entire datasets (such as a JOIN) and any iterative type of record processing (PROJECT, ITERATE, etc.), possible. A TRANSFORM defines the specific operations that must occur on a record-by-record basis. It defines the function that is called each time the operation that uses the TRANSFORM needs to process record(s). One TRANSFORM function may be defined in terms of another, and they may be nested.

The TRANSFORM structure specifies exactly how each field in the output record set is to receive its value. That result value may simply be the value of a field in an input record set, or it may be the result of some complex calculation or conditional expression evaluation.

The TRANSFORM structure itself is a generic tool; each operation that uses a TRANSFORM function defines what its TRANSFORM needs to receive and what basic functionality it should provide. Therefore, the real key to understanding TRANSFORM structures is in understanding how it is used by the calling function -- each function that uses a TRANSFORM documents the type of TRANSFORM required to accomplish the goal, although the TRANSFORM itself may also provide extra functionality and receive extra parameters beyond those required by the operation itself.

The SKIP option specifies the condition that results in no output from that iteration of the TRANSFORM. However, COUNTER values are incremented even when SKIP eliminates generating the current record.

Transformation Attribute Definitions

The attribute definitions inside the TRANSFORM structure are used to convert the data passed in as parameters to the output resulttype format. Every field in the resulttype record layout must be fully defined in the TRANSFORM. You can explicitly define each field, using the SELF.outfield := transformation; expression, or you can use one of these shortcuts:

SELF := [ ];

clears all fields in the resulttype output that have not previously been defined in the transform function, while this form:

SELF.outfield := [];   //the outfield names a child DATASET in
                       // the resulttype RECORD Structure

clears only the child fields in the outfield, and this form:

SELF := label; //the label names a RECORD structure parameter
// in the parameterlist

defines the output for each field in the resulttype output format that has not previously been defined as coming from the label parameter's matching named field.

You may also define local attributes inside the TRANSFORM structure to better organize the code. These local attributes may receive parameters.