
In the above message mapping, we can see javac, jre, args,
java as tags. The javac contains the path of the compiler, javac.exe. The jre
contains the path of the java.exe. The args contains param as subelements,
which are the arguments to the java code. Finally, the java tag contains the
source code of the mapping program.
Below is the java function getParameter and Dyna_SAP_Compiler,
accepting the input.

The all the param tags are made into a single context by a
custom java function getParameter(), which gives the output as arguments
separated by a space.


//write your code here
String output="";
InputStream in=null;
try {
String className = JavaCode.substring(JavaCode.indexOf("class") + 5, JavaCode.indexOf("{")).trim();
FileOutputStream f = new FileOutputStream(new File("c:
"+ className + ".java"));
f.write(JavaCode.getBytes());
f.close();
String javac=javac_exe" -classpath c:
. c:
" className + ".java -d c:
";
String java=jre_exe" -classpath c:
. " className" "arguments;
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(javac);
in = p.getInputStream();
InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr);
String line="";
while ( (line = br.readLine()) != null){}
p.waitFor();
p = rt.exec(java);
in = p.getInputStream();
isr = new InputStreamReader(in);
br = new BufferedReader(isr);
output="";
line="";
while ( (line = br.readLine()) != null)
{
output=line"\n";
}
p.waitFor();
} catch (Exception e) {
output = e.getMessage();
}
return output.substring(689);

This shows the unbelievable flexibility of XI to have design time work (mapping)
at runtime (using Java code).
Note: