How to use if contion in tranform function?

How to use if condition in transform function?


import org.jetel.component.DataRecordTransform;
import org.jetel.data.*;
 
 
public class ReformatOrdersInline extends DataRecordTransform{
 
	int counter=0;
	int field=0;
 
	public int transform(DataRecord[] source, DataRecord[] target){
	System.out.println("Everthing was OK.");
	
		StringBuffer strBuf=new StringBuffer(80);
		if (source[0]==null){
		   System.err.println("NULL source[0]");
		}
		try{
		
		if(GetVal.getString(target[0],"RECORD_TYPE")=="asd")
		{
		System.out.println("Everthing was OK.");
		
		System.out.println(GetVal.getString(source[0],"RECORD_TYPE"));
			SetVal.setString(target[0],"RECORD_TYPE",GetVal.getString(source[0],"RECORD_TYPE"));	 
				SetVal.setString(target[0],"BILLING_ACCOUNT_NUMBER",GetVal.getString(source[0],"BILLING_ACCOUNT_NUMBER"));	 
				SetVal.setString(target[0],"RECORD_TYPE_PLN_ID",GetVal.getString(source[0],"RECORD_TYPE_PLN_ID")	);
				SetVal.setInt(target[0],"CHARGE_AMOUNT",GetVal.getInt(source[0],"CHARGE_AMOUNT")	);
				
			}		
					
		}catch(Exception ex){
		  ex.printStackTrace();
			errorMessage=ex.getMessage()+" ->occured with record :"+counter;
			return SKIP;
		}
		
			return ALL;
	}
}

is this correct??

Hi Kunaljd,

I don’t know what you would like to achieve, but your current code do this:

* check RECORD_TYPE==“asd”
* if equal, set output record data
* if not equal, do nothing
* in both cases send record

This is probably not what you want. If you would like to send record just in case condition is true, use “return OK;” from within block. For rest of cases return SKIP.

See http://doc.cloveretl.com/documentation/ … alues.html for details.