Looks like you can use the Java API function invokeJExpression() inside Java transformation to derive the target columns.
(datatype)invokeJExpression(
String expression,
Object[] paramMetadataArray);
I guess the hard part would be to parse the concatenated string from your lookup to get the two parameters expression and paramMeradataArray
expression and paramMeradataArray should be something like below:
"concat(X1,X2)", [S1, S2]
"substr(X1,X2,X3)", [S1, 1, 3]
Note that you must start the parameters with X and number them consecutively.
Update:
Assuming from lookup you are getting the port lkp='concat(S1,S2)~T1::substr(S3,1,3)~T2::substr(S3,3,1)~T3', you can try the following code in Java transformation. However, this code might not work for all functions. For example, passing decimal values will not work.
Import Packages:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
On Input Row:
String[] arr1 = lkp.split("::");
for (int i = 0; i < arr1.length; i++) {
String[] arr2 = arr1[i].split("~");
Pattern pattern = Pattern.compile("\\((.*?)\\)");
Matcher matcher = pattern.matcher(arr2[0]);
String params = "";
if (matcher.find()) {
params = matcher.group(1);
}
String[] param = params.split(",");
Object[] args1 = new Object[param.length];
String params1 = "";
for (int j = 0; j < param.length; j++) {
int index = j + 1;
Object arg = new Object();
params1 = params1 + (!params1.equals("") ? "," : "") + "X"
+ index;
if (param[j].equals("S1"))
arg = S1;
else if (param[j].equals("S2"))
arg = S2;
else if (param[j].equals("S3"))
arg = S3;
else if (param[j].equals("S4"))
arg = S4;
else if (!param[j].startsWith("\'"))
arg = Integer.parseInt(param[j]);
else
arg = param[j];
args1[j] = arg;
}
String exp = matcher.replaceAll("(" + params1 + ")");
if (arr2[1].equals("T1"))
T1 = (String) invokeJExpression(exp, args1);
else if (arr2[1].equals("T2"))
T2 = (String) invokeJExpression(exp, args1);
else if (arr2[1].equals("T3"))
T3 = (String) invokeJExpression(exp, args1);
}