Pass variable as Reformat Port Output

Is it possible to dynamically populate port numbers with variables?
For example:

for (integer i = 0; i<=3; i++) {
		$out.i.Row = i;
	}

The above code would populate the port number in the field ‘Row’ for the first 4 (0-3) ports.

To put this in context, i’m looking for a solution to output to the “next available” port as way of handling nested rows that vary dependent on the input record.

Thanks,
Paul

Hi Paul,

you can achieve this by simple Java transformation like:


import com.opensys.cloveretl.ctl.CTLUtils;
import static com.opensys.cloveretl.ctl.CTLUtils.DECIMAL_MAX_PRECISION;

/**Top level class*/
public final class CTL_REFORMAT_22052014_15_47_15_278_0 extends org.jetel.component.CTLRecordTransform {

    /**Code from CTL function globalScopeInit()*/
    public final void globalScopeInit() throws org.jetel.exception.ComponentNotReadyException {
    }

    /**Code from CTL function transform()*/
    protected final java.lang.Integer transformDelegate() throws org.jetel.exception.ComponentNotReadyException, org.jetel.exception.TransformException {
	for (int i=0;i<3;++i) {
	    getOutputRecord(i).getField("field1").setValue(i);
	}

        return 2147483647;
    }
}


Sample graph attached.

This is great - thanks for the response.
Is it possible to achieve this using CTL2? Or is this functionality only possible using Java? If the latter, would i be able to embed Java in my existing code (which is CTL2).

Thanks,
Paul

Hi Paul,

Unfortunately this cannot be achieved by CTL2. You can either split your code into CTL2 and Java part and have 2 Reformats or convert your CTL2 code to Java. CTL2 can be converted into Java automatically - please see “Convert to Java” on http://doc.cloveretl.com/documentation/ … ditor.html for details.